Make WordPress Core

Changeset 20352


Ignore:
Timestamp:
04/04/2012 09:02:29 PM (14 years ago)
Author:
koopersmith
Message:

Theme Customizer: Improve the customize loader and themes list table markup. see #19910.

  • Use event delegation for triggering the customize loader (so we play nicely with infinite scroll).
  • Use data attributes on .load-customize links instead of parsing the href.
  • Properly translate the 'Customize' string instead of injecting the replacement with JS.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-themes-list-table.php

    r20104 r20352  
    132132                                home_url( '/' ) ) );
    133133
     134                        $customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize “%s”' ), $title ) ) . '"
     135                                . data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';
     136
    134137                        $actions = array();
    135138                        $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="'
    136139                                . esc_attr( sprintf( __( 'Activate &#8220;%s&#8221;' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
    137                         $actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="'
    138                                 . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '">' . __( 'Preview' ) . '</a>';
     140                        $actions[] = '<a href="' . $preview_link . '" class="hide-if-js" title="'
     141                                . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '">' . __( 'Preview' ) . '</a>'
     142                                . '<a href="#" class="load-customize hide-if-no-js" ' . $customize_attributes . '>' . __( 'Customize' ) . '</a>';
    139143                        if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
    140144                                $actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&amp;template=$stylesheet", 'delete-theme_' . $stylesheet )
     
    146150                        $actions = implode ( ' | ', $actions );
    147151                        ?>
    148                         <a href="<?php echo $preview_link; ?>" class="thickbox thickbox-preview screenshot">
     152                        <a href="<?php echo $preview_link; ?>" class="load-customize screenshot" <?php echo $customize_attributes; ?>>
    149153                        <?php if ( $screenshot = $theme->get_screenshot() ) : ?>
    150154                                <img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
  • trunk/wp-includes/js/customize-loader.dev.js

    r20250 r20352  
    4242                Loader.initialize();
    4343
    44                 // Override 'preview' links on themes page.
    45                 $('.thickbox-preview').click( function( event ) {
    46                         var href, template, stylesheet;
     44                $('#current-theme, #availablethemes').on( 'click', '.load-customize', function( event ) {
     45                        var load = $(this);
    4746
    48                         // Stop the thickbox.
    4947                        event.preventDefault();
    50                         event.stopImmediatePropagation();
    51 
    52                         // Extract the template/stylesheet from the preview link's url.
    53                         href = $(this).attr('href');
    54                         template = href.match('template=([^&]*)')[1];
    55                         stylesheet = href.match('stylesheet=([^&]*)')[1];
    5648
    5749                        // Load the theme.
    5850                        Loader.open({
    59                                 template: template,
    60                                 stylesheet: stylesheet
     51                                template:   load.data('customizeTemplate'),
     52                                stylesheet: load.data('customizeStylesheet')
    6153                        });
    62                 }).filter( function() {
    63                         return 'Preview' == $(this).text();
    64                 }).text('Customize');
     54                });
    6555        });
    6656
Note: See TracChangeset for help on using the changeset viewer.