Make WordPress Core


Ignore:
Timestamp:
02/07/2023 07:01:56 AM (3 years ago)
Author:
youknowriad
Message:

Block Editor: Updated the WordPress packages to include Gutenberg 15.1.0 changes.

In addition to all the packages being updated to the latest versions,
this commit also includes some mandatory changes to avoid editor breakage:

  • Update React to to 18.2.0.
  • Add the right stylesheets to support iframed block editors.

Props ntsekouras, mamaduka, flixos90, desrosj, peterwilsoncc.
See #57471.

File:
1 edited

Legend:

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

    r54486 r55246  
    140140 * @param boolean $is_navigation_child If block is a child of Navigation block.
    141141 * @param array   $nested_pages The array of nested pages.
     142 * @param boolean $is_nested Whether the submenu is nested or not.
    142143 * @param array   $active_page_ancestor_ids An array of ancestor ids for active page.
    143144 * @param array   $colors Color information for overlay styles.
     
    146147 * @return string List markup.
    147148 */
    148 function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids = array(), $colors = array(), $depth = 0 ) {
     149function block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $is_nested, $active_page_ancestor_ids = array(), $colors = array(), $depth = 0 ) {
    149150    if ( empty( $nested_pages ) ) {
    150151        return;
     
    174175
    175176        // If this is the first level of submenus, include the overlay colors.
    176         if ( 1 === $depth && isset( $colors['overlay_css_classes'], $colors['overlay_inline_styles'] ) ) {
     177        if ( ( ( 0 < $depth && ! $is_nested ) || $is_nested ) && isset( $colors['overlay_css_classes'], $colors['overlay_inline_styles'] ) ) {
    177178            $css_class .= ' ' . trim( implode( ' ', $colors['overlay_css_classes'] ) );
    178179            if ( '' !== $colors['overlay_inline_styles'] ) {
     
    197198        if ( isset( $page['children'] ) && $is_navigation_child && $open_submenus_on_click ) {
    198199            $markup .= '<button aria-label="' . esc_attr( $aria_label ) . '" class="' . esc_attr( $navigation_child_content_class ) . ' wp-block-navigation-submenu__toggle" aria-expanded="false">' . esc_html( $title ) .
    199             '</button>' . '<span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><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></span>';
     200            '</button><span class="wp-block-page-list__submenu-icon wp-block-navigation__submenu-icon"><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></span>';
    200201        } else {
    201202            $markup .= '<a class="wp-block-pages-list__item__link' . esc_attr( $navigation_child_content_class ) . '" href="' . esc_url( $page['link'] ) . '"' . $aria_current . '>' . $title . '</a>';
     
    208209                $markup .= '</button>';
    209210            }
    210             $markup .= '<ul class="submenu-container';
    211             // Extra classname is added when the block is a child of Navigation.
    212             if ( $is_navigation_child ) {
    213                 $markup .= ' wp-block-navigation__submenu-container';
    214             }
    215             $markup .= '">' . block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $active_page_ancestor_ids, $colors, $depth + 1 ) . '</ul>';
     211            $markup .= '<ul class="wp-block-navigation__submenu-container">';
     212            $markup .= block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $page['children'], $is_nested, $active_page_ancestor_ids, $colors, $depth + 1 );
     213            $markup .= '</ul>';
    216214        }
    217215        $markup .= '</li>';
     
    251249function render_block_core_page_list( $attributes, $content, $block ) {
    252250    static $block_id = 0;
    253     $block_id++;
     251    ++$block_id;
     252
     253    $parent_page_id = $attributes['parentPageID'];
     254    $is_nested      = $attributes['isNested'];
    254255
    255256    $all_pages = get_pages(
     
    272273
    273274    foreach ( (array) $all_pages as $page ) {
    274         $is_active = ! empty( $page->ID ) && ( get_the_ID() === $page->ID );
     275        $is_active = ! empty( $page->ID ) && ( get_queried_object_id() === $page->ID );
    275276
    276277        if ( $is_active ) {
     
    307308    $nested_pages = block_core_page_list_nest_pages( $top_level_pages, $pages_with_children );
    308309
     310    if ( 0 !== $parent_page_id ) {
     311        // If the parent page has no child pages, there is nothing to show.
     312        if ( ! array_key_exists( $parent_page_id, $pages_with_children ) ) {
     313            return;
     314        }
     315
     316        $nested_pages = block_core_page_list_nest_pages(
     317            $pages_with_children[ $parent_page_id ],
     318            $pages_with_children
     319        );
     320    }
     321
    309322    $is_navigation_child = array_key_exists( 'showSubmenuIcon', $block->context );
    310323
     
    313326    $show_submenu_icons = array_key_exists( 'showSubmenuIcon', $block->context ) ? $block->context['showSubmenuIcon'] : false;
    314327
    315     $wrapper_markup = '<ul %1$s>%2$s</ul>';
    316 
    317     $items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $active_page_ancestor_ids, $colors );
     328    $wrapper_markup = $is_nested ? '%2$s' : '<ul %1$s>%2$s</ul>';
     329
     330    $items_markup = block_core_page_list_render_nested_page_list( $open_submenus_on_click, $show_submenu_icons, $is_navigation_child, $nested_pages, $is_nested, $active_page_ancestor_ids, $colors );
    318331
    319332    $wrapper_attributes = get_block_wrapper_attributes(
Note: See TracChangeset for help on using the changeset viewer.