Make WordPress Core

Ticket #20507: 20507.4.diff

File 20507.4.diff, 1.9 KB (added by mdawaffe, 13 years ago)
  • wp-includes/class-wp-customize.php

     
    7171                if ( ! isset( $_REQUEST['customize'] ) || 'on' != $_REQUEST['customize'] )
    7272                        return;
    7373
     74                $url = parse_url( admin_url() );
     75                $allowed_origins = array( 'http://' . $url[ 'host' ],  'https://' . $url[ 'host' ] );
     76                // @todo preserve port?
     77                if ( isset( $_SERVER[ 'HTTP_ORIGIN' ] ) && in_array( $_SERVER[ 'HTTP_ORIGIN' ], $allowed_origins ) ) {
     78                        $origin = $_SERVER[ 'HTTP_ORIGIN' ];
     79                } else {
     80                        $origin = $url[ 'scheme' ] . '://' . $url[ 'host' ];
     81                }
     82
     83                @header( 'Access-Control-Allow-Origin: ' .  $origin );
     84                @header( 'Access-Control-Allow-Credentials: true' );
     85
    7486                $this->start_previewing_theme();
    7587                show_admin_bar( false );
    7688        }
  • wp-includes/js/customize-controls.dev.js

     
    343343                        if ( this.request )
    344344                                this.request.abort();
    345345
    346                         this.request = $.post( this.url(), this.query() || {}, function( response ) {
    347                                 var iframe = self.loader()[0].contentWindow;
     346                        this.request = $.ajax( this.url(), {
     347                                type: 'POST',
     348                                data: this.query() || {},
     349                                success: function( response ) {
     350                                        var iframe = self.loader()[0].contentWindow;
    348351
    349                                 self.loader().one( 'load', self.loaded );
     352                                        self.loader().one( 'load', self.loaded );
    350353
    351                                 iframe.document.open();
    352                                 iframe.document.write( response );
    353                                 iframe.document.close();
    354                         });
     354                                        iframe.document.open();
     355                                        iframe.document.write( response );
     356                                        iframe.document.close();
     357                                },
     358                                xhrFields: {
     359                                        withCredentials: true
     360                                }
     361                        } );
    355362                }
    356363        });
    357364