Changeset 51051 for trunk/src/wp-includes/blocks/legacy-widget.php
- Timestamp:
- 06/01/2021 08:07:07 AM (5 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks/legacy-widget.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/legacy-widget.php
r50997 r51051 14 14 */ 15 15 function render_block_core_legacy_widget( $attributes ) { 16 global $wp_widget_factory; 17 16 18 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 ); 19 21 } 20 22 … … 23 25 } 24 26 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 } 26 32 27 33 if ( ! $widget_object ) { … … 45 51 46 52 /** 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. 48 59 */ 49 function register_block_core_legacy_widget() {60 function init_legacy_widget_block() { 50 61 register_block_type_from_metadata( 51 62 __DIR__ . '/legacy-widget', … … 54 65 ) 55 66 ); 56 }57 67 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, if62 * set, renders a page containing a preview of the requested Legacy Widget63 * block.64 */65 function handle_legacy_widget_preview_iframe() {66 68 if ( empty( $_GET['legacy-widget-preview'] ) ) { 67 69 return; … … 109 111 } 110 112 111 add_action( 'init', ' handle_legacy_widget_preview_iframe', 21);113 add_action( 'init', 'init_legacy_widget_block' );
Note: See TracChangeset
for help on using the changeset viewer.