Commit Graph

40 Commits

Author SHA1 Message Date
Sergey Biryukov
001ffe81fb Docs: Improve inline comments per the documentation standards.
Includes minor code layout fixes for better readability.

See #48303.
Built from https://develop.svn.wordpress.org/trunk@47122


git-svn-id: http://core.svn.wordpress.org/trunk@46922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-29 00:45:18 +00:00
Sergey Biryukov
2a0489ec49 Docs: Replace @returns tags in JS docs with @return.
Per the documentation standards, `@returns` is an unsupported synonym, `@return` should be used instead:
https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/javascript/

See #48303.
Built from https://develop.svn.wordpress.org/trunk@46800


git-svn-id: http://core.svn.wordpress.org/trunk@46600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-11-29 18:01:03 +00:00
desrosj
03262a191f Block Editor: Refresh nonces used by wp.apiFetch.
Adds heartbeat nonces refreshing support to `wp.apiFetch` requests.

Props pento, adamsilverstein, dd32, desrosj, youknowriad.

Merges [43939] into trunk.

Fixes #45113. 
Built from https://develop.svn.wordpress.org/trunk@44275


git-svn-id: http://core.svn.wordpress.org/trunk@44105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-17 19:28:51 +00:00
atimmer
bde558be2f Docs: Add file doc @output annotations.
These annotations make it clear to the reader of a JavaScript source
where the build process outputs to. These annotations can later be
integrated in a webpack configuration. This way there is one source of
truth.

The `build` folder is omitted from the paths, because a single JS file
shouldn't not be responsible of knowing where outputs in general will
end up at. A file only knows its output location relative to the
project.

Props adamsilverstein, herregroen, omarreiss, pento.
Fixes #44361.

Built from https://develop.svn.wordpress.org/trunk@43347


git-svn-id: http://core.svn.wordpress.org/trunk@43175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-06-28 02:30:15 +00:00
atimmer
1a357d3758 Docs: Improve JS Docs for wp-includes/js/heartbeat.js.
Most of the documentation was already present. This change achieves the following:

* Fixes the formatting for most doc blocks.
* Adds `@since` tags to all functions.
* Makes sure the heartbeat public methods are correctly added to the `wp.heartbeat` namespace.

Props andizer, jjcomack, carolinegeven.
Fixes #42675.

Built from https://develop.svn.wordpress.org/trunk@42389


git-svn-id: http://core.svn.wordpress.org/trunk@42218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-12-12 14:33:54 +00:00
Weston Ruter
434e3aba82 Customize: Add changeset locking in Customizer to prevent users from overriding each other's changes.
* Customization locking is checked when changesets are saved and when heartbeat ticks.
* Lock is lifted immediately upon a user closing the Customizer.
* Heartbeat is introduced into Customizer.
* Changes made to user after it was locked by another user are stored as an autosave revision for restoration.
* Lock notification displays link to preview the other user's changes on the frontend.
* A user loading a locked Customizer changeset will be presented with an option to take over.
* Autosave revisions attached to a published changeset are converted into auto-drafts so that they will be presented to users for restoration.
* Focus constraining is improved in overlay notifications.
* Escape key is stopped from propagating in overlay notifications, and it dismisses dismissible overlay notifications.
* Introduces `changesetLocked` state which is used to disable the Save button and suppress the AYS dialog when leaving the Customizer.
* Fixes bug where users could be presented with each other's autosave revisions.

Props sayedwp, westonruter, melchoyce.
See #31436, #31897, #39896.
Fixes #42024.

Built from https://develop.svn.wordpress.org/trunk@41839


git-svn-id: http://core.svn.wordpress.org/trunk@41673 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-10-12 04:01:46 +00:00
Adam Silverstein
8a23b80b56 Docs: JSDoc improvements for namespaces.
Improve JS parsing of our inline JSDocs by introducing `@namespace`, `@lends` and `@memberOf`. Helps set the way for showing our JavaScript documentation on developer.wordpress.org, see https://meta.trac.wordpress.org/ticket/3063.

* Define all used namespaces using @namespace.
* Correctly specify in which namespace each class is using @memberOf.
* Define each usage of the extend function as a prototype assignment using @lends.
* Some comment blocks were moved to correct the parsing of certain definitions. 

Props herregroen, atimmer, netweb, SergeyBiryukov.  
Fixes #41682.

Built from https://develop.svn.wordpress.org/trunk@41351


git-svn-id: http://core.svn.wordpress.org/trunk@41184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-08 18:42:49 +00:00
Drew Jaynes
5f4497f0af Docs: Fix multiple trivial typos throughout a variety of core files.
Props ottok.
Fixes #38489.

Built from https://develop.svn.wordpress.org/trunk@39051


git-svn-id: http://core.svn.wordpress.org/trunk@38993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-31 06:28:32 +00:00
Dominik Schilling
e5ea82d81a Spelling: Standardize on "front end"/"back end" (noun) and "front-end"/"back-end" (adjective).
Props obrienlabs, thewanderingbrit.
Fixes #34887.
Built from https://develop.svn.wordpress.org/trunk@36709


git-svn-id: http://core.svn.wordpress.org/trunk@36676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-25 12:53:27 +00:00
Andrew Ozz
fa25fe82ef Fix updating of nonces on the Edit Post screen after the log in expires and the user logs in again.
Props iseulde, azaozz. Fixes #33098.
Built from https://develop.svn.wordpress.org/trunk@33468


git-svn-id: http://core.svn.wordpress.org/trunk@33435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-28 22:07:25 +00:00
Andrew Ozz
ba10ab197b Heartbeat:
- Use the page visibility API (when available) and document.hasFocus() instead of window.onfocus/onblur. Improves speeding up/slowing down the interval and works for iframes by default.
- Add a setting for minimal interval. Maximum value is 10 min. This overrides all other intervals and cannot be changed after setting it at initialization. Can be used to reduce the frequency of requests on hosts that have low limits for used CPU time, etc.
- Extend the setting of interval to support 120 sec. (60 sec, is still the default).
- Always suspend after one hour of keyboard/mouse/touch inactivity.
Fixes #29779.
Built from https://develop.svn.wordpress.org/trunk@30293


git-svn-id: http://core.svn.wordpress.org/trunk@30292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-10 01:47:24 +00:00
Drew Jaynes
d33c807723 Fix some documentation typos in various core files.
Props vlajos.
Fixes #29199.

Built from https://develop.svn.wordpress.org/trunk@29479


git-svn-id: http://core.svn.wordpress.org/trunk@29257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-13 03:56:17 +00:00
Andrew Ozz
2f2e5635cb Heartbeat: no longer "experimental", see #25272
Built from https://develop.svn.wordpress.org/trunk@27981


git-svn-id: http://core.svn.wordpress.org/trunk@27811 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-07 06:33:16 +00:00
Andrew Nacin
84c8a669d9 Heartbeat: Don't use a variable of the same name as the function it is in.
fixes #25073.

Built from https://develop.svn.wordpress.org/trunk@26626


git-svn-id: http://core.svn.wordpress.org/trunk@26516 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-04 19:24:09 +00:00
Andrew Ozz
0f20e57329 Heartbeat:
- Bring back heartbeat.interval().
- Rename wp_disable_heartbeat_suspend() to wp_heartbeat_set_suspension().
- Rename the option for disabling suspension from options.suspend to options.suspension.
Fixes #25073.
Built from https://develop.svn.wordpress.org/trunk@26549


git-svn-id: http://core.svn.wordpress.org/trunk@26441 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-03 00:45:10 +00:00
Andrew Ozz
162037903d Heartbeat: introduce "suspend" functionality and enable it after 20 min. of inactivity, see #25073.
Built from https://develop.svn.wordpress.org/trunk@26428


git-svn-id: http://core.svn.wordpress.org/trunk@26328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-27 01:56:10 +00:00
Andrew Ozz
0dcf40e749 Heartbeat: use cached $document instead of $(document), props TobiasBg, see #25073
Built from https://develop.svn.wordpress.org/trunk@26276


git-svn-id: http://core.svn.wordpress.org/trunk@26181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-19 23:52:10 +00:00
Andrew Nacin
14c473535b Fix JSHint errors in heartbeat.js.
props dziudek.
fixes #25986.

Built from https://develop.svn.wordpress.org/trunk@26197


git-svn-id: http://core.svn.wordpress.org/trunk@26105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-15 05:00:10 +00:00
Andrew Ozz
188fce6c9b Heartbeat: clean up code style, better naming, better code structure. Props carldanley, props evansolomon.
Changes:
- Add connectNow() public method to trigger a connection immediately.
- Remove the "skipping" when no data to send.
- Change the default interval to 60 sec.
- Fix resetting the next connection time when changing the interval.
See #25073.
Built from https://develop.svn.wordpress.org/trunk@26169


git-svn-id: http://core.svn.wordpress.org/trunk@26078 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-14 18:41:10 +00:00
Andrew Nacin
ede8b8db88 Have heartbeat's connection lost notice handle 503 errors send by the upgrader's maintenance mode.
fixes #25660 for 3.7.

Built from https://develop.svn.wordpress.org/trunk@25874


git-svn-id: http://core.svn.wordpress.org/trunk@25874 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-24 23:00:09 +00:00
Andrew Nacin
8ae8e01b67 Remove the old wp_auto_updates_maybe_update cron event. Schedule the new wp_maybe_auto_update event at 7 a.m. and 7 p.m. in the site's timezone.
see #27704.

Built from https://develop.svn.wordpress.org/trunk@25825


git-svn-id: http://core.svn.wordpress.org/trunk@25825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-24 22:53:14 +00:00
Andrew Nacin
ffd7f53bcf Have heartbeat's connection lost notice handle 503 errors send by the upgrader's maintenance mode.
fixes #25660 for 3.7.

