WP_Interactivity_API_Directives_Processor::get_balanced_tag_bookmarks()privateWP 6.5.0

Returns a pair of bookmarks for the current opener tag and the matching closer tag.

It positions the cursor in the closer tag of the balanced tag, if it exists.

Method of the class: WP_Interactivity_API_Directives_Processor{}

No Hooks.

Returns

Array|null. A pair of bookmarks, or null if there's no matching closing tag.

Usage

// private - for code of main (parent) class only
$result = $this->get_balanced_tag_bookmarks();

Changelog

Since 6.5.0 Introduced.

WP_Interactivity_API_Directives_Processor::get_balanced_tag_bookmarks() code WP 6.8.1

private function get_balanced_tag_bookmarks() {
	static $i   = 0;
	$opener_tag = 'opener_tag_of_balanced_tag_' . ++$i;

	$this->set_bookmark( $opener_tag );
	if ( ! $this->next_balanced_tag_closer_tag() ) {
		$this->release_bookmark( $opener_tag );
		return null;
	}

	$closer_tag = 'closer_tag_of_balanced_tag_' . ++$i;
	$this->set_bookmark( $closer_tag );

	return array( $opener_tag, $closer_tag );
}