[ Index ] |
PHP Cross Reference of WordPress |
[Source view] [Print] [Project Stats]
Heartbeat API Heartbeat is a simple server polling API that sends XHR requests to the server every 15 - 60 seconds and triggers events (or callbacks) upon receiving data. Currently these 'ticks' handle transports for post locking, login-expiration warnings, autosave, and related tasks while a user is logged in.
File Size: | 873 lines (23 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
initialize() X-Ref |
Sets local variables and events, then starts the heartbeat. since: 3.8.0 return: {void} |
time() X-Ref |
Returns the current time according to the browser. since: 3.6.0 return: {number} Returns the current time. |
isLocalFrame( frame ) X-Ref |
Checks if the iframe is from the same origin. since: 3.6.0 return: {boolean} Returns whether or not the iframe is from the same origin. |
checkFocus() X-Ref |
Checks if the document's focus has changed. since: 4.1.0 return: {void} |
setErrorState( error, status ) X-Ref |
Sets error state and fires an event on XHR errors or timeout. since: 3.8.0 return: {void} param: {string} error The error type passed from the XHR. param: {number} status The HTTP status code passed from jqXHR |
clearErrorState() X-Ref |
Clears the error state and fires an event if there is a connection error. since: 3.8.0 return: {void} |
connect() X-Ref |
Gathers the data and connects to the server. since: 3.6.0 return: {void} |
scheduleNextTick() X-Ref |
Schedules the next connection. Fires immediately if the connection time is longer than the interval. since: 3.8.0 return: {void} |
blurred() X-Ref |
No description |
focused() X-Ref |
Sets the internal state when the browser window becomes visible or is in focus. since: 3.6.0 return: {void} |
userIsActive() X-Ref |
Runs when the user becomes active after a period of inactivity. since: 3.6.0 return: {void} |
checkUserActivity() X-Ref |
Checks for user activity. Runs every 30 seconds. Sets 'hasFocus = true' if user is active and the window is in the background. Sets 'hasFocus = false' if the user has been inactive (no mouse or keyboard activity) for 5 minutes even when the window has focus. since: 3.8.0 return: {void} |
hasFocus() X-Ref |
Checks whether the window (or any local iframe in it) has focus, or the user is active. since: 3.6.0 return: {boolean} True if the window or the user is active. |
hasConnectionError() X-Ref |
Checks whether there is a connection error. since: 3.6.0 return: {boolean} True if a connection error was found. |
connectNow() X-Ref |
Connects as soon as possible regardless of 'hasFocus' state. Will not open two concurrent connections. If a connection is in progress, will connect again immediately after the current connection completes. since: 3.8.0 return: {void} |
disableSuspend() X-Ref |
Disables suspending. Should be used only when Heartbeat is performing critical tasks like autosave, post-locking, etc. Using this on many screens may overload the user's hosting account if several browser windows/tabs are left open for a long time. since: 3.8.0 return: {void} |
interval( speed, ticks ) X-Ref |
Gets/Sets the interval. When setting to 'fast' or 5, the interval is 5 seconds for the next 30 ticks (for 2 minutes and 30 seconds) by default. In this case the number of 'ticks' can be passed as second argument. If the window doesn't have focus, the interval slows down to 2 minutes. since: 3.6.0 return: {number} Current interval in seconds. param: {string|number} speed Interval: 'fast' or 5, 15, 30, 60, 120. param: {string} ticks Tells how many ticks before the interval reverts |
enqueue( handle, data, noOverwrite ) X-Ref |
Enqueues data to send with the next XHR. As the data is send asynchronously, this function doesn't return the XHR response. To see the response, use the custom jQuery event 'heartbeat-tick' on the document, example: $(document).on( 'heartbeat-tick.myname', function( event, data, textStatus, jqXHR ) { // code }); If the same 'handle' is used more than once, the data is not overwritten when the third argument is 'true'. Use `wp.heartbeat.isQueued('handle')` to see if any data is already queued for that handle. since: 3.6.0 return: {boolean} True if the data was queued. param: {string} handle Unique handle for the data, used in PHP to param: {*} data The data to send. param: {boolean} noOverwrite Whether to overwrite existing data in the queue. |
isQueued( handle ) X-Ref |
Checks if data with a particular handle is queued. since: 3.6.0 return: {boolean} True if the data is queued with this handle. param: {string} handle The handle for the data. |
dequeue( handle ) X-Ref |
Removes data with a particular handle from the queue. since: 3.7.0 return: {void} param: {string} handle The handle for the data. |
getQueuedItem( handle ) X-Ref |
Gets data that was enqueued with a particular handle. since: 3.7.0 return: {*} The data or undefined. param: {string} handle The handle for the data. |
Generated: Fri Dec 27 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |