WP_Interactivity_API_Directives_Processor::append_content_after_template_tag_closer()publicWP 1.0

Appends content after the closing tag of a template tag.

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

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 appended.

Usage

$WP_Interactivity_API_Directives_Processor = new WP_Interactivity_API_Directives_Processor();
$WP_Interactivity_API_Directives_Processor->append_content_after_template_tag_closer( $new_content ): bool;
$new_content(string) (required)
The string to append after the closing template tag.

WP_Interactivity_API_Directives_Processor::append_content_after_template_tag_closer() code WP 6.8.1

public function append_content_after_template_tag_closer( string $new_content ): bool {
	if ( empty( $new_content ) || 'TEMPLATE' !== $this->get_tag() || ! $this->is_tag_closer() ) {
		return false;
	}

	// Flushes any changes.
	$this->get_updated_html();

	$bookmark = 'append_content_after_template_tag_closer';
	$this->set_bookmark( $bookmark );
	$after_closing_tag = $this->bookmarks[ $bookmark ]->start + $this->bookmarks[ $bookmark ]->length;
	$this->release_bookmark( $bookmark );

	// Appends the new content.
	$this->lexical_updates[] = new WP_HTML_Text_Replacement( $after_closing_tag, 0, $new_content );

	return true;
}