WP_Interactivity_API_Directives_Processor::get_after_opener_tag_and_before_closer_tag_positions()privateWP 6.5.0

Gets the positions right after the opener tag and right before the closer tag in a balanced tag.

By default, it positions the cursor in the closer tag of the balanced tag. If $rewind is true, it seeks back to the opener tag.

Method of the class: WP_Interactivity_API_Directives_Processor{}

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Returns

Array|null. Start and end byte position, or null when no balanced tag bookmarks.

Usage

// private - for code of main (parent) class only
$result = $this->get_after_opener_tag_and_before_closer_tag_positions( $rewind );
$rewind(true|false)
Whether to seek back to the opener tag after finding the positions.
Default: false

Changelog

Since 6.5.0 Introduced.

WP_Interactivity_API_Directives_Processor::get_after_opener_tag_and_before_closer_tag_positions() code WP 6.8.1

private function get_after_opener_tag_and_before_closer_tag_positions( bool $rewind = false ) {
	// Flushes any changes.
	$this->get_updated_html();

	$bookmarks = $this->get_balanced_tag_bookmarks();
	if ( ! $bookmarks ) {
		return null;
	}
	list( $opener_tag, $closer_tag ) = $bookmarks;

	$after_opener_tag  = $this->bookmarks[ $opener_tag ]->start + $this->bookmarks[ $opener_tag ]->length;
	$before_closer_tag = $this->bookmarks[ $closer_tag ]->start;

	if ( $rewind ) {
		$this->seek( $opener_tag );
	}

	$this->release_bookmark( $opener_tag );
	$this->release_bookmark( $closer_tag );

	return array( $after_opener_tag, $before_closer_tag );
}