WordPress.org

WordPress Developer Resources

WP_Interactivity_API_Directives_Processor::append_content_after_template_tag_closer()

WP_Interactivity_API_Directives_Processor::append_content_after_template_tag_closer( string $new_content ): bool

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.

Appends content after the closing tag of a template tag.

Description

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

Parameters

$new_contentstringrequired
The string to append after the closing template tag.

Return

bool Whether the content was successfully appended.

Source

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 + 1;
	$this->release_bookmark( $bookmark );

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

	return true;
}

User Contributed Notes

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