WP_HTML_Tag_Processor::is_tag_closerpublicWP 6.2.0

Indicates if the current tag token is a tag closer.

Example:

$p = new WP_HTML_Tag_Processor( '<div></div>' );
$p->next_tag( array( 'tag_name' => 'div', 'tag_closers' => 'visit' ) );
$p->is_tag_closer() === false;
$p->next_tag( array( 'tag_name' => 'div', 'tag_closers' => 'visit' ) );
$p->is_tag_closer() === true;

Method of the class: WP_HTML_Tag_Processor{}

No Hooks.

Returns

true|false. Whether the current tag is a tag closer.

Usage

$WP_HTML_Tag_Processor = new WP_HTML_Tag_Processor();
$WP_HTML_Tag_Processor->is_tag_closer(): bool;

Changelog

Since 6.2.0 Introduced.
Since 6.7.0 Reports all BR tags as opening tags.

WP_HTML_Tag_Processor::is_tag_closer() code WP 6.8.1

public function is_tag_closer(): bool {
	return (
		self::STATE_MATCHED_TAG === $this->parser_state &&
		$this->is_closing_tag &&

		/*
		 * The BR tag can only exist as an opening tag. If something like `</br>`
		 * appears then the HTML parser will treat it as an opening tag with no
		 * attributes. The BR tag is unique in this way.
		 *
		 * @see https://html.spec.whatwg.org/#parsing-main-inbody
		 */
		'BR' !== $this->get_tag()
	);
}