WP_Interactivity_API_Directives_Processor::set_content_between_balanced_tags()publicWP 6.5.0

Sets the content between two balanced tags.

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

true|false. Whether the content was successfully replaced.

Usage

$WP_Interactivity_API_Directives_Processor = new WP_Interactivity_API_Directives_Processor();
$WP_Interactivity_API_Directives_Processor->set_content_between_balanced_tags( $new_content ): bool;
$new_content(string) (required)
The string to replace the content between the matching tags.

Changelog

Since 6.5.0 Introduced.

WP_Interactivity_API_Directives_Processor::set_content_between_balanced_tags() code WP 6.8.1

public function set_content_between_balanced_tags( string $new_content ): bool {
	$positions = $this->get_after_opener_tag_and_before_closer_tag_positions( true );
	if ( ! $positions ) {
		return false;
	}
	list( $after_opener_tag, $before_closer_tag ) = $positions;

	$this->lexical_updates[] = new WP_HTML_Text_Replacement(
		$after_opener_tag,
		$before_closer_tag - $after_opener_tag,
		esc_html( $new_content )
	);

	return true;
}