WordPress.org

Make WordPress Core

Opened 20 months ago

#43453 new defect (bug)

heartbeat_received filter requires data in order to execute

Reported by: brianscaturro Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9.4
Component: Plugins Keywords:
Focuses: javascript Cc:
PR Number:

Description

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 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:

$( 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.

Change History (0)

Note: See TracTickets for help on using tickets.