WordPress.org

WordPress Developer Resources

WP_Interactivity_API_Directives_Processor::get_content_between_balanced_template_tags()

WP_Interactivity_API_Directives_Processor::get_content_between_balanced_template_tags(): string|null

In this article

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.

Returns the content between two balanced template tags.

Description

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

Return

string|null The content between the current opener template tag and its matching closer tag or null if it doesn’t find the matching closing tag or the current tag is not a template opener tag.

Source

public function get_content_between_balanced_template_tags() {
	if ( 'TEMPLATE' !== $this->get_tag() ) {
		return null;
	}

	$positions = $this->get_after_opener_tag_and_before_closer_tag_positions();
	if ( ! $positions ) {
		return null;
	}
	list( $after_opener_tag, $before_closer_tag ) = $positions;

	return substr( $this->html, $after_opener_tag, $before_closer_tag - $after_opener_tag );
}

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

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