Make WordPress Core


Ignore:
Timestamp:
04/12/2022 03:10:30 PM (3 years ago)
Author:
gziolo
Message:

Editor: Update WordPress packages based based on Gutenberg v13.0 RC3

This is the last step of backports from the Gutenberg plugin for WordPress 6.0 Beta 1 release. It includes all updates WordPress packages published to npm based on the Gutenberg plugin v13.0 RC3 release. This patch also includes all the necessary changes applied to core blocks. New blocks included:

  • Avatar
  • Comment Author Name
  • Comment Content
  • Comment Date
  • Comment Edit Link
  • Comment Rely Link
  • Comment Template
  • Comments Pagination
  • Comments Pagination Next
  • Comments Pagination Previous
  • Comments Query Loop
  • Home Link
  • Post Author Biography
  • Query No Results
  • Read More

See more details in https://github.com/WordPress/wordpress-develop/pull/2564.

Props zieladam, ramonopoly, ocean90.
Fixes #55505.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks/navigation.php

    r52402 r53157  
    246246 */
    247247function block_core_navigation_render_submenu_icon() {
    248     return '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" role="img" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
     248    return '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
    249249}
    250250
     
    344344     * children of the `core/navigation` block.
    345345     *
     346     * @since 5.9.0
     347     *
    346348     * @param array[] default fallback blocks provided by the default block mechanic.
    347349     */
     
    352354 * Renders the `core/navigation` block on server.
    353355 *
    354  * @param array $attributes The block attributes.
    355  * @param array $content The saved content.
    356  * @param array $block The parsed block.
     356 * @param array    $attributes The block attributes.
     357 * @param string   $content    The saved content.
     358 * @param WP_Block $block      The parsed block.
    357359 *
    358360 * @return string Returns the post content with the legacy widget added.
    359361 */
    360362function render_block_core_navigation( $attributes, $content, $block ) {
     363
     364    static $seen_menu_names = array();
    361365
    362366    // Flag used to indicate whether the rendered output is considered to be
    363367    // a fallback (i.e. the block has no menu associated with it).
    364368    $is_fallback = false;
     369
     370    $nav_menu_name = '';
    365371
    366372    /**
     
    427433        }
    428434
     435        $nav_menu_name = $navigation_post->post_title;
     436
     437        if ( isset( $seen_menu_names[ $nav_menu_name ] ) ) {
     438            ++$seen_menu_names[ $nav_menu_name ];
     439        } else {
     440            $seen_menu_names[ $nav_menu_name ] = 1;
     441        }
     442
    429443        $parsed_blocks = parse_blocks( $navigation_post->post_content );
    430444
     
    472486        $layout_class .= ' no-wrap';
    473487    }
     488
     489    // Manually add block support text decoration as CSS class.
     490    $text_decoration       = _wp_array_get( $attributes, array( 'style', 'typography', 'textDecoration' ), null );
     491    $text_decoration_class = sprintf( 'has-text-decoration-%s', $text_decoration );
    474492
    475493    $colors     = block_core_navigation_build_css_colors( $attributes );
     
    480498        $is_responsive_menu ? array( 'is-responsive' ) : array(),
    481499        $layout_class ? array( $layout_class ) : array(),
    482         $is_fallback ? array( 'is-fallback' ) : array()
     500        $is_fallback ? array( 'is-fallback' ) : array(),
     501        $text_decoration ? array( $text_decoration_class ) : array()
    483502    );
    484503
     
    507526    $block_styles = isset( $attributes['styles'] ) ? $attributes['styles'] : '';
    508527
     528    // If the menu name has been used previously then append an ID
     529    // to the name to ensure uniqueness across a given post.
     530    if ( isset( $seen_menu_names[ $nav_menu_name ] ) && $seen_menu_names[ $nav_menu_name ] > 1 ) {
     531        $count         = $seen_menu_names[ $nav_menu_name ];
     532        $nav_menu_name = $nav_menu_name . ' ' . ( $count );
     533    }
     534
    509535    $wrapper_attributes = get_block_wrapper_attributes(
    510536        array(
    511             'class' => implode( ' ', $classes ),
    512             'style' => $block_styles . $colors['inline_styles'] . $font_sizes['inline_styles'],
     537            'class'      => implode( ' ', $classes ),
     538            'style'      => $block_styles . $colors['inline_styles'] . $font_sizes['inline_styles'],
     539            'aria-label' => $nav_menu_name,
    513540        )
    514541    );
    515542
    516     $modal_unique_id = uniqid();
     543    $modal_unique_id = wp_unique_id( 'modal-' );
    517544
    518545    // Determine whether or not navigation elements should be wrapped in the markup required to make it responsive,
     
    538565    );
    539566
     567    $toggle_button_icon        = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg>';
     568    $should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon'];
     569    $toggle_button_content     = $should_display_icon_label ? $toggle_button_icon : 'Menu';
     570
    540571    $responsive_container_markup = sprintf(
    541         '<button aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="modal-%1$s"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg></button>
    542             <div class="%5$s" style="%7$s" id="modal-%1$s">
     572        '<button aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="%1$s">%9$s</button>
     573            <div class="%5$s" style="%7$s" id="%1$s">
    543574                <div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
    544575                    <div class="wp-block-navigation__responsive-dialog" aria-label="%8$s">
    545                             <button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
    546                         <div class="wp-block-navigation__responsive-container-content" id="modal-%1$s-content">
     576                            <button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
     577                        <div class="wp-block-navigation__responsive-container-content" id="%1$s-content">
    547578                            %2$s
    548579                        </div>
     
    550581                </div>
    551582            </div>',
    552         $modal_unique_id,
     583        esc_attr( $modal_unique_id ),
    553584        $inner_blocks_html,
    554585        __( 'Open menu' ), // Open button label.
    555586        __( 'Close menu' ), // Close button label.
    556         implode( ' ', $responsive_container_classes ),
    557         implode( ' ', $open_button_classes ),
    558         $colors['overlay_inline_styles'],
    559         __( 'Menu' )
     587        esc_attr( implode( ' ', $responsive_container_classes ) ),
     588        esc_attr( implode( ' ', $open_button_classes ) ),
     589        safecss_filter_attr( $colors['overlay_inline_styles'] ),
     590        __( 'Menu' ),
     591        $toggle_button_content
    560592    );
    561593
     
    570602 * Register the navigation block.
    571603 *
     604 * @uses render_block_core_navigation()
    572605 * @throws WP_Error An WP_Error exception parsing the block definition.
    573  * @uses render_block_core_navigation()
    574606 */
    575607function register_block_core_navigation() {
Note: See TracChangeset for help on using the changeset viewer.