From f029572866cbd58695b2ae5bc30f63643ea85850 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Wed, 22 Apr 2015 16:15:01 +0000 Subject: [PATCH] Theme Switcher: Provide an easier way to reset back to the current active theme. * Add control for the active theme when doing a theme preview * Highlight an active theme and move it to the top props valendesigns, ocean90. fixes #32002. git-svn-id: https://develop.svn.wordpress.org/trunk@32265 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/customize-controls.css | 4 +++ src/wp-admin/css/themes.css | 4 +++ .../class-wp-customize-control.php | 34 +++++++++++++++---- .../class-wp-customize-manager.php | 16 ++++++++- 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index 35585e7ae1..c6417052bf 100644 --- a/src/wp-admin/css/customize-controls.css +++ b/src/wp-admin/css/customize-controls.css @@ -1089,6 +1089,10 @@ body.cheatin p { .wp-customizer .theme:not(.active):focus .theme-actions { display: block; } + + .wp-customizer .theme-browser .theme.active .theme-name span { + display: inline; + } } @media screen and ( max-width: 640px ) { diff --git a/src/wp-admin/css/themes.css b/src/wp-admin/css/themes.css index 79247adaca..18148849fc 100644 --- a/src/wp-admin/css/themes.css +++ b/src/wp-admin/css/themes.css @@ -259,6 +259,10 @@ box-shadow: inset 0 1px 1px rgba(0,0,0,0.5); } +.theme-browser .customize-control .theme.active .theme-name { + padding-right: 15px; +} + .theme-browser .theme.active .theme-name span { font-weight: 600; } diff --git a/src/wp-includes/class-wp-customize-control.php b/src/wp-includes/class-wp-customize-control.php index 4ac0befb89..bf17fb203f 100644 --- a/src/wp-includes/class-wp-customize-control.php +++ b/src/wp-includes/class-wp-customize-control.php @@ -1243,10 +1243,16 @@ class WP_Customize_Theme_Control extends WP_Customize_Control { */ public function content_template() { $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); + $active_url = esc_url( remove_query_arg( 'theme', $current_url ) ); $preview_url = esc_url( add_query_arg( 'theme', '__THEME__', $current_url ) ); // Token because esc_url() strips curly braces. $preview_url = str_replace( '__THEME__', '{{ data.theme.id }}', $preview_url ); ?> -
+ <# if ( data.theme.isActiveTheme ) { #> +
+ <# } else { #> +
+ <# } #> + <# if ( data.theme.screenshot[0] ) { #>
@@ -1254,14 +1260,28 @@ class WP_Customize_Theme_Control extends WP_Customize_Control { <# } else { #>
<# } #> - + + <# if ( data.theme.isActiveTheme ) { #> + + <# } else { #> + + <# } #> +
-

{{ data.theme.name }}

- -
- -
+ <# if ( data.theme.isActiveTheme ) { #> +

+ Active: %s' ), '{{ data.theme.name }}' ); + ?> +

+ <# } else { #> +

{{ data.theme.name }}

+
+ +
+ <# } #>
is_theme_active() ) { + $themes = wp_prepare_themes_for_js( array( wp_get_theme( $this->original_stylesheet ) ) ); + $active_theme = current( $themes ); + $active_theme['isActiveTheme'] = true; + $this->add_control( new WP_Customize_Theme_Control( $this, $active_theme['id'], array( + 'theme' => $active_theme, + 'section' => 'themes', + 'settings' => 'active_theme', + ) ) ); + } + $themes = wp_prepare_themes_for_js(); foreach ( $themes as $theme ) { - if ( $theme['active'] ) { + if ( $theme['active'] || $theme['id'] === $this->original_stylesheet ) { continue; } $theme_id = 'theme_' . $theme['id']; + $theme['isActiveTheme'] = false; $this->add_control( new WP_Customize_Theme_Control( $this, $theme_id, array( 'theme' => $theme, 'section' => 'themes',