WordPress.org

WordPress Developer Resources

WP_Interactivity_API_Directives_Processor::get_after_opener_tag_and_before_closer_tag_positions()

WP_Interactivity_API_Directives_Processor::get_after_opener_tag_and_before_closer_tag_positions( bool $rewind = false ): array|null

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

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

Description

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.

Parameters

$rewindbooloptional
Whether to seek back to the opener tag after finding the positions. Defaults to false.

Default:false

Return

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

Source

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 + 1;
	$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 );
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.