[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/html-api/ -> class-wp-html-open-elements.php (summary)

HTML API: WP_HTML_Open_Elements class

File Size: 462 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_HTML_Open_Elements:: (18 methods):
  contains_node()
  count()
  current_node()
  has_element_in_specific_scope()
  has_element_in_scope()
  has_element_in_list_item_scope()
  has_element_in_button_scope()
  has_element_in_table_scope()
  has_element_in_select_scope()
  has_p_in_button_scope()
  pop()
  pop_until()
  push()
  remove_node()
  walk_down()
  walk_up()
  after_element_push()
  after_element_pop()


Class: WP_HTML_Open_Elements  - X-Ref

Core class used by the HTML processor during HTML parsing
for managing the stack of open elements.

This class is designed for internal use by the HTML processor.

> Initially, the stack of open elements is empty. The stack grows
> downwards; the topmost node on the stack is the first one added
> to the stack, and the bottommost node of the stack is the most
> recently added node in the stack (notwithstanding when the stack
> is manipulated in a random access fashion as part of the handling
> for misnested tags).

contains_node( $token )   X-Ref
Reports if a specific node is in the stack of open elements.

return: bool Whether the referenced node is in the stack of open elements.
param: WP_HTML_Token $token Look for this node in the stack.

count()   X-Ref
Returns how many nodes are currently in the stack of open elements.

return: int How many node are in the stack of open elements.

current_node()   X-Ref
Returns the node at the end of the stack of open elements,
if one exists. If the stack is empty, returns null.

return: WP_HTML_Token|null Last node in the stack of open elements, if one exists, otherwise null.

has_element_in_specific_scope( $tag_name, $termination_list )   X-Ref
Returns whether an element is in a specific scope.

## HTML Support

This function skips checking for the termination list because there
are no supported elements which appear in the termination list.

return: bool Whether the element was found in a specific scope.
param: string   $tag_name         Name of tag check.
param: string[] $termination_list List of elements that terminate the search.

has_element_in_scope( $tag_name )   X-Ref
Returns whether a particular element is in scope.

return: bool Whether given element is in scope.
param: string $tag_name Name of tag to check.

has_element_in_list_item_scope( $tag_name )   X-Ref
Returns whether a particular element is in list item scope.

return: bool Whether given element is in scope.
param: string $tag_name Name of tag to check.

has_element_in_button_scope( $tag_name )   X-Ref
Returns whether a particular element is in button scope.

return: bool Whether given element is in scope.
param: string $tag_name Name of tag to check.

has_element_in_table_scope( $tag_name )   X-Ref
Returns whether a particular element is in table scope.

return: bool Whether given element is in scope.
param: string $tag_name Name of tag to check.

has_element_in_select_scope( $tag_name )   X-Ref
Returns whether a particular element is in select scope.

return: bool Whether given element is in scope.
param: string $tag_name Name of tag to check.

has_p_in_button_scope()   X-Ref
Returns whether a P is in BUTTON scope.

return: bool Whether a P is in BUTTON scope.

pop()   X-Ref
Pops a node off of the stack of open elements.

return: bool Whether a node was popped off of the stack.

pop_until( $tag_name )   X-Ref
Pops nodes off of the stack of open elements until one with the given tag name has been popped.

return: bool Whether a tag of the given name was found and popped off of the stack of open elements.
param: string $tag_name Name of tag that needs to be popped off of the stack of open elements.

push( $stack_item )   X-Ref
Pushes a node onto the stack of open elements.

param: WP_HTML_Token $stack_item Item to add onto stack.

remove_node( $token )   X-Ref
Removes a specific node from the stack of open elements.

return: bool Whether the node was found and removed from the stack of open elements.
param: WP_HTML_Token $token The node to remove from the stack of open elements.

walk_down()   X-Ref
Steps through the stack of open elements, starting with the top element
(added first) and walking downwards to the one added last.

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

Example:

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

To start with the most-recently added element and walk towards the top,
see WP_HTML_Open_Elements::walk_up().


walk_up( $above_this_node = null )   X-Ref
Steps through the stack of open elements, starting with the bottom element
(added last) and walking upwards to the one added first.

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().

param: ?WP_HTML_Token $above_this_node Start traversing above this node, if provided and if the node exists.

after_element_push( $item )   X-Ref
Updates internal flags after adding an element.

Certain conditions (such as "has_p_in_button_scope") are maintained here as
flags that are only modified when adding and removing elements. This allows
the HTML Processor to quickly check for these conditions instead of iterating
over the open stack elements upon each new tag it encounters. These flags,
however, need to be maintained as items are added and removed from the stack.

param: WP_HTML_Token $item Element that was added to the stack of open elements.

after_element_pop( $item )   X-Ref
Updates internal flags after removing an element.

Certain conditions (such as "has_p_in_button_scope") are maintained here as
flags that are only modified when adding and removing elements. This allows
the HTML Processor to quickly check for these conditions instead of iterating
over the open stack elements upon each new tag it encounters. These flags,
however, need to be maintained as items are added and removed from the stack.

param: WP_HTML_Token $item Element that was removed from the stack of open elements.



Generated : Sat Apr 27 08:20:02 2024 Cross-referenced by PHPXref