WPDev.one
Core Class

WP_HTML_Processor

class WP_HTML_Processor // Constructor: function Object() { [native code] }

Core class used to safely parse and modify an HTML document.

Methods 79 methods

Method / Return Description
create_fragment()
(static

Creates an HTML processor in the fragment parsing mode.

Parameters: $html: mixed, $context: mixed, $encoding: mixed
create_full_parser()
(static

Creates an HTML processor in the full parsing mode.

Parameters: $html: mixed, $known_definite_encoding: mixed
__construct()
void

Constructor.

Parameters: $html: mixed, $use_the_static_create_methods_instead: mixed
create_fragment_at_current_node()
(static

Creates a fragment processor at the current node.

Parameters: $html: string
bail()
void

Stops the parser and terminates its execution when encountering unsupported markup.

Parameters: $message: string
get_last_error()
(string

Returns the last error, if any.

get_unsupported_exception()
(WP_HTML_Unsupported_Exception

Returns context for why the parser aborted due to unsupported HTML, if it did.

next_tag()
bool

Finds the next tag matching the $query.

Parameters: $query: mixed
next_token()
bool

Finds the next token in the HTML document.

next_visitable_token()
bool

Ensures internal accounting is maintained for HTML semantic rules while

is_tag_closer()
bool

Indicates if the current tag token is a tag closer.

is_virtual()
bool

Indicates if the currently-matched token is virtual, created by a stack operation

matches_breadcrumbs()
bool

Indicates if the currently-matched tag matches the given breadcrumbs.

Parameters: $breadcrumbs: mixed
expects_closer()
(bool

Indicates if the currently-matched node expects a closing

Parameters: $node: ?WP_HTML_Token
step()
bool

Steps through the HTML document and stop at the next tag, if any.

Parameters: $node_to_process: mixed
get_breadcrumbs()
string[]

Computes the HTML breadcrumbs for the currently-matched node, if matched.

get_current_depth()
int

Returns the nesting depth of the current location in the document.

normalize()
(string

Normalizes an HTML fragment by serializing it.

Parameters: $html: string
serialize()
(string

Returns normalized HTML for a fragment by serializing it.

serialize_token()
string

Serializes the currently-matched token.

step_initial()
bool

Parses next element in the 'initial' insertion mode.

step_before_html()
bool

Parses next element in the 'before html' insertion mode.

step_before_head()
bool

Parses next element in the 'before head' insertion mode.

step_in_head()
bool

Parses next element in the 'in head' insertion mode.

step_in_head_noscript()
bool

Parses next element in the 'in head noscript' insertion mode.

step_after_head()
bool

Parses next element in the 'after head' insertion mode.

step_in_body()
bool

Parses next element in the 'in body' insertion mode.

step_in_table()
bool

Parses next element in the 'in table' insertion mode.

step_in_table_text()
bool

Parses next element in the 'in table text' insertion mode.

step_in_caption()
bool

Parses next element in the 'in caption' insertion mode.

step_in_column_group()
bool

Parses next element in the 'in column group' insertion mode.

step_in_table_body()
bool

Parses next element in the 'in table body' insertion mode.

step_in_row()
bool

Parses next element in the 'in row' insertion mode.

step_in_cell()
bool

Parses next element in the 'in cell' insertion mode.

step_in_select()
bool

Parses next element in the 'in select' insertion mode.

step_in_select_in_table()
bool

Parses next element in the 'in select in table' insertion mode.

step_in_template()
bool

Parses next element in the 'in template' insertion mode.

step_after_body()
bool

Parses next element in the 'after body' insertion mode.

step_in_frameset()
bool

Parses next element in the 'in frameset' insertion mode.

step_after_frameset()
bool

Parses next element in the 'after frameset' insertion mode.

step_after_after_body()
bool

Parses next element in the 'after after body' insertion mode.

step_after_after_frameset()
bool

Parses next element in the 'after after frameset' insertion mode.

step_in_foreign_content()
bool

Parses next element in the 'in foreign content' insertion mode.

bookmark_token()
(string

Creates a new bookmark for the currently-matched token and returns the generated name.

get_namespace()
string

Indicates the namespace of the current token, or "html" if there is none.

get_tag()
(string

Returns the uppercase name of the matched tag.

has_self_closing_flag()
bool

Indicates if the currently matched tag contains the self-closing flag.

get_token_name()
(string

Returns the node name represented by the token.

get_token_type()
(string

Indicates the kind of matched token, if any.

get_attribute()
(string

Returns the value of a requested attribute from a matched tag opener if that attribute exists.

Parameters: $name: mixed
set_attribute()
bool

Updates or creates a new attribute on the currently matched tag with the passed value.

Parameters: $name: mixed, $value: mixed
remove_attribute()
bool

Remove an attribute from the currently-matched tag.

Parameters: $name: mixed
get_attribute_names_with_prefix()
(array

Gets lowercase names of all attributes matching a given prefix in the current tag.

Parameters: $prefix: mixed
add_class()
bool

Adds a new class name to the currently matched tag.

Parameters: $class_name: mixed
remove_class()
bool

Removes a class name from the currently matched tag.

Parameters: $class_name: mixed
has_class()
(bool

Returns if a matched tag contains the given ASCII case-insensitive class name.

Parameters: $wanted_class: mixed
class_list()
void

Generator for a foreach loop to step through each class name for the matched tag.

get_modifiable_text()
string

Returns the modifiable text for a matched token, or an empty string.

get_comment_type()
(string

Indicates what kind of comment produced the comment node.

release_bookmark()
bool

Removes a bookmark that is no longer needed.

Parameters: $bookmark_name: mixed
seek()
bool

Moves the internal cursor in the HTML Processor to a given bookmark's location.

Parameters: $bookmark_name: mixed
set_bookmark()
bool

Sets a bookmark in the HTML document.

Parameters: $bookmark_name: mixed
has_bookmark()
bool

Checks whether a bookmark with the given name exists.

Parameters: $bookmark_name: mixed
close_a_p_element()
void

Closes a P element.

generate_implied_end_tags()
void

Closes elements that have implied end tags.

Parameters: $except_for_this_element: ?string
generate_implied_end_tags_thoroughly()
void

Closes elements that have implied end tags, thoroughly.

get_adjusted_current_node()
(WP_HTML_Token

Returns the adjusted current node.

reconstruct_active_formatting_elements()
bool

Reconstructs the active formatting elements.

reset_insertion_mode_appropriately()
void

Runs the reset the insertion mode appropriately algorithm.

run_adoption_agency_algorithm()
void

Runs the adoption agency algorithm.

close_cell()
void

Runs the "close the cell" algorithm.

insert_html_element()
void

Inserts an HTML element on the stack of open elements.

Parameters: $token: WP_HTML_Token
insert_foreign_element()
void

Inserts a foreign element on to the stack of open elements.

Parameters: $token: WP_HTML_Token, $only_add_to_element_stack: bool
insert_virtual_node()
WP_HTML_Token

Inserts a virtual element on the stack of open elements.

Parameters: $token_name: mixed, $bookmark_name: mixed
is_mathml_integration_point()
bool

Indicates if the current token is a MathML integration point.

is_html_integration_point()
bool

Indicates if the current token is an HTML integration point.

is_special()
bool

Returns whether an element of a given name is in the HTML special category.

Parameters: $tag_name: mixed
is_void()
bool

Returns whether a given element is an HTML Void Element

Parameters: $tag_name: mixed
get_encoding()
(string

Gets an encoding from a given string.

Parameters: $label: string

Properties

Property / Type Description
$state
mixed
public
No description available.
$bookmark_counter
mixed
public
No description available.
$last_error
mixed
public
No description available.
$unsupported_exception
mixed
public
No description available.
$release_internal_bookmark_on_destruct
mixed
public
No description available.
$element_queue
mixed
public
No description available.
$breadcrumbs
mixed
public
No description available.
$current_element
mixed
public
No description available.
$context_node
mixed
public
No description available.

Class Information

Since Version
6.4.0
Source File
wp-includes/html-api/class-wp-html-processor.php
Advertisement