Changeset 20861
- Timestamp:
- 05/24/2012 01:48:32 AM (13 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-customize-manager.php
r20860 r20861 35 35 add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); 36 36 37 // Run wp_redirect_status late to make sure we override the status last. 38 add_action( 'wp_redirect_status', array( $this, 'wp_redirect_status' ), 1000 ); 39 37 40 add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); 38 41 … … 209 212 if ( $this->is_preview() && ! is_admin() ) 210 213 $this->customize_preview_init(); 214 } 215 216 /** 217 * Prevents AJAX requests from following redirects when previewing a theme 218 * by issuing a 200 response instead of a 30x. 219 * 220 * Instead, the JS will sniff out the location header. 221 * 222 * @since 3.4.0 223 */ 224 public function wp_redirect_status( $status ) { 225 if ( $this->is_preview() && ! is_admin() ) 226 return 200; 227 228 return $status; 211 229 } 212 230 -
trunk/wp-includes/js/customize-controls.dev.js
r20837 r20861 319 319 api.Messenger.prototype.initialize.call( this, params.url ); 320 320 321 // We're dynamically generating the iframe, so the origin is set 322 // to the current window's location, not the url's. 323 this.origin.unlink( this.url ).set( window.location.href ); 324 325 // Limit the URL to internal, front-end links. 326 this.url.setter( function( to ) { 327 // Bail if we're navigating to a different origin or wp-admin. 328 if ( 0 !== to.indexOf( self.origin() + '/' ) || -1 !== to.indexOf( 'wp-admin' ) ) 329 return null; 330 331 return to; 332 }); 333 334 // Refresh the preview when the URL is changed. 335 this.url.bind( this.refresh ); 336 321 337 this.scroll = 0; 322 338 this.bind( 'scroll', function( distance ) { … … 324 340 }); 325 341 326 // We're dynamically generating the iframe, so the origin is set 327 // to the current window's location, not the url's. 328 this.origin.unlink( this.url ).set( window.location.href ); 329 330 this.bind( 'url', function( url ) { 331 // Bail if we're navigating to the current url, to a different origin, or wp-admin. 332 if ( this.url() == url || 0 !== url.indexOf( this.origin() + '/' ) || -1 !== url.indexOf( 'wp-admin' ) ) 333 return; 334 335 this.url( url ); 336 this.refresh(); 337 }); 342 // Update the URL when the iframe sends a URL message. 343 this.bind( 'url', this.url ); 338 344 }, 339 345 loader: function() { … … 366 372 data: this.query() || {}, 367 373 success: function( response ) { 368 var iframe = self.loader()[0].contentWindow; 374 var iframe = self.loader()[0].contentWindow, 375 location = self.request.getResponseHeader('Location'); 376 377 // Check if the location response header differs from the current URL. 378 // If so, the request was redirected; try loading the requested page. 379 if ( location && location != self.url() ) { 380 self.url( location ); 381 return; 382 } 369 383 370 384 self.loader().one( 'load', self.loaded );
Note: See TracChangeset
for help on using the changeset viewer.