WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/19/2016 03:19:13 AM (3 years ago)
Author:
westonruter
Message:

Customize: Introduce a new experience for discovering, installing, and previewing themes within the customizer.

Unify the theme-browsing and theme-customization experiences by introducing a comprehensive theme browser and installer directly accessible in the customizer. Replaces the customizer theme switcher with a full-screen panel for discovering/browsing and installing themes available on WordPress.org. Themes can now be installed and previewed directly in the customizer without entering the wp-admin context.

For details, see https://make.wordpress.org/core/2016/10/03/feature-proposal-a-new-experience-for-discovering-installing-and-previewing-themes-in-the-customizer/

Fixes #37661, #34843.
Props celloexpressions, folletto, westonruter, karmatosed, afercia.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/customize/class-wp-customize-theme-control.php

    r38810 r38813  
    6363     */
    6464    public function content_template() {
    65         $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
    66         $active_url  = esc_url( remove_query_arg( 'customize_theme', $current_url ) );
    67         $preview_url = esc_url( add_query_arg( 'customize_theme', '__THEME__', $current_url ) ); // Token because esc_url() strips curly braces.
    68         $preview_url = str_replace( '__THEME__', '{{ data.theme.id }}', $preview_url );
     65        /* translators: %s: theme name */
     66        $details_label = sprintf( __( 'Details for theme: %s' ), '{{ data.theme.name }}' );
     67        /* translators: %s: theme name */
     68        $customize_label = sprintf( __( 'Customize theme: %s' ), '{{ data.theme.name }}' );
     69        /* translators: %s: theme name */
     70        $preview_label = sprintf( __( 'Live preview theme: %s' ), '{{ data.theme.name }}' );
     71        /* translators: %s: theme name */
     72        $install_label = sprintf( __( 'Install and preview theme: %s' ), '{{ data.theme.name }}' );
    6973        ?>
    70         <# if ( data.theme.isActiveTheme ) { #>
    71             <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">
     74        <# if ( data.theme.active ) { #>
     75            <div class="theme active" tabindex="0" aria-describedby="{{ data.section }}-{{ data.theme.id }}-action {{ data.theme.id }}-name">
    7276        <# } else { #>
    73             <div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name">
     77            <div class="theme" tabindex="0" aria-describedby="{{ data.section }}-{{ data.theme.id }}-action {{ data.theme.id }}-name">
    7478        <# } #>
    7579
    76             <# if ( data.theme.screenshot[0] ) { #>
     80            <# if ( data.theme.screenshot && data.theme.screenshot[0] ) { #>
    7781                <div class="theme-screenshot">
    7882                    <img data-src="{{ data.theme.screenshot[0] }}" alt="" />
     
    8286            <# } #>
    8387
    84             <# if ( data.theme.isActiveTheme ) { #>
    85                 <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Customize' ); ?></span>
    86             <# } else { #>
    87                 <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Live Preview' ); ?></span>
     88            <span class="more-details theme-details" id="{{ data.section }}-{{ data.theme.id }}-action" aria-label="<?php echo esc_attr( $details_label ); ?>"><?php _e( 'Theme Details' ); ?></span>
     89
     90
     91            <# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #>
     92                <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}"><p><?php printf( __( 'New version available. %s' ), '<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>' ); ?></p></div>
    8893            <# } #>
    8994
    90             <div class="theme-author"><?php printf( __( 'By %s' ), '{{ data.theme.author }}' ); ?></div>
    91 
    92             <# if ( data.theme.isActiveTheme ) { #>
    93                 <h3 class="theme-name" id="{{ data.theme.id }}-name">
     95            <# if ( data.theme.active ) { #>
     96                <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">
    9497                    <?php
    9598                    /* translators: %s: theme name */
    96                     printf( __( '<span>Active:</span> %s' ), '{{{ data.theme.name }}}' );
     99                    printf( __( '<span>Current:</span> %s' ), '{{ data.theme.name }}' );
    97100                    ?>
    98101                </h3>
     102                <div class="theme-actions">
     103                    <button type="button" class="button button-primary customize-theme" aria-label="<?php echo esc_attr( $customize_label ); ?>"><?php _e( 'Customize' ); ?></button>
     104                </div>
     105                <div class="notice notice-success notice-alt"><p><?php _e( 'Installed' ); ?></p></div>
     106            <# } else if ( 'installed' === data.theme.type ) { #>
     107                <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
     108                <div class="theme-actions">
     109                    <button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-theme-id="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></span>
     110                </div>
     111                <div class="notice notice-success notice-alt"><p><?php _e( 'Installed' ); ?></p></div>
    99112            <# } else { #>
    100                 <h3 class="theme-name" id="{{ data.theme.id }}-name">{{{ data.theme.name }}}</h3>
     113                <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
    101114                <div class="theme-actions">
    102                     <button type="button" class="button theme-details"><?php _e( 'Theme Details' ); ?></button>
     115                    <button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}" data-theme-id="{{ data.theme.id }}"><?php _e( 'Install & Preview' ); ?></button>
    103116                </div>
    104117            <# } #>
Note: See TracChangeset for help on using the changeset viewer.