WP_HTML_Open_Elements::walk_up( ?WP_HTML_Token $above_this_node = null )

In this article

Steps through the stack of open elements, starting with the bottom element (added last) and walking upwards to the one added first.

Description

This generator function is designed to be used inside a "foreach" loop.

Example:

$html = '<em><strong><a>We are here';
foreach ( $stack->walk_up() as $node ) {
    echo "{$node->node_name} -> ";
}
> A -> STRONG -> EM ->

To start with the first added element and walk towards the bottom, see WP_HTML_Open_Elements::walk_down().

Parameters

$above_this_node?WP_HTML_Tokenoptional
Start traversing above this node, if provided and if the node exists.

Default:null

Source

 * > consisting of the following element types:
 * >
 * >   - All the element types listed above for the has an element in scope algorithm.
 * >   - button in the HTML namespace
 *
 * @since 6.4.0
 * @since 6.7.0 Supports all required HTML elements.
 *
 * @see https://html.spec.whatwg.org/#has-an-element-in-button-scope
 *
 * @param string $tag_name Name of tag to check.
 * @return bool Whether given element is in scope.
 */
public function has_element_in_button_scope( string $tag_name ): bool {

Changelog

VersionDescription
6.5.0Accepts $above_this_node to start traversal above a given node, if it exists.
6.4.0Introduced.

User Contributed Notes

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