Make WordPress Core

Changeset 32265


Ignore:
Timestamp:
04/22/2015 04:15:01 PM (11 years ago)
Author:
ocean90
Message:

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.

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/customize-controls.css

    r32103 r32265  
    10901090                display: block;
    10911091        }
     1092
     1093        .wp-customizer .theme-browser .theme.active .theme-name span {
     1094                display: inline;
     1095        }
    10921096}
    10931097
  • trunk/src/wp-admin/css/themes.css

    r32128 r32265  
    260260}
    261261
     262.theme-browser .customize-control .theme.active .theme-name {
     263        padding-right: 15px;
     264}
     265
    262266.theme-browser .theme.active .theme-name span {
    263267        font-weight: 600;
  • trunk/src/wp-includes/class-wp-customize-control.php

    r32134 r32265  
    12441244        public function content_template() {
    12451245                $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
     1246                $active_url  = esc_url( remove_query_arg( 'theme', $current_url ) );
    12461247                $preview_url = esc_url( add_query_arg( 'theme', '__THEME__', $current_url ) ); // Token because esc_url() strips curly braces.
    12471248                $preview_url = str_replace( '__THEME__', '{{ data.theme.id }}', $preview_url );
    12481249                ?>
    1249                 <div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
     1250                <# if ( data.theme.isActiveTheme ) { #>
     1251                        <div class="theme active" tabindex="0" data-preview-url="<?php echo esc_attr( $active_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
     1252                <# } else { #>
     1253                        <div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
     1254                <# } #>
     1255
    12501256                        <# if ( data.theme.screenshot[0] ) { #>
    12511257                                <div class="theme-screenshot">
     
    12551261                                <div class="theme-screenshot blank"></div>
    12561262                        <# } #>
    1257                         <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Live Preview' ); ?></span>
     1263
     1264                        <# if ( data.theme.isActiveTheme ) { #>
     1265                                <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Customize' ); ?></span>
     1266                        <# } else { #>
     1267                                <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Live Preview' ); ?></span>
     1268                        <# } #>
     1269
    12581270                        <div class="theme-author"><?php printf( __( 'By %s' ), '{{ data.theme.author }}' ); ?></div>
    12591271
    1260                         <h3 class="theme-name" id="{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
    1261 
    1262                         <div class="theme-actions">
    1263                                 <button type="button" class="button theme-details"><?php _e( 'Theme Details' ); ?></button>
    1264                         </div>
     1272                        <# if ( data.theme.isActiveTheme ) { #>
     1273                                <h3 class="theme-name" id="{{ data.theme.id }}-name">
     1274                                        <?php
     1275                                        /* translators: %s: theme name */
     1276                                        printf( __( '<span>Active:</span> %s' ), '{{ data.theme.name }}' );
     1277                                        ?>
     1278                                </h3>
     1279                        <# } else { #>
     1280                                <h3 class="theme-name" id="{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
     1281                                <div class="theme-actions">
     1282                                        <button type="button" class="button theme-details"><?php _e( 'Theme Details' ); ?></button>
     1283                                </div>
     1284                        <# } #>
    12651285                </div>
    12661286        <?php
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r32054 r32265  
    11991199
    12001200                // Theme Controls.
     1201
     1202                // Add a control for the active/original theme.
     1203                if ( ! $this->is_theme_active() ) {
     1204                        $themes = wp_prepare_themes_for_js( array( wp_get_theme( $this->original_stylesheet ) ) );
     1205                        $active_theme = current( $themes );
     1206                        $active_theme['isActiveTheme'] = true;
     1207                        $this->add_control( new WP_Customize_Theme_Control( $this, $active_theme['id'], array(
     1208                                'theme'    => $active_theme,
     1209                                'section'  => 'themes',
     1210                                'settings' => 'active_theme',
     1211                        ) ) );
     1212                }
     1213
    12011214                $themes = wp_prepare_themes_for_js();
    12021215                foreach ( $themes as $theme ) {
    1203                         if ( $theme['active'] ) {
     1216                        if ( $theme['active'] || $theme['id'] === $this->original_stylesheet ) {
    12041217                                continue;
    12051218                        }
    12061219
    12071220                        $theme_id = 'theme_' . $theme['id'];
     1221                        $theme['isActiveTheme'] = false;
    12081222                        $this->add_control( new WP_Customize_Theme_Control( $this, $theme_id, array(
    12091223                                'theme'    => $theme,
Note: See TracChangeset for help on using the changeset viewer.