WP_HTML_Open_Elements::at()publicWP 6.7.0

Returns the name of the node at the nth position on the stack of open elements, or null if no such position exists.

Note that this uses a 1-based index, which represents the "nth item" on the stack, counting from the top, where the top-most element is the 1st, the second is the 2nd, etc...

Method of the class: WP_HTML_Open_Elements{}

No Hooks.

Return

WP_HTML_Token|null. Name of the node on the stack at the given location, or null if the location isn't on the stack.

Usage

$WP_HTML_Open_Elements = new WP_HTML_Open_Elements();
$WP_HTML_Open_Elements->at( $nth ): ?WP_HTML_Token;
$nth(int) (required)
Retrieve the nth item on the stack, with 1 being the top element, 2 being the second, etc...

Changelog

Since 6.7.0 Introduced.

WP_HTML_Open_Elements::at() code WP 6.7.1

public function at( int $nth ): ?WP_HTML_Token {
	foreach ( $this->walk_down() as $item ) {
		if ( 0 === --$nth ) {
			return $item;
		}
	}

	return null;
}