get_updated_html example

if ( empty( $block_settings ) ) {
        return $block_content;
    }

    // Like the layout hook this assumes the hook only applies to blocks with a single wrapper.     // Add the class name to the first element, presuming it's the wrapper, if it exists.     $tags = new WP_HTML_Tag_Processor( $block_content );
    if ( $tags->next_tag() ) {
        $tags->add_class( _wp_get_presets_class_name( $block ) );
    }

    return $tags->get_updated_html();
}

/** * Render the block level presets stylesheet. * * @internal * * @since 6.2.0 * @since 6.3.0 Updated preset styles to use Selectors API. * @access private * * @param string|null $pre_render The pre-rendered content. Default null. * @param array $block The block being rendered. * * @return null */

    private function skip_whitespace() {
        $this->bytes_already_parsed += strspn( $this->html, " \t\f\r\n", $this->bytes_already_parsed );
    }

    /** * Applies attribute updates and cleans up once a tag is fully parsed. * * @since 6.2.0 */
    private function after_tag() {
        $this->get_updated_html();
        $this->tag_name_starts_at = null;
        $this->tag_name_length    = null;
        $this->tag_ends_at        = null;
        $this->is_closing_tag     = null;
        $this->attributes         = array();
    }

    /** * Converts class name updates into tag attributes updates * (they are accumulated in different data formats for performance). * * @since 6.2.0 * * @see WP_HTML_Tag_Processor::$lexical_updates * @see WP_HTML_Tag_Processor::$classname_updates */
$inner_blocks_html = '';
        foreach ( $block->inner_blocks as $inner_block ) {
            $inner_blocks_html .= $inner_block->render();
        }

        if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) {
            $tag_processor = new WP_HTML_Tag_Processor( $html );
            while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-navigation-item__content' ) ) ) {
                $tag_processor->add_class( 'current-menu-ancestor' );
            }
            $html = $tag_processor->get_updated_html();
        }

        $wrapper_attributes = get_block_wrapper_attributes(
            array(
                'class' => $css_classes,
                'style' => $style_attribute,
            )
        );

        $html .= sprintf(
            '<ul %s>%s</ul>',
            
return $content;
        }

        $processor = new WP_HTML_Tag_Processor( $content );
        $processor->next_tag();

        $styles         = $processor->get_attribute( 'style' );
        $merged_styles  = ! empty( $styles ) ? $styles . ';' : '';
        $merged_styles .= 'background-image:url(' . esc_url( $current_featured_image ) . ');';

        $processor->set_attribute( 'style', $merged_styles );
        $content = $processor->get_updated_html();
    }

    return $content;
}

/** * Registers the `core/cover` block renderer on server. */
function register_block_core_cover() {
    register_block_type_from_metadata(
        __DIR__ . '/cover',
        
if ( null === $link_color && null === $hover_link_color ) {
        return $block_content;
    }

    // Like the layout hook this assumes the hook only applies to blocks with a single wrapper.     // Add the class name to the first element, presuming it's the wrapper, if it exists.     $tags = new WP_HTML_Tag_Processor( $block_content );
    if ( $tags->next_tag() ) {
        $tags->add_class( wp_get_elements_class_name( $block ) );
    }

    return $tags->get_updated_html();
}

/** * Renders the elements stylesheet. * * In the case of nested blocks we want the parent element styles to be rendered before their descendants. * This solves the issue of an element (e.g.: link color) being styled in both the parent and a descendant: * we want the descendant style to take priority, and this is done by loading it after, in DOM order. * * @since 6.0.0 * @since 6.1.0 Implemented the style engine to generate CSS and classnames. * @access private * * @param string|null $pre_render The pre-rendered content. Default null. * @param array $block The block being rendered. * @return null */


    if ( $attributes['isLink'] && '_blank' === $attributes['linkTarget'] ) {
        // Add the link target after the rel="home".         // Add an aria-label for informing that the page opens in a new tab.         $processor = new WP_HTML_Tag_Processor( $custom_logo );
        $processor->next_tag( 'a' );
        if ( 'home' === $processor->get_attribute( 'rel' ) ) {
            $processor->set_attribute( 'aria-label', __( '(Home link, opens in a new tab)' ) );
            $processor->set_attribute( 'target', $attributes['linkTarget'] );
        }
        $custom_logo = $processor->get_updated_html();
    }

    $classnames = array();
    if ( empty( $attributes['width'] ) ) {
        $classnames[] = 'is-default-size';
    }

    $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) );
    $html               = sprintf( '<div %s>%s</div>', $wrapper_attributes$custom_logo );
    return $html;
}

