Make WordPress Core


Ignore:
Timestamp:
02/07/2023 07:01:56 AM (23 months 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/navigation-submenu.php

    r54486 r55246  
    156156    $css_classes = trim( implode( ' ', $classes ) );
    157157    $has_submenu = count( $block->inner_blocks ) > 0;
    158     $is_active   = ! empty( $attributes['id'] ) && ( get_the_ID() === (int) $attributes['id'] );
     158    $is_active   = ! empty( $attributes['id'] ) && ( get_queried_object_id() === (int) $attributes['id'] );
    159159
    160160    $show_submenu_indicators = isset( $block->context['showSubmenuIcon'] ) && $block->context['showSubmenuIcon'];
     
    256256        }
    257257
     258        if ( strpos( $inner_blocks_html, 'current-menu-item' ) ) {
     259            $tag_processor = new WP_HTML_Tag_Processor( $html );
     260            while ( $tag_processor->next_tag( array( 'class_name' => 'wp-block-navigation-item__content' ) ) ) {
     261                $tag_processor->add_class( 'current-menu-ancestor' );
     262            }
     263            $html = $tag_processor->get_updated_html();
     264        }
     265
    258266        $html .= sprintf(
    259267            '<ul class="wp-block-navigation__submenu-container">%s</ul>',
     
    282290}
    283291add_action( 'init', 'register_block_core_navigation_submenu' );
     292
     293/**
     294 * Enables animation of the block inspector for the Navigation Submenu block.
     295 *
     296 * See:
     297 * - https://github.com/WordPress/gutenberg/pull/46342
     298 * - https://github.com/WordPress/gutenberg/issues/45884
     299 *
     300 * @param array $settings Default editor settings.
     301 * @return array Filtered editor settings.
     302 */
     303function block_core_navigation_submenu_enable_inspector_animation( $settings ) {
     304    $current_animation_settings = _wp_array_get(
     305        $settings,
     306        array( '__experimentalBlockInspectorAnimation' ),
     307        array()
     308    );
     309
     310    $settings['__experimentalBlockInspectorAnimation'] = array_merge(
     311        $current_animation_settings,
     312        array(
     313            'core/navigation-submenu' =>
     314                array(
     315                    'enterDirection' => 'rightToLeft',
     316                ),
     317        )
     318    );
     319
     320    return $settings;
     321}
     322
     323add_filter( 'block_editor_settings_all', 'block_core_navigation_submenu_enable_inspector_animation' );
Note: See TracChangeset for help on using the changeset viewer.