Changeset 21071
- Timestamp:
- 06/12/2012 10:51:55 PM (14 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 3 edited
-
admin-ajax.php (modified) (1 diff)
-
includes/ajax-actions.php (modified) (1 diff)
-
js/customize-controls.dev.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r21003 r21071 39 39 $core_actions_get = array( 40 40 'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache', 41 'autocomplete-user', 'dashboard-widgets', 41 'autocomplete-user', 'dashboard-widgets', 'logged-in', 42 42 ); 43 43 -
trunk/wp-admin/includes/ajax-actions.php
r21003 r21071 211 211 } 212 212 wp_die(); 213 } 214 215 function wp_ajax_logged_in() { 216 wp_die( 1 ); 213 217 } 214 218 -
trunk/wp-admin/js/customize-controls.dev.js
r21037 r21071 289 289 290 290 initialize: function( params, options ) { 291 var loaded = false, 292 ready = false, 293 deferred = $.Deferred(), 291 var deferred = $.Deferred(), 294 292 self = this; 295 293 … … 305 303 this.add( 'previewUrl', params.previewUrl ); 306 304 307 this.bind( 'ready', function() { 305 this.query = $.extend( params.query || {}, { customize_messenger_channel: this.channel() }); 306 307 this.run( deferred ); 308 }, 309 310 run: function( deferred ) { 311 var self = this, 312 loaded = false, 313 ready = false; 314 315 if ( this._ready ) 316 this.unbind( 'ready', this._ready ); 317 318 this._ready = function() { 308 319 ready = true; 309 320 310 321 if ( loaded ) 311 322 deferred.resolveWith( self ); 312 } );313 314 params.query = $.extend( params.query || {}, { customize_messenger_channel: this.channel() });323 }; 324 325 this.bind( 'ready', this._ready ); 315 326 316 327 this.request = $.ajax( this.previewUrl(), { 317 328 type: 'POST', 318 data: params.query,329 data: this.query, 319 330 xhrFields: { 320 331 withCredentials: true … … 340 351 // Check if the user is not logged in. 341 352 if ( '0' === response ) { 342 deferred.rejectWith( self, [ 'logged out' ]);353 self.login( deferred ); 343 354 return; 344 355 } … … 357 368 } 358 369 359 // Strip the signature from the request.360 response = response.slice( 0, index ) + response.slice( index + signature.length );361 362 // Create the iframe and inject the html content.363 370 // Strip the signature from the request. 364 371 response = response.slice( 0, index ) + response.slice( index + signature.length ); … … 386 393 self.targetWindow().document.write( response ); 387 394 self.targetWindow().document.close(); 395 }); 396 }, 397 398 login: function( deferred ) { 399 var self = this, 400 reject; 401 402 reject = function() { 403 deferred.rejectWith( self, [ 'logged out' ] ); 404 }; 405 406 if ( this.triedLogin ) 407 return reject(); 408 409 // Check if we have an admin cookie. 410 $.get( api.settings.url.ajax, { 411 action: 'logged-in' 412 }).fail( reject ).done( function( response ) { 413 var iframe; 414 415 if ( '1' !== response ) 416 reject(); 417 418 iframe = $('<iframe src="' + self.previewUrl() + '" />').hide(); 419 iframe.appendTo( self.previewer.container ); 420 iframe.load( function() { 421 self.triedLogin = true; 422 423 iframe.remove(); 424 self.run( deferred ); 425 }); 388 426 }); 389 427 },
Note: See TracChangeset
for help on using the changeset viewer.