WP_HTML_Open_Elements::pop_until( string $tag_name ): bool

Pops nodes off of the stack of open elements until one with the given tag name has been popped.

Description

See also

Parameters

$tag_namestringrequired
Name of tag that needs to be popped off of the stack of open elements.

Return

bool Whether a tag of the given name was found and popped off of the stack of open elements.

Source

public function pop_until( $tag_name ) {
	foreach ( $this->walk_up() as $item ) {
		$this->pop();

		if (
			'(internal: H1 through H6 - do not use)' === $tag_name &&
			in_array( $item->node_name, array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' ), true )
		) {
			return true;
		}

		if ( $tag_name === $item->node_name ) {
			return true;
		}
	}

	return false;
}

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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