set_attribute example

 __( 'PDF embed' );

            return str_replace( $matches['attribute']sprintf( 'aria-label="%s"', $label )$matches[0] );
        },
        $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. */
$inline_styles       = styles_for_block_core_search( $attributes );
    $color_classes       = get_color_classes_for_block_core_search( $attributes );
    $typography_classes  = get_typography_classes_for_block_core_search( $attributes );
    $is_button_inside    = ! empty( $attributes['buttonPosition'] ) &&
        'button-inside' === $attributes['buttonPosition'];
    // Border color classes need to be applied to the elements that have a border color.     $border_color_classes = get_border_color_classes_for_block_core_search( $attributes );

    $label_inner_html = empty( $attributes['label'] ) ? __( 'Search' ) : wp_kses_post( $attributes['label'] );
    $label            = new WP_HTML_Tag_Processor( sprintf( '<label %1$s>%2$s</label>', $inline_styles['label']$label_inner_html ) );
    if ( $label->next_tag() ) {
        $label->set_attribute( 'for', $input_id );
        $label->add_class( 'wp-block-search__label' );
        if ( $show_label && ! empty( $attributes['label'] ) ) {
            if ( ! empty( $typography_classes ) ) {
                $label->add_class( $typography_classes );
            }
        } else {
            $label->add_class( 'screen-reader-text' );
        }
    }

    $input         = new WP_HTML_Tag_Processor( sprintf( '<input type="search" name="s" required %s/>', $inline_styles['input'] ) );
    

    function block_core_navigation_add_directives_to_submenu( $w$block_attributes ) {
        while ( $w->next_tag(
            array(
                'tag_name'   => 'LI',
                'class_name' => 'has-child',
            )
        ) ) {
            // Add directives to the parent `<li>`.             $w->set_attribute( 'data-wp-interactive', true );
            $w->set_attribute( 'data-wp-context', '{ "core": { "navigation": { "isMenuOpen": { "click": false, "hover": false }, "overlay": false } } }' );
            $w->set_attribute( 'data-wp-effect', 'effects.core.navigation.initMenu' );
            $w->set_attribute( 'data-wp-on--focusout', 'actions.core.navigation.handleMenuFocusout' );
            $w->set_attribute( 'data-wp-on--keydown', 'actions.core.navigation.handleMenuKeydown' );
            if ( ! isset( $block_attributes['openSubmenusOnClick'] ) || false === $block_attributes['openSubmenusOnClick'] ) {
                $w->set_attribute( 'data-wp-on--mouseenter', 'actions.core.navigation.openMenuOnHover' );
                $w->set_attribute( 'data-wp-on--mouseleave', 'actions.core.navigation.closeMenuOnHover' );
            }

            // Add directives to the toggle submenu button.             if ( $w->next_tag(
                
$processor->next_tag( 'img' );

    if ( $processor->get_attribute( 'src' ) === null ) {
        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(
        
$class .= strlen( $class ) > 0 ? ' ' : '';
                $class .= $name;
            }
        }

        $this->classname_updates = array();
        if ( ! $modified ) {
            return;
        }

        if ( strlen( $class ) > 0 ) {
            $this->set_attribute( 'class', $class );
        } else {
            $this->remove_attribute( 'class' );
        }
    }

    /** * Applies attribute updates to HTML document. * * @since 6.2.0 * @since 6.2.1 Accumulates shift for internal cursor and passed pointer. * @since 6.3.0 Invalidate any bookmarks whose targets are overwritten. * * @param int $shift_this_point Accumulate and return shift for this position. * @return int How many bytes the given pointer moved in response to the updates. */
if ( ! $attributes['isLink'] ) {
        // Remove the link.         $custom_logo = preg_replace( '#<a.*?>(.*?)</a>#i', '\1', $custom_logo );
    }

    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 ) ) );
    
$link  = '<li ' . $wrapper_attributes . '>';
    $link .= '<a href="' . esc_url( $url ) . '" class="wp-block-social-link-anchor">';
    $link .= $icon;
    $link .= '<span class="wp-block-social-link-label' . ( $show_labels ? '' : ' screen-reader-text' ) . '">';
    $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() {
    
if ( ! $current_featured_image ) {
            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(
        
Home | Imprint | This part of the site doesn't use cookies.