From b1a672cdfa6e4cf4314c7025c2941134355eb071 Mon Sep 17 00:00:00 2001 From: Daryl Koopersmith Date: Fri, 25 May 2012 00:15:12 +0000 Subject: [PATCH] Theme Customizer: Add CORS checks to the initial check for customize support. Prevents flash of customize links on large pages. see #20582, #19910. Add wp_customize_support_script(), to quickly alter the body class based on whether customize is supported. git-svn-id: https://develop.svn.wordpress.org/trunk@20893 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/admin-header.php | 9 ++------- wp-includes/theme.php | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index 8cb315284b..6aba1c14d5 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -97,15 +97,10 @@ $admin_body_class .= ' no-customize-support'; "> + +
diff --git a/wp-includes/theme.php b/wp-includes/theme.php index fb9fc04eef..8bbf799a82 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -1618,3 +1618,44 @@ add_action( 'admin_enqueue_scripts', '_wp_customize_loader_settings' ); function wp_customize_url( $stylesheet ) { return esc_url( admin_url( 'customize.php' ) . '?theme=' . $stylesheet ); } + +/** + * Prints a script to check whether or not the customizer is supported, + * and apply either the no-customize-support or customize-support class + * to the body. + * + * This function MUST be called inside the body tag. + * + * Ideally, call this function immediately after the body tag is opened. + * This prevents a flash of unstyled content. + * + * It is also recommended that you add the "no-customize-support" class + * to the body tag by default. + * + * @since 3.4.0 + */ +function wp_customize_support_script() { + if ( ! wp_script_is( 'customize-loader', 'queue' ) ) + return; + + $admin_origin = parse_url( admin_url() ); + $home_origin = parse_url( home_url() ); + $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) ); + + ?> + +