'tag_name'   => 'BUTTON',
                    'class_name' => 'wp-block-navigation-submenu__toggle',
                )
            ) ) {
                $w->set_attribute( 'data-wp-on--click', 'actions.core.navigation.toggleMenuOnClick' );
                $w->set_attribute( 'data-wp-bind--aria-expanded', 'selectors.core.navigation.isMenuOpen' );
            };

            // Iterate through subitems if exist.             block_core_navigation_add_directives_to_submenu( $w$block_attributes );
        }
        return $w->get_updated_html();
    };

    /** * Replaces view script for the Navigation block with version using Interactivity API. * * @param array $metadata Block metadata as read in via block.json. * * @return array Filtered block type metadata. */
    function gutenberg_block_core_navigation_update_interactive_view_script( $metadata ) {
        if ( 'core/navigation' === $metadata['name'] ) {
            
$link .= esc_html( $label );
    $link .= '</span></a></li>';

    $processor = new WP_HTML_Tag_Processor( $link );
    $processor->next_tag( 'a' );
    if ( $open_in_new_tab ) {
        $processor->set_attribute( 'rel', esc_attr( $rel ) . ' noopener nofollow' );
        $processor->set_attribute( 'target', '_blank' );
    } elseif ( '' !== $rel ) {
        $processor->set_attribute( 'rel', esc_attr( $rel ) );
    }
    return $processor->get_updated_html();
}

/** * Registers the `core/social-link` blocks. */
function register_block_core_social_link() {
    register_block_type_from_metadata(
        __DIR__ . '/social-link',
        array(
            'render_callback' => 'render_block_core_social_link',
        )
    );
            $filter_value = self::get_css_var( $slug ); // e.g. 'var(--wp--preset--duotone--blue-orange)'.
            // CSS custom property, SVG filter, and block CSS.             self::enqueue_global_styles_preset( $filter_id$duotone_selector$filter_value );
        }

        // Like the layout hook, this assumes the hook only applies to blocks with a single wrapper.         $tags = new WP_HTML_Tag_Processor( $block_content );
        if ( $tags->next_tag() ) {
            $tags->add_class( $filter_id );
        }
        return $tags->get_updated_html();
    }

    /** * Appends the used block duotone filter declarations to the inline block supports CSS. * * Uses the declarations saved in earlier calls to self::enqueue_block_css. * * @since 6.3.0 */
    public static function output_block_styles() {
        if ( ! empty( self::$block_css_declarations ) ) {
            
$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. */
function register_block_core_heading() {
    register_block_type_from_metadata(
        __DIR__ . '/heading',
        array(
            'render_callback' => 'block_core_heading_render',
        )
    );
$content
    );

    // If it uses the Interactivity API, add the directives.     if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
        $processor = new WP_HTML_Tag_Processor( $content );
        $processor->next_tag();
        $processor->set_attribute( 'data-wp-interactive', '' );
        $processor->next_tag( 'object' );
        $processor->set_attribute( 'data-wp-bind--hidden', '!selectors.core.file.hasPdfPreview' );
        $processor->set_attribute( 'hidden', true );
        return $processor->get_updated_html();
    }

    return $content;
}

/** * Registers the `core/file` block on server. */
function register_block_core_file() {
    register_block_type_from_metadata(
        __DIR__ . '/file',
        
return '';
    }

    if ( isset( $attributes['data-id'] ) ) {
        // Add the data-id="$id" attribute to the img element         // to provide backwards compatibility for the Gallery Block,         // which now wraps Image Blocks within innerBlocks.         // The data-id attribute is added in a core/gallery `render_block_data` hook.         $processor->set_attribute( 'data-id', $attributes['data-id'] );
    }

    return $processor->get_updated_html();
}

/** * Registers the `core/image` block on server. */
function register_block_core_image() {

    register_block_type_from_metadata(
        __DIR__ . '/image',
        array(
            'render_callback' => 'render_block_core_image',
        )
Home | Imprint | This part of the site doesn't use cookies.