[wp-trac] [WordPress Trac] #43453: heartbeat_received filter requires data in order to execute
WordPress Trac
noreply at wordpress.org
Thu Mar 1 15:38:40 UTC 2018
#43453: heartbeat_received filter requires data in order to execute
---------------------------+-----------------------------
Reporter: brianscaturro | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 4.9.4
Severity: normal | Keywords:
Focuses: javascript |
---------------------------+-----------------------------
With regards to the heartbeat api, the plugin developer handbook states:
Not every feature will need all three of these steps. For example, if
you don’t need to send any data to
the server, you can use just the latter two steps.
But this does not seem to be the case given this line of of
[https://core.trac.wordpress.org/browser/tags/4.9/src/wp-admin/includes
/ajax-actions.php#L2808 wp_ajax_heartbeat].
This makes it less useful if you just want to include some new data on an
interval. It requires an approach like:
{{{
#!javascript
$( document ).on('heartbeat-send', (e, data) => {
data.wouldLikeFilterToTrigger = true;
});
$(document).on('heartbeat-tick', (e, data) => {
// do something with data generated by filter
console.log(data);
});
}}}
If you omit the send event, the filter on the server never runs.
It seems like this constraint should be lifted, or at the very least the
documentation should be updated.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43453>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list