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. git-svn-id: https://develop.svn.wordpress.org/trunk@20352 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
dfab3319f8
commit
31caea7b9b
|
@ -131,11 +131,15 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||||
array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ),
|
array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ),
|
||||||
home_url( '/' ) ) );
|
home_url( '/' ) ) );
|
||||||
|
|
||||||
|
$customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize “%s”' ), $title ) ) . '"
|
||||||
|
. data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';
|
||||||
|
|
||||||
$actions = array();
|
$actions = array();
|
||||||
$actions[] = '<a href="' . $activate_link . '" class="activatelink" title="'
|
$actions[] = '<a href="' . $activate_link . '" class="activatelink" title="'
|
||||||
. esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
|
. esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
|
||||||
$actions[] = '<a href="' . $preview_link . '" class="thickbox thickbox-preview" title="'
|
$actions[] = '<a href="' . $preview_link . '" class="hide-if-js" title="'
|
||||||
. esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>';
|
. esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>'
|
||||||
|
. '<a href="#" class="load-customize hide-if-no-js" ' . $customize_attributes . '>' . __( 'Customize' ) . '</a>';
|
||||||
if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
|
if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
|
||||||
$actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&template=$stylesheet", 'delete-theme_' . $stylesheet )
|
$actions[] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&template=$stylesheet", 'delete-theme_' . $stylesheet )
|
||||||
. '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) )
|
. '" onclick="' . "return confirm( '" . esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) )
|
||||||
|
@ -145,7 +149,7 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||||
|
|
||||||
$actions = implode ( ' | ', $actions );
|
$actions = implode ( ' | ', $actions );
|
||||||
?>
|
?>
|
||||||
<a href="<?php echo $preview_link; ?>" class="thickbox thickbox-preview screenshot">
|
<a href="<?php echo $preview_link; ?>" class="load-customize screenshot" <?php echo $customize_attributes; ?>>
|
||||||
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
||||||
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
@ -41,27 +41,17 @@ if ( typeof wp === 'undefined' )
|
||||||
$( function() {
|
$( function() {
|
||||||
Loader.initialize();
|
Loader.initialize();
|
||||||
|
|
||||||
// Override 'preview' links on themes page.
|
$('#current-theme, #availablethemes').on( 'click', '.load-customize', function( event ) {
|
||||||
$('.thickbox-preview').click( function( event ) {
|
var load = $(this);
|
||||||
var href, template, stylesheet;
|
|
||||||
|
|
||||||
// Stop the thickbox.
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopImmediatePropagation();
|
|
||||||
|
|
||||||
// Extract the template/stylesheet from the preview link's url.
|
|
||||||
href = $(this).attr('href');
|
|
||||||
template = href.match('template=([^&]*)')[1];
|
|
||||||
stylesheet = href.match('stylesheet=([^&]*)')[1];
|
|
||||||
|
|
||||||
// Load the theme.
|
// Load the theme.
|
||||||
Loader.open({
|
Loader.open({
|
||||||
template: template,
|
template: load.data('customizeTemplate'),
|
||||||
stylesheet: stylesheet
|
stylesheet: load.data('customizeStylesheet')
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}).filter( function() {
|
|
||||||
return 'Preview' == $(this).text();
|
|
||||||
}).text('Customize');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Expose the API to the world.
|
// Expose the API to the world.
|
||||||
|
|
Loading…
Reference in New Issue