[ 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. return: {void} since: 3.8.0 |
time() X-Ref |
Returns the current time according to the browser. return: {number} Returns the current time. since: 3.6.0 |
isLocalFrame( frame ) X-Ref |
Checks if the iframe is from the same origin. return: {boolean} Returns whether or not the iframe is from the same origin. since: 3.6.0 |
checkFocus() X-Ref |
Checks if the document's focus has changed. return: {void} since: 4.1.0 |
setErrorState( error, status ) X-Ref |
Sets error state and fires an event on XHR errors or timeout. return: {void} param: {string} error The error type passed from the XHR. param: {number} status The HTTP status code passed from jqXHR since: 3.8.0 |
clearErrorState() X-Ref |
Clears the error state and fires an event if there is a connection error. return: {void} since: 3.8.0 |
connect() X-Ref |
Gathers the data and connects to the server. return: {void} since: 3.6.0 |
scheduleNextTick() X-Ref |
Schedules the next connection. Fires immediately if the connection time is longer than the interval. return: {void} since: 3.8.0 |
blurred() X-Ref |
No description |
focused() X-Ref |
Sets the internal state when the browser window becomes visible or is in focus. return: {void} since: 3.6.0 |
userIsActive() X-Ref |
Runs when the user becomes active after a period of inactivity. return: {void} since: 3.6.0 |
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. return: {void} since: 3.8.0 |
hasFocus() X-Ref |
Checks whether the window (or any local iframe in it) has focus, or the user is active. return: {boolean} True if the window or the user is active. since: 3.6.0 |
hasConnectionError() X-Ref |
Checks whether there is a connection error. return: {boolean} True if a connection error was found. since: 3.6.0 |
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. return: {void} since: 3.8.0 |
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. return: {void} since: 3.8.0 |
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. 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 since: 3.6.0 |
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. 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. since: 3.6.0 |
isQueued( handle ) X-Ref |
Checks if data with a particular handle is queued. return: {boolean} True if the data is queued with this handle. param: {string} handle The handle for the data. since: 3.6.0 |
dequeue( handle ) X-Ref |
Removes data with a particular handle from the queue. return: {void} param: {string} handle The handle for the data. since: 3.7.0 |
getQueuedItem( handle ) X-Ref |
Gets data that was enqueued with a particular handle. return: {*} The data or undefined. param: {string} handle The handle for the data. since: 3.7.0 |
Generated: Sat Nov 23 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |