WP_HTML_Tag_Processor::class_list()

In this article

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

Description

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

Example:

$p = new WP_HTML_Tag_Processor( "<div class='free &lt;egg&lt;\tlang-en'>" );
$p->next_tag();
foreach ( $p->class_list() as $class_name ) {
    echo "{$class_name} ";
}
// Outputs: "free <egg> lang-en "

Source

 * There are certain elements whose children are not DATA but are instead
 * RCDATA or RAWTEXT. These cannot contain other elements, and the contents
 * are parsed as plaintext, with character references decoded in RCDATA but
 * not in RAWTEXT.
 *
 * These elements are described here as "self-contained" or special atomic
 * elements whose end tag is consumed with the opening tag, and they will
 * contain modifiable text inside of them.
 *
 * Preserve the opening tag pointers, as these will be overwritten
 * when finding the closing tag. They will be reset after finding
 * the closing to tag to point to the opening of the special atomic
 * tag sequence.
 */
$tag_name_starts_at   = $this->tag_name_starts_at;
$tag_name_length      = $this->tag_name_length;
$tag_ends_at          = $this->token_starts_at + $this->token_length;
$attributes           = $this->attributes;
$duplicate_attributes = $this->duplicate_attributes;

// Find the closing tag if necessary.
switch ( $tag_name ) {
	case 'SCRIPT':
		$found_closer = $this->skip_script_data();
		break;

	case 'TEXTAREA':
	case 'TITLE':
		$found_closer = $this->skip_rcdata( $tag_name );
		break;

	/*
	 * In the browser this list would include the NOSCRIPT element,
	 * but the Tag Processor is an environment with the scripting
	 * flag disabled, meaning that it needs to descend into the
	 * NOSCRIPT element to be able to properly process what will be
	 * sent to a browser.
	 *
	 * Note that this rule makes HTML5 syntax incompatible with XML,
	 * because the parsing of this token depends on client application.
	 * The NOSCRIPT element cannot be represented in the XHTML syntax.
	 */
	case 'IFRAME':
	case 'NOEMBED':
	case 'NOFRAMES':
	case 'STYLE':
	case 'XMP':
		$found_closer = $this->skip_rawtext( $tag_name );
		break;

Changelog

VersionDescription
6.4.0Introduced.

User Contributed Notes

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