Ticket #20582: cors-test.patch

File cors-test.patch, 1.8 KB (added by azaozz, 12 months ago)
  • wp-includes/js/customize-loader.dev.js

     
    88        Loader = $.extend( {}, api.Events, { 
    99                supports: { 
    1010                        history:  !! ( window.history && history.pushState ), 
    11                         hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7) 
     11                        hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7), 
     12                        cors: (function(){ var xhr = new XMLHttpRequest(); return ( 'withCredentials' in xhr ); })() 
    1213                }, 
    1314 
    1415                initialize: function() { 
     
    128129        }); 
    129130 
    130131        $( function() { 
     132                var url, home; 
     133 
     134                if ( ! Loader.supports.cors ) { 
     135                        url = wpCustomizeLoaderL10n.url.replace(/https?:\/\//, ''); 
     136                        home = wpCustomizeLoaderL10n.home.replace(/https?:\/\//, ''); 
     137 
     138                        if ( url.indexOf( home ) == -1 ) { 
     139                                // no cors and x-domain, bail 
     140                        } 
     141                } 
     142 
    131143                if ( window.postMessage ) 
    132144                        Loader.initialize(); 
    133145        }); 
  • wp-includes/theme.php

     
    15891589 * @since 3.4.0 
    15901590 */ 
    15911591function _wp_customize_loader_localize() { 
    1592         $l10n = array( 'url'  => admin_url( 'admin.php' ) ); 
     1592        $l10n = array( 'url'  => admin_url( 'admin.php' ), 'home' => home_url() ); 
    15931593 
    15941594        if ( is_admin() ) 
    15951595                $l10n[ 'back' ] = sprintf( __( '← Return to %s' ), get_admin_page_title() ); 
     
    16051605 */ 
    16061606function wp_customize_url( $stylesheet ) { 
    16071607        return esc_url( admin_url( 'customize.php' ) . '?theme=' . $stylesheet ); 
    1608 } 
    1609  No newline at end of file 
     1608}