get_tag example


function block_core_heading_render( $attributes$content ) {
    if ( ! $content ) {
        return $content;
    }

    $p = new WP_HTML_Tag_Processor( $content );

    $header_tags = array( 'H1', 'H2', 'H3', 'H4', 'H5', 'H6' );
    while ( $p->next_tag() ) {
        if ( in_array( $p->get_tag()$header_tags, true ) ) {
            $p->add_class( 'wp-block-heading' );
            break;
        }
    }

    return $p->get_updated_html();
}

/** * Registers the `core/heading` block on server. */
            if ( $this->matches() ) {
                ++$already_found;
            }

            /* * For non-DATA sections which might contain text that looks like HTML tags but * isn't, scan with the appropriate alternative mode. Looking at the first letter * of the tag name as a pre-check avoids a string allocation when it's not needed. */
            $t = $this->html[ $this->tag_name_starts_at ];
            if ( ! $this->is_closing_tag && ( 's' === $t || 'S' === $t || 't' === $t || 'T' === $t ) ) {
                $tag_name = $this->get_tag();

                if ( 'SCRIPT' === $tag_name && ! $this->skip_script_data() ) {
                    $this->bytes_already_parsed = strlen( $this->html );
                    return false;
                } elseif (
                    ( 'TEXTAREA' === $tag_name || 'TITLE' === $tag_name ) &&
                    ! $this->skip_rcdata( $tag_name )
                ) {
                    $this->bytes_already_parsed = strlen( $this->html );
                    return false;
                }
            }
Home | Imprint | This part of the site doesn't use cookies.