From 442a9c7dbbcda5185cd19296a78fd8667d65ff77 Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Tue, 1 Jun 2021 09:23:47 +1000 Subject: [PATCH 01/25] Link to widgets.php instead of themes.php?page=gutenberg-widgets (#32299) --- lib/init.php | 16 +++++++++++++--- .../src/legacy-widget/edit/preview.js | 3 +-- .../src/components/sidebar/widget-areas.js | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/init.php b/lib/init.php index e22542766f87ed..f721b8f773f441 100644 --- a/lib/init.php +++ b/lib/init.php @@ -30,7 +30,10 @@ function gutenberg_menu() { 'gutenberg' ); - if ( gutenberg_use_widgets_block_editor() ) { + if ( + gutenberg_use_widgets_block_editor() && + ! function_exists( 'wp_use_widgets_block_editor' ) + ) { add_theme_page( __( 'Widgets', 'gutenberg' ), __( 'Widgets', 'gutenberg' ), @@ -113,7 +116,11 @@ function gutenberg_site_editor_menu() { * @param WP_Admin_Bar $wp_admin_bar Core class used to implement the Toolbar API. */ function modify_admin_bar( $wp_admin_bar ) { - if ( gutenberg_use_widgets_block_editor() && $wp_admin_bar->get_node( 'widgets' ) !== null ) { + if ( + gutenberg_use_widgets_block_editor() && + ! function_exists( 'wp_use_widgets_block_editor' ) && + $wp_admin_bar->get_node( 'widgets' ) !== null + ) { $wp_admin_bar->add_menu( array( 'id' => 'widgets', @@ -137,7 +144,10 @@ function modify_welcome_panel() { ob_start(); wp_welcome_panel(); $welcome_panel = ob_get_clean(); - if ( gutenberg_use_widgets_block_editor() ) { + if ( + gutenberg_use_widgets_block_editor() && + ! function_exists( 'wp_use_widgets_block_editor' ) + ) { echo str_replace( admin_url( 'widgets.php' ), admin_url( 'themes.php?page=gutenberg-widgets' ), diff --git a/packages/block-library/src/legacy-widget/edit/preview.js b/packages/block-library/src/legacy-widget/edit/preview.js index 639d7a6d0874e2..39e4d65a51cb45 100644 --- a/packages/block-library/src/legacy-widget/edit/preview.js +++ b/packages/block-library/src/legacy-widget/edit/preview.js @@ -78,8 +78,7 @@ export default function Preview( { idBase, instance, isVisible } ) { // TODO: This chokes when the query param is too big. // Ideally, we'd render a . Maybe by // rendering one in an iframe via a portal. - src={ addQueryArgs( 'themes.php', { - page: 'gutenberg-widgets', + src={ addQueryArgs( 'widgets.php', { 'legacy-widget-preview': { idBase, instance, diff --git a/packages/edit-widgets/src/components/sidebar/widget-areas.js b/packages/edit-widgets/src/components/sidebar/widget-areas.js index 120f0bdb132ec2..42ebf5e652f9e7 100644 --- a/packages/edit-widgets/src/components/sidebar/widget-areas.js +++ b/packages/edit-widgets/src/components/sidebar/widget-areas.js @@ -59,7 +59,7 @@ export default function WidgetAreas( { selectedWidgetAreaId } ) {