WP_HTML_Tag_Processor::has_self_closing_flag(): bool

In this article

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

Description

No HTML elements ought to have the self-closing flag and for those, the self-closing flag will be ignored. For void elements this is benign because they "self close" automatically. For non-void HTML elements though problems will appear if someone intends to use a self-closing element in place of that element with an empty body.
For HTML foreign elements and custom elements the self-closing flag determines if they self-close or not.

This function does not determine if a tag is self-closing, but only if the self-closing flag is present in the syntax.

Return

bool Whether the currently matched tag contains the self-closing flag.

Source

 *     $p->get_attribute( 'enabled' ) === true;
 *     $p->get_attribute( 'aria-label' ) === null;
 *
 *     $p->next_tag() === false;
 *     $p->get_attribute( 'class' ) === null;
 *
 * @since 6.2.0
 *
 * @param string $name Name of attribute whose value is requested.
 * @return string|true|null Value of attribute or `null` if not available. Boolean attributes return `true`.
 */
public function get_attribute( $name ) {
	if ( self::STATE_MATCHED_TAG !== $this->parser_state ) {
		return null;
	}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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