Make WordPress Core


Ignore:
Timestamp:
06/01/2021 08:07:07 AM (5 years ago)
Author:
youknowriad
Message:

Block Editor: Update packages and backport the latest Gutenberg fixes.

This includes the following fixes:

Props nosolosw, noisysocks.
See #52991.

File:
1 edited

Legend:

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

    r50997 r51051  
    1414 */
    1515function render_block_core_legacy_widget( $attributes ) {
     16    global $wp_widget_factory;
     17
    1618    if ( isset( $attributes['id'] ) ) {
    17         $sidebar_id = gutenberg_find_widgets_sidebar( $attributes['id'] );
    18         return gutenberg_render_widget( $attributes['id'], $sidebar_id );
     19        $sidebar_id = wp_find_widgets_sidebar( $attributes['id'] );
     20        return wp_render_widget( $attributes['id'], $sidebar_id );
    1921    }
    2022
     
    2325    }
    2426
    25     $widget_object = gutenberg_get_widget_object( $attributes['idBase'] );
     27    if ( method_exists( $wp_widget_factory, 'get_widget_object' ) ) {
     28        $widget_object = $wp_widget_factory->get_widget_object( $attributes['idBase'] );
     29    } else {
     30        $widget_object = gutenberg_get_widget_object( $attributes['idBase'] );
     31    }
    2632
    2733    if ( ! $widget_object ) {
     
    4551
    4652/**
    47  * Registers the 'core/legacy-widget' block.
     53 * On application init this does two things:
     54 *
     55 * - Registers the 'core/legacy-widget' block.
     56 * - Intercepts any request with legacy-widget-preview in the query param and,
     57 *   if set, renders a page containing a preview of the requested Legacy Widget
     58 *   block.
    4859 */
    49 function register_block_core_legacy_widget() {
     60function init_legacy_widget_block() {
    5061    register_block_type_from_metadata(
    5162        __DIR__ . '/legacy-widget',
     
    5465        )
    5566    );
    56 }
    5767
    58 add_action( 'init', 'register_block_core_legacy_widget', 20 );
    59 
    60 /**
    61  * Intercepts any request with legacy-widget-preview in the query param and, if
    62  * set, renders a page containing a preview of the requested Legacy Widget
    63  * block.
    64  */
    65 function handle_legacy_widget_preview_iframe() {
    6668    if ( empty( $_GET['legacy-widget-preview'] ) ) {
    6769        return;
     
    109111}
    110112
    111 add_action( 'init', 'handle_legacy_widget_preview_iframe', 21 );
     113add_action( 'init', 'init_legacy_widget_block' );
Note: See TracChangeset for help on using the changeset viewer.