Ticket #20926: 20926.diff
| File 20926.diff, 3.6 KB (added by koopersmith, 12 months ago) |
|---|
-
wp-admin/admin-ajax.php
38 38 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 44 44 $core_actions_post = array( -
wp-admin/includes/ajax-actions.php
212 212 wp_die(); 213 213 } 214 214 215 function wp_ajax_logged_in() { 216 wp_die( 1 ); 217 } 218 215 219 /* 216 220 * Ajax helper. 217 221 */ -
wp-admin/js/customize-controls.dev.js
288 288 sensitivity: 2000, 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 296 294 // This is the promise object. … … 304 302 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 } );323 }; 313 324 314 params.query = $.extend( params.query || {}, { customize_messenger_channel: this.channel() });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 321 332 } … … 339 350 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 } 345 356 … … 360 371 response = response.slice( 0, index ) + response.slice( index + signature.length ); 361 372 362 373 // Create the iframe and inject the html content. 363 // Strip the signature from the request.364 response = response.slice( 0, index ) + response.slice( index + signature.length );365 366 // Create the iframe and inject the html content.367 374 self.iframe = $('<iframe />').appendTo( self.previewer.container ); 368 375 369 376 // Bind load event after the iframe has been added to the page; … … 388 395 }); 389 396 }, 390 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 }); 426 }); 427 }, 428 391 429 destroy: function() { 392 430 api.Messenger.prototype.destroy.call( this ); 393 431 this.request.abort();