@@ -662,13 +662,14 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
662662 if ( ! current_user_can ( 'edit_theme_options ' ) )
663663 return ;
664664
665+ $ current_url = ( is_ssl () ? 'https:// ' : 'http:// ' ) . $ _SERVER ['HTTP_HOST ' ] . $ _SERVER ['REQUEST_URI ' ];
666+ $ customize_url = add_query_arg ( 'url ' , urlencode ( $ current_url ), wp_customize_url () );
665667 if ( current_user_can ( 'customize ' ) ) {
666- $ current_url = ( is_ssl () ? 'https:// ' : 'http:// ' ) . $ _SERVER ['HTTP_HOST ' ] . $ _SERVER ['REQUEST_URI ' ];
667668 $ wp_admin_bar ->add_menu ( array (
668669 'parent ' => 'appearance ' ,
669670 'id ' => 'customize ' ,
670671 'title ' => __ ('Customize ' ),
671- 'href ' => add_query_arg ( ' url ' , urlencode ( $ current_url ), wp_customize_url () ) ,
672+ 'href ' => $ customize_url ,
672673 'meta ' => array (
673674 'class ' => 'hide-if-no-customize ' ,
674675 ),
@@ -682,11 +683,54 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
682683 if ( current_theme_supports ( 'menus ' ) || current_theme_supports ( 'widgets ' ) )
683684 $ wp_admin_bar ->add_menu ( array ( 'parent ' => 'appearance ' , 'id ' => 'menus ' , 'title ' => __ ('Menus ' ), 'href ' => admin_url ('nav-menus.php ' ) ) );
684685
685- if ( current_theme_supports ( 'custom-background ' ) )
686- $ wp_admin_bar ->add_menu ( array ( 'parent ' => 'appearance ' , 'id ' => 'background ' , 'title ' => __ ('Background ' ), 'href ' => admin_url ('themes.php?page=custom-background ' ) ) );
686+ if ( current_theme_supports ( 'custom-background ' ) ) {
687+ $ wp_admin_bar ->add_menu ( array (
688+ 'parent ' => 'appearance ' ,
689+ 'id ' => 'background ' ,
690+ 'title ' => __ ( 'Background ' ),
691+ 'href ' => admin_url ( 'themes.php?page=custom-background ' ),
692+ 'meta ' => array (
693+ 'class ' => 'hide-if-customize ' ,
694+ ),
695+ ) );
696+
697+ if ( current_user_can ( 'customize ' ) ) {
698+ $ wp_admin_bar ->add_menu ( array (
699+ 'parent ' => 'appearance ' ,
700+ 'id ' => 'customize-background ' ,
701+ 'title ' => __ ( 'Background ' ),
702+ 'href ' => add_query_arg ( urlencode ( 'autofocus[control] ' ), 'background_image ' , $ customize_url ), // urlencode() needed due to #16859
703+ 'meta ' => array (
704+ 'class ' => 'hide-if-no-customize ' ,
705+ ),
706+ ) );
707+ }
708+ }
709+
710+ if ( current_theme_supports ( 'custom-header ' ) ) {
711+ $ wp_admin_bar ->add_menu ( array (
712+ 'parent ' => 'appearance ' ,
713+ 'id ' => 'header ' ,
714+ 'title ' => __ ( 'Header ' ),
715+ 'href ' => admin_url ( 'themes.php?page=custom-header ' ),
716+ 'meta ' => array (
717+ 'class ' => 'hide-if-customize ' ,
718+ ),
719+ ) );
720+
721+ if ( current_user_can ( 'customize ' ) ) {
722+ $ wp_admin_bar ->add_menu ( array (
723+ 'parent ' => 'appearance ' ,
724+ 'id ' => 'customize-header ' ,
725+ 'title ' => __ ( 'Header ' ),
726+ 'href ' => add_query_arg ( urlencode ( 'autofocus[control] ' ), 'header_image ' , $ customize_url ), // urlencode() needed due to #16859
727+ 'meta ' => array (
728+ 'class ' => 'hide-if-no-customize ' ,
729+ ),
730+ ) );
731+ }
732+ }
687733
688- if ( current_theme_supports ( 'custom-header ' ) )
689- $ wp_admin_bar ->add_menu ( array ( 'parent ' => 'appearance ' , 'id ' => 'header ' , 'title ' => __ ('Header ' ), 'href ' => admin_url ('themes.php?page=custom-header ' ) ) );
690734}
691735
692736/**
0 commit comments