Make WordPress Core


Ignore:
Timestamp:
05/24/2012 09:13:21 PM (13 years ago)
Author:
koopersmith
Message:

Theme Customizer: Check for CORS support when the preview and admin urls are cross-domain. Add a fallback to the customize control frame, and check support there as well. see #20582, #19910.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/customize.php

    r20882 r20886  
    108108    $admin_origin = parse_url( admin_url() );
    109109    $home_origin  = parse_url( home_url() );
     110    $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
    110111
    111     if ( is_ssl() && ( $admin_origin[ 'host' ] == $home_origin[ 'host' ] ) )
     112    if ( is_ssl() && ! $cross_domain )
    112113        $allowed_urls[] = home_url( '/', 'https' );
    113114
    114115    $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
     116
     117    $fallback_url = add_query_arg( array(
     118        'preview'        => 1,
     119        'template'       => $wp_customize->get_template(),
     120        'stylesheet'     => $wp_customize->get_stylesheet(),
     121        'preview_iframe' => true,
     122        'TB_iframe'      => 'true'
     123    ), home_url( '/' ) );
    115124
    116125    $settings = array(
     
    120129        ),
    121130        'url'      => array(
    122             'preview'  => esc_url( home_url( '/' ) ),
    123             'parent'   => esc_url( admin_url() ),
    124             'ajax'     => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
    125             'allowed'  => array_map( 'esc_url', $allowed_urls ),
     131            'preview'       => esc_url( home_url( '/' ) ),
     132            'parent'        => esc_url( admin_url() ),
     133            'ajax'          => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
     134            'allowed'       => array_map( 'esc_url', $allowed_urls ),
     135            'isCrossDomain' => $cross_domain,
     136            'fallback'      => $fallback_url,
    126137        ),
    127138        'settings' => array(),
Note: See TracChangeset for help on using the changeset viewer.