Skip to content

Commit df884cb

Browse files
committed
Customizer: Use deep-links for Backgrounds, Headers, and Widgets.
Replace links in admin menu and toolbar to Custom Background/Header screen with deep-links to the Customizer section. On the Widgets screen display a link to the Customizer widgets panel. props topher1kenobe, rzen, celloexpressions, westonruter fixes #25569, #25571, #28032. git-svn-id: https://develop.svn.wordpress.org/trunk@30459 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 05facab commit df884cb

6 files changed

Lines changed: 106 additions & 8 deletions

File tree

src/wp-admin/css/admin-menu.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ li#wp-admin-bar-menu-toggle {
610610
display: none;
611611
}
612612

613+
/* Hide-if-customize for items we can't add classes to */
614+
.customize-support #menu-appearance a[href="themes.php?page=custom-header"],
615+
.customize-support #menu-appearance a[href="themes.php?page=custom-background"] {
616+
display: none;
617+
}
613618

614619
/* Auto-folding of the admin menu */
615620
@media only screen and (max-width: 960px) {

src/wp-admin/custom-background.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,19 @@ public function admin_page() {
238238
<div class="wrap" id="custom-background">
239239
<h2><?php _e( 'Custom Background' ); ?></h2>
240240

241+
<?php if ( current_user_can( 'customize' ) ) { ?>
242+
<div class="update-nag hide-if-no-customize">
243+
<p>
244+
<?php
245+
printf(
246+
__( 'You can now manage and live-preview Custom Backgrounds in the <a href="%1$s">Customizer</a>.' ),
247+
admin_url( 'customize.php?autofocus[control]=background_image' )
248+
);
249+
?>
250+
</p>
251+
</div>
252+
<?php } ?>
253+
241254
<?php if ( ! empty( $this->updated ) ) { ?>
242255
<div id="message" class="updated">
243256
<p><?php printf( __( 'Background updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p>

src/wp-admin/custom-header.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,19 @@ public function step_1() {
524524
<div class="wrap">
525525
<h2><?php _e( 'Custom Header' ); ?></h2>
526526

527+
<?php if ( current_user_can( 'customize' ) ) { ?>
528+
<div class="update-nag hide-if-no-customize">
529+
<p>
530+
<?php
531+
printf(
532+
__( 'You can now manage and live-preview Custom Header in the <a href="%1$s">Customizer</a>.' ),
533+
admin_url( 'customize.php?autofocus[control]=header_image' )
534+
);
535+
?>
536+
</p>
537+
</div>
538+
<?php } ?>
539+
527540
<?php if ( ! empty( $this->updated ) ) { ?>
528541
<div id="message" class="updated">
529542
<p><?php printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); ?></p>

src/wp-admin/menu.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,23 @@
152152

153153
$customize_url = add_query_arg( 'return', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'customize.php' );
154154
$submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', $customize_url, '', 'hide-if-no-customize' );
155-
unset( $customize_url );
155+
156156
if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) {
157157
$submenu['themes.php'][10] = array(__( 'Menus' ), 'edit_theme_options', 'nav-menus.php');
158158
}
159159

160+
if ( current_theme_supports( 'custom-header' ) && current_user_can( 'customize') ) {
161+
$customize_header_url = add_query_arg( 'autofocus[control]', 'header_image', $customize_url );
162+
$submenu['themes.php'][15] = array( __( 'Header' ), $appearance_cap, $customize_header_url, '', 'hide-if-no-customize' );
163+
}
164+
165+
if ( current_theme_supports( 'custom-background' ) && current_user_can( 'customize') ) {
166+
$customize_background_url = add_query_arg( 'autofocus[control]', 'background_image', $customize_url );
167+
$submenu['themes.php'][20] = array( __( 'Background' ), $appearance_cap, $customize_background_url, '', 'hide-if-no-customize' );
168+
}
169+
170+
unset( $customize_url );
171+
160172
unset( $appearance_cap );
161173

162174
// Add 'Editor' to the bottom of the Appearance menu.

src/wp-admin/widgets.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,18 @@ function wp_widgets_access_body_class($classes) {
310310
require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?>
311311

312312
<div class="wrap">
313-
<h2><?php echo esc_html( $title ); ?></h2>
313+
<h2>
314+
<?php
315+
echo esc_html( $title );
316+
if ( current_user_can( 'customize' ) ) {
317+
printf(
318+
' <a class="add-new-h2 hide-if-no-customize" href="%1$s">%2$s</a>',
319+
admin_url( 'customize.php?autofocus[panel]=widgets' ),
320+
__( 'Manage in Customizer' )
321+
);
322+
}
323+
?>
324+
</h2>
314325

315326
<?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?>
316327
<div id="message" class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div>

src/wp-includes/admin-bar.php

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)