Make WordPress Core


Ignore:
Timestamp:
03/11/2014 07:46:27 AM (12 years ago)
Author:
nacin
Message:

Bring the theme browsing experience from 3.8 to the theme installer. First pass.

props matveb with assists from me and gcorne.
see #27055.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/theme-install.php

    r27469 r27499  
    77 */
    88
    9 if ( !defined( 'IFRAME_REQUEST' ) && isset( $_GET['tab'] ) && ( 'theme-information' == $_GET['tab'] ) )
    10         define( 'IFRAME_REQUEST', true );
    11 
    129/** WordPress Administration Bootstrap */
    1310require_once( dirname( __FILE__ ) . '/admin.php' );
     11require( ABSPATH . 'wp-admin/includes/theme-install.php' );
     12
     13wp_reset_vars( array( 'tab' ) );
    1414
    1515if ( ! current_user_can('install_themes') )
     
    2121}
    2222
    23 $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
    24 $pagenum = $wp_list_table->get_pagenum();
    25 $wp_list_table->prepare_items();
    26 
    27 $title = __('Install Themes');
     23$title = __( 'Add Themes' );
    2824$parent_file = 'themes.php';
    29 if ( !is_network_admin() )
     25
     26if ( ! is_network_admin() ) {
    3027        $submenu_file = 'themes.php';
    31 
    32 wp_enqueue_script( 'theme-install' );
    33 wp_enqueue_script( 'theme-preview' );
    34 
    35 $body_id = $tab;
     28}
     29
     30$sections = array(
     31        'featured' => __( 'Featured Themes' ),
     32        'popular'  => __( 'Popular Themes' ),
     33        'new'      => __( 'Newest Themes' ),
     34);
     35
     36wp_localize_script( 'theme', '_wpThemeSettings', array(
     37        'themes'   => false,
     38        'settings' => array(
     39                'isInstall'     => true,
     40                'canInstall'    => current_user_can( 'install_themes' ),
     41                'installURI'    => current_user_can( 'install_themes' ) ? self_admin_url( 'theme-install.php' ) : null,
     42                'adminUrl'      => parse_url( self_admin_url(), PHP_URL_PATH ),
     43                'updateURI'     => self_admin_url( 'update.php' ),
     44                '_nonceInstall' => wp_create_nonce( 'install-theme' )
     45        ),
     46        'l10n' => array(
     47                'addNew' => __( 'Add New Theme' ),
     48                'search'  => __( 'Search Themes' ),
     49                'searchPlaceholder' => __( 'Search themes...' ),
     50                'upload' => __( 'Upload Theme' ),
     51                'back'   => __( 'Back' ),
     52                'error'  => __( 'There was a problem trying to load the themes. Please, try again.' ),
     53        ),
     54        'browse' => array(
     55                'sections' => $sections,
     56        ),
     57) );
     58
     59wp_enqueue_script( 'theme' );
    3660
    3761/**
     
    4468 * @since 2.8.0
    4569 */
    46 do_action( "install_themes_pre_{$tab}" );
     70if ( $tab ) {
     71        do_action( "install_themes_pre_{$tab}" );
     72}
    4773
    4874$help_overview =
     
    74100
    75101include(ABSPATH . 'wp-admin/admin-header.php');
     102
    76103?>
    77104<div class="wrap">
    78 <h2><?php echo esc_html( $title ); ?></h2>
    79 <?php
    80 
    81 $wp_list_table->views(); ?>
    82 
    83 <br class="clear" />
     105        <h2>
     106                <?php echo esc_html( $title ); ?>
     107                <a class="upload button button-secondary"><?php esc_html_e( 'Upload Theme' ); ?></a>
     108        </h2>
     109
     110        <div class="upload-theme">
     111        <?php install_themes_upload(); ?>
     112        </div>
     113
     114        <div class="theme-navigation">
     115                <span class="theme-count"></span>
     116                <span class="theme-section current" data-sort="featured"><?php esc_html_e( 'Featured' ); ?></span>
     117                <span class="theme-section" data-sort="popular"><?php esc_html_e( 'Popular' ); ?></span>
     118                <span class="theme-section" data-sort="new"><?php esc_html_e( 'Latest' ); ?></span>
     119                <div class="theme-top-filters">
     120                        <span class="theme-filter" data-filter="photoblogging">Photography</span>
     121                        <span class="theme-filter" data-filter="responsive-layout">Responsive</span>
     122                        <span class="theme-filter more-filters">More</span>
     123                </div>
     124                <div class="more-filters-container">
     125                        Display more filters.
     126                </div>
     127        </div>
     128        <div class="theme-browser"></div>
     129        <div class="theme-overlay"></div>
     130        <div id="theme-installer" class="wp-full-overlay expanded"></div>
     131
     132        <span class="spinner"></span>
     133
     134        <br class="clear" />
    84135<?php
    85136/**
     
    94145 * @param int $paged Number of the current page of results being viewed.
    95146 */
    96 do_action( "install_themes_{$tab}", $paged );
     147if ( $tab ) {
     148        do_action( "install_themes_{$tab}", $paged );
     149}
    97150?>
    98151</div>
     152
     153<script id="tmpl-theme" type="text/template">
     154        <# if ( data.screenshot_url ) { #>
     155                <div class="theme-screenshot">
     156                        <img src="{{ data.screenshot_url }}" alt="" />
     157                </div>
     158        <# } else { #>
     159                <div class="theme-screenshot blank"></div>
     160        <# } #>
     161        <span class="more-details"><?php _ex( 'Details &amp; Preview', 'theme' ); ?></span>
     162        <div class="theme-author"><?php printf( __( 'By %s' ), '{{ data.author }}' ); ?></div>
     163        <h3 class="theme-name">{{ data.name }}</h3>
     164
     165        <div class="theme-actions">
     166                <a class="button button-primary" href="{{ data.installURI }}"><?php esc_html_e( 'Install' ); ?></a>
     167                <a class="button button-secondary preview install-theme-preview" href="#"><?php esc_html_e( 'Preview' ); ?></a>
     168        </div>
     169</script>
     170
     171<script id="tmpl-theme-preview" type="text/template">
     172        <div class="wp-full-overlay-sidebar">
     173                <div class="wp-full-overlay-header">
     174                        <a href="" class="close-full-overlay button-secondary"><?php _e( 'Close' ); ?></a>
     175                        <a href="{{ data.installURI }}" class="button button-primary theme-install"><?php _e( 'Install' ); ?></a>
     176                </div>
     177                <div class="wp-full-overlay-sidebar-content">
     178                        <div class="install-theme-info">
     179                                <h3 class="theme-name">{{ data.name }}</h3>
     180                                <span class="theme-by"><?php printf( __( 'By %s' ), '{{ data.author }}' ); ?></span>
     181
     182                                <img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" />
     183
     184                                <div class="theme-details">
     185                                        <div class="rating rating-{{ Math.round( data.rating / 10 ) * 10 }}">
     186                                                <span class="one"></span>
     187                                                <span class="two"></span>
     188                                                <span class="three"></span>
     189                                                <span class="four"></span>
     190                                                <span class="five"></span>
     191                                                <p class="votes"><?php printf( __( 'Based on %s ratings.' ), '{{ data.num_ratings }}' ); ?></p>
     192                                        </div>
     193                                        <div class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></div>
     194                                        <div class="theme-description">{{ data.description }}</div>
     195                                </div>
     196                        </div>
     197                </div>
     198                <div class="wp-full-overlay-footer">
     199                        <a href="" class="collapse-sidebar" title="<?php esc_attr_e( 'Collapse Sidebar' ); ?>">
     200                                <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span>
     201                                <span class="collapse-sidebar-arrow"></span>
     202                        </a>
     203                </div>
     204        </div>
     205        <div class="wp-full-overlay-main">
     206                <iframe src="{{ data.preview_url }}" />
     207        </div>
     208</script>
     209
    99210<?php
    100211include(ABSPATH . 'wp-admin/admin-footer.php');
Note: See TracChangeset for help on using the changeset viewer.