mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
Theme Customizer: Allow the customize iframe to be accessed directly (with full feature support). see #19910.
* Move the 'Return to Manage Themes' and 'Collapse Sidebar' actions from themes.php to customize-controls.php. * Create a postMessage connection between themes.php and customize-controls.php. * Allow the theme customizer to be accessed directly (independent of themes.php and the customize loader). * Add wp_customize_href() and wp_customize_url(). * Remove wp_customize_loader(). To include the loader, use wp_enqueue_script( 'customize-loader' ). * The theme customizer now requires postMessage browser support. * Add .hide-if-customize and .hide-if-no-customize CSS classes. * Clean up customize-preview.js. git-svn-id: https://develop.svn.wordpress.org/trunk@20476 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -5313,6 +5313,16 @@ body.full-overlay-active {
|
||||
24.0 - Customize Loader
|
||||
------------------------------------------------------------------------------*/
|
||||
|
||||
.hide-if-no-customize,
|
||||
.customize-support .hide-if-customize {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.hide-if-customize,
|
||||
.customize-support .hide-if-no-customize {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
#customize-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -131,15 +131,13 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
array( 'preview' => 1, 'template' => $template, 'stylesheet' => $stylesheet, 'preview_iframe' => true, 'TB_iframe' => 'true' ),
|
||||
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[] = '<a href="' . $activate_link . '" class="activatelink" title="'
|
||||
. esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>';
|
||||
$actions[] = '<a href="' . $preview_link . '" class="hide-if-js" title="'
|
||||
$actions[] = '<a href="' . $preview_link . '" class="hide-if-customize" title="'
|
||||
. esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>'
|
||||
. '<a href="#" class="load-customize hide-if-no-js" ' . $customize_attributes . '>' . __( 'Customize' ) . '</a>';
|
||||
. '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="load-customize hide-if-no-customize">'
|
||||
. __( 'Customize' ) . '</a>';
|
||||
if ( ! is_multisite() && current_user_can( 'delete_themes' ) )
|
||||
$actions['delete'] = '<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 ) )
|
||||
@@ -150,11 +148,18 @@ class WP_Themes_List_Table extends WP_List_Table {
|
||||
unset( $actions['delete'] );
|
||||
|
||||
?>
|
||||
<a href="<?php echo $preview_link; ?>" class="load-customize screenshot" <?php echo $customize_attributes; ?>>
|
||||
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
||||
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
||||
<?php endif; ?>
|
||||
|
||||
<a href="<?php echo $preview_link; ?>" class="screenshot hide-if-customize">
|
||||
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
||||
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<a <?php echo wp_customize_href( $template, $stylesheet ); ?> class="screenshot load-customize hide-if-no-customize">
|
||||
<?php if ( $screenshot = $theme->get_screenshot() ) : ?>
|
||||
<img src="<?php echo esc_url( $screenshot ); ?>" alt="" />
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
|
||||
<h3><?php echo $title; ?></h3>
|
||||
<div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div>
|
||||
<div class="action-links">
|
||||
|
||||
@@ -1507,9 +1507,6 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
'stylesheet' => $stylesheet,
|
||||
), trailingslashit( get_home_url() ) );
|
||||
|
||||
$customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize “%s”' ), $name ) ) . '"
|
||||
. data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';
|
||||
|
||||
$activate_link = add_query_arg( array(
|
||||
'action' => 'activate',
|
||||
'template' => $template,
|
||||
@@ -1518,8 +1515,8 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $template );
|
||||
|
||||
$install_actions = array();
|
||||
$install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-js" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
|
||||
$install_actions['preview'] .= '<a href="#" class="hide-if-no-js load-customize" ' . $customize_attributes . '>' . __('Customize') . '</a>';
|
||||
$install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
|
||||
$install_actions['preview'] .= '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="hide-if-no-customize load-customize>' . __('Customize') . '</a>';
|
||||
$install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
|
||||
|
||||
if ( is_network_admin() && current_user_can( 'manage_network_themes' ) )
|
||||
@@ -1574,9 +1571,6 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
'stylesheet' => $stylesheet,
|
||||
), trailingslashit( get_home_url() ) );
|
||||
|
||||
$customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize “%s”' ), $name ) ) . '"
|
||||
. data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';
|
||||
|
||||
$activate_link = add_query_arg( array(
|
||||
'action' => 'activate',
|
||||
'template' => $template,
|
||||
@@ -1584,8 +1578,8 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
), admin_url('themes.php') );
|
||||
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $template );
|
||||
|
||||
$update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-js" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
|
||||
$update_actions['preview'] .= '<a href="#" class="hide-if-no-js load-customize" ' . $customize_attributes . '>' . __('Customize') . '</a>';
|
||||
$update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
|
||||
$update_actions['preview'] .= '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="hide-if-no-customize load-customize">' . __('Customize') . '</a>';
|
||||
$update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
|
||||
|
||||
if ( ( ! $this->result || is_wp_error( $this->result ) ) || $stylesheet == get_stylesheet() )
|
||||
|
||||
+2
-2
@@ -67,7 +67,7 @@ get_current_screen()->set_help_sidebar(
|
||||
);
|
||||
|
||||
wp_enqueue_script( 'theme' );
|
||||
wp_customize_loader();
|
||||
wp_enqueue_script( 'customize-loader' );
|
||||
|
||||
endif;
|
||||
|
||||
@@ -122,7 +122,7 @@ $class = $screenshot ? 'has-screenshot' : '';
|
||||
</div>
|
||||
|
||||
<div class="theme-options">
|
||||
<a href="#" class="load-customize hide-if-no-js" data-customize-template="<?php echo esc_attr( $ct->get_template() ); ?>" data-customize-stylesheet="<?php echo esc_attr( $ct->get_stylesheet() ); ?>" title="<?php echo esc_attr( sprintf( __( 'Customize “%s”' ), $ct->get('Name') ) ); ?>"><?php _e( 'Customize' )?></a>
|
||||
<a <?php echo wp_customize_href( $ct->get_template(), $ct->get_stylesheet() ); ?> class="load-customize hide-if-no-customize" title="<?php echo esc_attr( sprintf( __( 'Customize “%s”' ), $ct->get('Name') ) ); ?>"><?php _e( 'Customize' )?></a>
|
||||
<span><?php _e( 'Options:' )?></span>
|
||||
<?php
|
||||
// Pretend you didn't see this.
|
||||
|
||||
+3
-3
@@ -152,7 +152,7 @@ if ( isset($_GET['action']) ) {
|
||||
|
||||
check_admin_referer('upgrade-theme_' . $theme);
|
||||
|
||||
wp_customize_loader();
|
||||
wp_enqueue_script( 'customize-loader' );
|
||||
|
||||
$title = __('Update Theme');
|
||||
$parent_file = 'themes.php';
|
||||
@@ -204,7 +204,7 @@ if ( isset($_GET['action']) ) {
|
||||
if ( is_wp_error($api) )
|
||||
wp_die($api);
|
||||
|
||||
wp_customize_loader();
|
||||
wp_enqueue_script( 'customize-loader' );
|
||||
|
||||
$title = __('Install Themes');
|
||||
$parent_file = 'themes.php';
|
||||
@@ -230,7 +230,7 @@ if ( isset($_GET['action']) ) {
|
||||
|
||||
$file_upload = new File_Upload_Upgrader('themezip', 'package');
|
||||
|
||||
wp_customize_loader();
|
||||
wp_enqueue_script( 'customize-loader' );
|
||||
|
||||
$title = __('Upload Theme');
|
||||
$parent_file = 'themes.php';
|
||||
|
||||
Reference in New Issue
Block a user