From 74bb197a4aed0ef937e26b25e88b471dac44ecf6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 13 Jan 2015 07:44:57 +0000 Subject: [PATCH] Customizer: Use deep-link for Widgets in toolbar on front-end. props caseypatrickdriscoll. fixes #30971. git-svn-id: https://develop.svn.wordpress.org/trunk@31176 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/admin-bar.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 2849d43f92..49279a9926 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -678,8 +678,29 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) { add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); } - if ( current_theme_supports( 'widgets' ) ) - $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __('Widgets'), 'href' => admin_url('widgets.php') ) ); + if ( current_theme_supports( 'widgets' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'widgets', + 'title' => __( 'Widgets' ), + 'href' => admin_url( 'widgets.php' ), + 'meta' => array( + 'class' => 'hide-if-customize', + ), + ) ); + + if ( current_user_can( 'customize' ) ) { + $wp_admin_bar->add_menu( array( + 'parent' => 'appearance', + 'id' => 'customize-widgets', + 'title' => __( 'Widgets' ), + 'href' => add_query_arg( urlencode( 'autofocus[panel]' ), 'widgets', $customize_url ), // urlencode() needed due to #16859 + 'meta' => array( + 'class' => 'hide-if-no-customize', + ), + ) ); + } + } if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) );