get_widget_object( $attributes['idBase'] ); } else { $widget_object = gutenberg_get_widget_object( $attributes['idBase'] ); } if ( ! $widget_object ) { return ''; } if ( isset( $attributes['instance']['encoded'], $attributes['instance']['hash'] ) ) { $serialized_instance = base64_decode( $attributes['instance']['encoded'] ); if ( wp_hash( $serialized_instance ) !== $attributes['instance']['hash'] ) { return ''; } $instance = unserialize( $serialized_instance ); } else { $instance = array(); } ob_start(); the_widget( get_class( $widget_object ), $instance ); return ob_get_clean(); } /** * On application init this does two things: * * - Registers the 'core/legacy-widget' block. * - Intercepts any request with legacy-widget-preview in the query param and, * if set, renders a page containing a preview of the requested Legacy Widget * block. */ function init_legacy_widget_block() { register_block_type_from_metadata( __DIR__ . '/legacy-widget', array( 'render_callback' => 'render_block_core_legacy_widget', ) ); if ( empty( $_GET['legacy-widget-preview'] ) ) { return; } if ( ! current_user_can( 'edit_theme_options' ) ) { return; } define( 'IFRAME_REQUEST', true ); ?> >
>