mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-10 21:00:59 +01:00
Administration: Increase frequency of heartbeat API requests.
Increases the frequency of heartbeat API requests from once every 15 seconds to once every 10 seconds. The purpose of this change is to reduce the length of time before a post becomes unlocked as a user navigates around the WordPress Dashboard and ceases editing a post. `wp.heartbeat.interval()` has been modified to allow theme and plugin authors to set the heartbeat interval to any value between one second and one hour rather than limiting them to a fixed set of values. Props azaozz, annezazu, jorbin, kirasong. Fixes #61960. Built from https://develop.svn.wordpress.org/trunk@59016 git-svn-id: http://core.svn.wordpress.org/trunk@58412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e296eeb012
commit
5d3a6274b4
@ -123,6 +123,14 @@ wp_add_inline_script(
|
||||
'before'
|
||||
);
|
||||
|
||||
// Set Heartbeat interval to 10 seconds, used to refresh post locks.
|
||||
wp_add_inline_script(
|
||||
'heartbeat',
|
||||
'if ( window.wp && window.wp.heartbeat ) {
|
||||
window.wp.heartbeat.interval( 10 );
|
||||
}'
|
||||
);
|
||||
|
||||
/*
|
||||
* Get all available templates for the post/page attributes meta-box.
|
||||
* The "Default template" array element should only be added if the array is
|
||||
|
@ -603,9 +603,9 @@ $( function() { inlineEditPost.init(); } );
|
||||
// Show/hide locks on posts.
|
||||
$( function() {
|
||||
|
||||
// Set the heartbeat interval to 15 seconds.
|
||||
// Set the heartbeat interval to 10 seconds.
|
||||
if ( typeof wp !== 'undefined' && wp.heartbeat ) {
|
||||
wp.heartbeat.interval( 15 );
|
||||
wp.heartbeat.interval( 10 );
|
||||
}
|
||||
}).on( 'heartbeat-tick.wp-check-locked-posts', function( e, data ) {
|
||||
var locked = data['wp-check-locked-posts'] || {};
|
||||
|
2
wp-admin/js/inline-edit-post.min.js
vendored
2
wp-admin/js/inline-edit-post.min.js
vendored
File diff suppressed because one or more lines are too long
@ -343,9 +343,9 @@ jQuery( function($) {
|
||||
}
|
||||
}).filter(':visible').find('.wp-tab-first').trigger( 'focus' );
|
||||
|
||||
// Set the heartbeat interval to 15 seconds if post lock dialogs are enabled.
|
||||
// Set the heartbeat interval to 10 seconds if post lock dialogs are enabled.
|
||||
if ( wp.heartbeat && $('#post-lock-dialog').length ) {
|
||||
wp.heartbeat.interval( 15 );
|
||||
wp.heartbeat.interval( 10 );
|
||||
}
|
||||
|
||||
// The form is being submitted by the user.
|
||||
|
2
wp-admin/js/post.min.js
vendored
2
wp-admin/js/post.min.js
vendored
File diff suppressed because one or more lines are too long
@ -132,16 +132,17 @@
|
||||
}
|
||||
|
||||
/*
|
||||
* The interval can be from 15 to 120 seconds and can be set temporarily to 5 seconds.
|
||||
* It can be set in the initial options or changed later through JS and/or through PHP.
|
||||
* Logic check: the interval can be from 1 to 3600 seconds and can be set temporarily
|
||||
* to 5 seconds. It can be set in the initial options or changed later from JS
|
||||
* or from PHP through the AJAX responses.
|
||||
*/
|
||||
if ( options.interval ) {
|
||||
settings.mainInterval = options.interval;
|
||||
|
||||
if ( settings.mainInterval < 15 ) {
|
||||
settings.mainInterval = 15;
|
||||
} else if ( settings.mainInterval > 120 ) {
|
||||
settings.mainInterval = 120;
|
||||
if ( settings.mainInterval < 1 ) {
|
||||
settings.mainInterval = 1;
|
||||
} else if ( settings.mainInterval > 3600 ) {
|
||||
settings.mainInterval = 3600;
|
||||
}
|
||||
}
|
||||
|
||||
@ -721,10 +722,10 @@
|
||||
*
|
||||
* @memberOf wp.heartbeat.prototype
|
||||
*
|
||||
* @param {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120.
|
||||
* @param {string|number} speed Interval: 'fast' or integer between 1 and 3600 (seconds).
|
||||
* Fast equals 5.
|
||||
* @param {string} ticks Tells how many ticks before the interval reverts
|
||||
* back. Used with speed = 'fast' or 5.
|
||||
* @param {number} ticks Tells how many ticks before the interval reverts back.
|
||||
* Value must be between 1 and 30. Used with speed = 'fast' or 5.
|
||||
*
|
||||
* @return {number} Current interval in seconds.
|
||||
*/
|
||||
@ -733,35 +734,28 @@
|
||||
oldInterval = settings.tempInterval ? settings.tempInterval : settings.mainInterval;
|
||||
|
||||
if ( speed ) {
|
||||
switch ( speed ) {
|
||||
case 'fast':
|
||||
case 5:
|
||||
if ( 'fast' === speed ) {
|
||||
// Special case, see below.
|
||||
newInterval = 5000;
|
||||
break;
|
||||
case 15:
|
||||
newInterval = 15000;
|
||||
break;
|
||||
case 30:
|
||||
newInterval = 30000;
|
||||
break;
|
||||
case 60:
|
||||
newInterval = 60000;
|
||||
break;
|
||||
case 120:
|
||||
newInterval = 120000;
|
||||
break;
|
||||
case 'long-polling':
|
||||
} else if ( 'long-polling' === speed ) {
|
||||
// Allow long polling (experimental).
|
||||
settings.mainInterval = 0;
|
||||
return 0;
|
||||
default:
|
||||
} else {
|
||||
speed = parseInt( speed, 10 );
|
||||
|
||||
if ( speed >= 1 && speed <= 3600 ) {
|
||||
newInterval = speed * 1000;
|
||||
} else {
|
||||
newInterval = settings.originalInterval;
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings.minimalInterval && newInterval < settings.minimalInterval ) {
|
||||
newInterval = settings.minimalInterval;
|
||||
}
|
||||
|
||||
// Special case, runs for a number of ticks then reverts to the previous interval.
|
||||
if ( 5000 === newInterval ) {
|
||||
ticks = parseInt( ticks, 10 ) || 30;
|
||||
ticks = ticks < 1 || ticks > 30 ? 30 : ticks;
|
||||
|
2
wp-includes/js/heartbeat.min.js
vendored
2
wp-includes/js/heartbeat.min.js
vendored
File diff suppressed because one or more lines are too long
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-59015';
|
||||
$wp_version = '6.7-alpha-59016';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user