Built from https://develop.svn.wordpress.org/trunk@25874


git-svn-id: http://core.svn.wordpress.org/trunk@25786 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-22 21:27:09 +00:00
Andrew Ozz
0e349eaace Heartbeat: better queue functionality: improve enqueue() and isQueued(), introduce dequeue() and getQueuedItem(). Props evansolomon, fixes #25047.
Built from https://develop.svn.wordpress.org/trunk@25078


git-svn-id: http://core.svn.wordpress.org/trunk@25063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-21 22:55:09 +00:00
Andrew Nacin
4df303ff76 Heartbeat: Reduce the heartbeat from 120 sec to 100 sec when the window doesn't have the focus, to be shorter than the post lock expiration window.
props azaozz.
fixes #24894.



git-svn-id: http://core.svn.wordpress.org/trunk@24908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-31 03:23:22 +00:00
Andrew Ozz
19fb0f1153 Add "experimental" to heartbeat phpdoc, fixes #24855 for trunk.
git-svn-id: http://core.svn.wordpress.org/trunk@24818 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-28 20:54:48 +00:00
Andrew Nacin
30344d57b8 Simplify heartbeat API.
* Move to a method to check connection errors, a better framework for future changes.
 * Remove start(), stop(), autostart.

props carldanley.
fixes #23216.



git-svn-id: http://core.svn.wordpress.org/trunk@24749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-19 01:39:48 +00:00
Andrew Ozz
b2ecb55343 Fix a comment typo in heartbeat.js, props mordauk, fixes #24745.
git-svn-id: http://core.svn.wordpress.org/trunk@24705 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-13 18:16:57 +00:00
Andrew Ozz
9602a29c5d Add file header to heartbeat.js, props DrewAPicture, fixes #24723
git-svn-id: http://core.svn.wordpress.org/trunk@24654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-11 00:35:52 +00:00
Andrew Ozz
fa2a6b856e Heartbeat:
- Pass the actual error to the jQuery event 'heartbeat-connection-lost'.
- When in error state, keep trying to connect even when no response is expected until the error is cleared.
See #23216.

git-svn-id: http://core.svn.wordpress.org/trunk@24577 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-05 23:33:47 +00:00
Andrew Ozz
b8b66e2cc1 Nonce refresh:
- Update the heartbeat nonce when refreshing nonces on the Edit Post screen.
- After a user logs in from the auth-check dialog, speed up heatrbeat to check/refresh nonces on the Edit Post screen.
- Speeding up heartbeat: bring back the setting how long it should last (how many ticks).
- Add 'heartbeat-nonces-expired' jQuery event when nonces have expired and the user is logged in.
See #23295, see #23216.

git-svn-id: http://core.svn.wordpress.org/trunk@24528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-06-29 01:31:44 +00:00
Andrew Ozz
0fff739949 Heartbeat: rename some vars/args to make them more intuitive, don't set user_id on every request, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@24406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-06-05 00:13:40 +00:00
Andrew Ozz
bcdb12da79 Heartbeat: in isLocalFrame() compare window.location.origin to iframe.src to stop most cases where WebKit triggers errors about different iframe origin, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@24384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-30 00:08:53 +00:00
Andrew Ozz
c5cf8301d0 Heartbeat: don't connect when a response is not expected by any script (nothing to send), remove debug logging, clean up code formatting, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@24268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-15 23:17:51 +00:00
Sergey Biryukov
708806d2a6 Fix typo in heartbeat.js. see #23216.
git-svn-id: http://core.svn.wordpress.org/trunk@24139 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-29 20:29:10 +00:00
Andrew Ozz
2466f6a726 Autosave: use heartbeat to determine when connection is lost and disable the Save and Publish buttons. Re-enable the buttons when connection is restored. Props dh-shredder, see #23220
git-svn-id: http://core.svn.wordpress.org/trunk@23886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-02 22:51:09 +00:00
Andrew Ozz
651534f24e Heartbeat: improve setting the errorstate, add ajaxurl to the settings object when loading on the front-end, some code cleanup, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@23882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-30 23:32:12 +00:00
Andrew Ozz
9c2ebc4c60 Heartbeat API: add nopriv actions, add JS 'heartbeat-send' event, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@23481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-25 02:32:22 +00:00
Andrew Ozz
6985523d00 Heartbeat API: fix error in IE < 9, props SergeyBiryukov, don't attempt to bind events to cross-domain iframes, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@23389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-06 07:10:04 +00:00
Andrew Ozz
6c41e93fec Heartbeat API: throttle down when the window looses focus or when the user is inactive, always send 'screen_id', change the interval settings to 'fast' (5sec), 'standard' (15sec) and 'slow' (60sec), the interval can be changed from PHP, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@23382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-03 07:03:27 +00:00
Andrew Ozz
98bf511b56 Heartbeat API: first run, see #23216
git-svn-id: http://core.svn.wordpress.org/trunk@23355 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-01-29 06:15:25 +00:00