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:
Daryl Koopersmith
2012-04-16 14:02:28 +00:00
parent 7c562a712e
commit a43958baeb
13 changed files with 127 additions and 112 deletions

View File

@@ -1583,30 +1583,33 @@ function _wp_customize_include() {
add_action( 'plugins_loaded', '_wp_customize_include' );
/**
* Includes the loading scripts for the theme customizer and
* adds the action to print the customize container template.
* Localizes the customize-loader script.
*
* @since 3.4.0
*/
function wp_customize_loader() {
wp_enqueue_script( 'customize-loader' );
add_action( 'admin_footer', '_wp_customize_loader_template' );
function _wp_customize_loader_localize() {
wp_localize_script( 'customize-loader', 'wpCustomizeLoaderL10n', array(
'back' => sprintf( __( '← Return to %s' ), get_admin_page_title() ),
) );
}
add_action( 'admin_enqueue_scripts', '_wp_customize_loader_localize' );
/**
* Returns a URL to load the theme customizer.
*
* @since 3.4.0
*/
function wp_customize_url( $template, $stylesheet = null ) {
$stylesheet = isset( $stylesheet ) ? $stylesheet : $template;
return admin_url( 'admin.php' ) . '?customize=on&template=' . $template . '&stylesheet=' . $stylesheet;
}
/**
* Print the customize container template.
* Prints an href attribute to load the theme customizer.
*
* @since 3.4.0
*/
function _wp_customize_loader_template() {
?>
<div id="customize-container" class="wp-full-overlay">
<input type="hidden" class="admin-url" value="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" />
<a href="#" class="close-full-overlay"><?php printf( __( '&larr; Return to %s' ), get_admin_page_title() ); ?></a>
<a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
<span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
<span class="collapse-sidebar-arrow"></span>
</a>
</div>
<?php
function wp_customize_href( $template, $stylesheet = null ) {
$link = wp_customize_url( $template, $stylesheet );
return 'href="' . esc_url( $link ) . '"';
}