Heartbeat: update wp-auth-check to use the new "connectNow()" method after a successful login, see #25073.
Built from https://develop.svn.wordpress.org/trunk@26530 git-svn-id: http://core.svn.wordpress.org/trunk@26423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c6ddea79d1
commit
e31c68f9d2
|
@ -4,7 +4,10 @@
|
||||||
var wrap, next;
|
var wrap, next;
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
var parent = $('#wp-auth-check'), form = $('#wp-auth-check-form'), noframe = wrap.find('.wp-auth-fallback-expired'), frame, loaded = false;
|
var parent = $('#wp-auth-check'),
|
||||||
|
form = $('#wp-auth-check-form'),
|
||||||
|
noframe = wrap.find('.wp-auth-fallback-expired'),
|
||||||
|
frame, loaded = false;
|
||||||
|
|
||||||
if ( form.length ) {
|
if ( form.length ) {
|
||||||
// Add unload confirmation to counter (frame-busting) JS redirects
|
// Add unload confirmation to counter (frame-busting) JS redirects
|
||||||
|
@ -68,10 +71,10 @@
|
||||||
$(window).off( 'beforeunload.wp-auth-check' );
|
$(window).off( 'beforeunload.wp-auth-check' );
|
||||||
|
|
||||||
// When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces
|
// When on the Edit Post screen, speed up heartbeat after the user logs in to quickly refresh nonces
|
||||||
if ( typeof adminpage != 'undefined' && ( adminpage == 'post-php' || adminpage == 'post-new-php' ) &&
|
if ( typeof adminpage !== 'undefined' && ( adminpage === 'post-php' || adminpage === 'post-new-php' ) &&
|
||||||
typeof wp != 'undefined' && wp.heartbeat ) {
|
typeof wp !== 'undefined' && wp.heartbeat ) {
|
||||||
|
|
||||||
wp.heartbeat.interval( 'fast', 1 );
|
wp.heartbeat.connectNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
wrap.fadeOut( 200, function() {
|
wrap.fadeOut( 200, function() {
|
||||||
|
@ -88,14 +91,16 @@
|
||||||
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
|
$( document ).on( 'heartbeat-tick.wp-auth-check', function( e, data ) {
|
||||||
if ( 'wp-auth-check' in data ) {
|
if ( 'wp-auth-check' in data ) {
|
||||||
schedule();
|
schedule();
|
||||||
if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') )
|
if ( ! data['wp-auth-check'] && wrap.hasClass('hidden') ) {
|
||||||
show();
|
show();
|
||||||
else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') )
|
} else if ( data['wp-auth-check'] && ! wrap.hasClass('hidden') ) {
|
||||||
hide();
|
hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
|
}).on( 'heartbeat-send.wp-auth-check', function( e, data ) {
|
||||||
if ( ( new Date() ).getTime() > next )
|
if ( ( new Date() ).getTime() > next ) {
|
||||||
data['wp-auth-check'] = true;
|
data['wp-auth-check'] = true;
|
||||||
|
}
|
||||||
}).ready( function() {
|
}).ready( function() {
|
||||||
schedule();
|
schedule();
|
||||||
wrap = $('#wp-auth-check-wrap');
|
wrap = $('#wp-auth-check-wrap');
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
!function(a){function b(){var b,d=a("#wp-auth-check"),f=a("#wp-auth-check-form"),g=e.find(".wp-auth-fallback-expired"),h=!1;f.length&&(a(window).on("beforeunload.wp-auth-check",function(a){a.originalEvent.returnValue=window.authcheckL10n.beforeunload}),b=a('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",g.text()),b.load(function(){var b,i;h=!0;try{i=a(this).contents().find("body"),b=i.height()}catch(j){return e.addClass("fallback"),d.css("max-height",""),f.remove(),g.focus(),void 0}b?i&&i.hasClass("interim-login-success")?c():d.css("max-height",b+40+"px"):i&&i.length||(e.addClass("fallback"),d.css("max-height",""),f.remove(),g.focus())}).attr("src",f.data("src")),a("#wp-auth-check-form").append(b)),e.removeClass("hidden"),b?(b.focus(),setTimeout(function(){h||(e.addClass("fallback"),f.remove(),g.focus())},1e4)):g.focus()}function c(){a(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!=adminpage&&"post-new-php"!=adminpage||"undefined"==typeof wp||!wp.heartbeat||wp.heartbeat.interval("fast",1),e.fadeOut(200,function(){e.addClass("hidden").css("display",""),a("#wp-auth-check-frame").remove()})}function d(){var a=parseInt(window.authcheckL10n.interval,10)||180;f=(new Date).getTime()+1e3*a}var e,f;a(document).on("heartbeat-tick.wp-auth-check",function(a,f){"wp-auth-check"in f&&(d(),!f["wp-auth-check"]&&e.hasClass("hidden")?b():f["wp-auth-check"]&&!e.hasClass("hidden")&&c())}).on("heartbeat-send.wp-auth-check",function(a,b){(new Date).getTime()>f&&(b["wp-auth-check"]=!0)}).ready(function(){d(),e=a("#wp-auth-check-wrap"),e.find(".wp-auth-check-close").on("click",function(){c()})})}(jQuery);
|
!function(a){function b(){var b,d=a("#wp-auth-check"),f=a("#wp-auth-check-form"),g=e.find(".wp-auth-fallback-expired"),h=!1;f.length&&(a(window).on("beforeunload.wp-auth-check",function(a){a.originalEvent.returnValue=window.authcheckL10n.beforeunload}),b=a('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",g.text()),b.load(function(){var b,i;h=!0;try{i=a(this).contents().find("body"),b=i.height()}catch(j){return e.addClass("fallback"),d.css("max-height",""),f.remove(),g.focus(),void 0}b?i&&i.hasClass("interim-login-success")?c():d.css("max-height",b+40+"px"):i&&i.length||(e.addClass("fallback"),d.css("max-height",""),f.remove(),g.focus())}).attr("src",f.data("src")),a("#wp-auth-check-form").append(b)),e.removeClass("hidden"),b?(b.focus(),setTimeout(function(){h||(e.addClass("fallback"),f.remove(),g.focus())},1e4)):g.focus()}function c(){a(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!==adminpage&&"post-new-php"!==adminpage||"undefined"==typeof wp||!wp.heartbeat||wp.heartbeat.connectNow(),e.fadeOut(200,function(){e.addClass("hidden").css("display",""),a("#wp-auth-check-frame").remove()})}function d(){var a=parseInt(window.authcheckL10n.interval,10)||180;f=(new Date).getTime()+1e3*a}var e,f;a(document).on("heartbeat-tick.wp-auth-check",function(a,f){"wp-auth-check"in f&&(d(),!f["wp-auth-check"]&&e.hasClass("hidden")?b():f["wp-auth-check"]&&!e.hasClass("hidden")&&c())}).on("heartbeat-send.wp-auth-check",function(a,b){(new Date).getTime()>f&&(b["wp-auth-check"]=!0)}).ready(function(){d(),e=a("#wp-auth-check-wrap"),e.find(".wp-auth-check-close").on("click",function(){c()})})}(jQuery);
|
Loading…
Reference in New Issue