Is there a way to manually trigger WordPress' heartbeat

327 views Asked by At

I have written something that hook into WordPress' heartbeat via the heartbeat-send JS event.
However, to test things I am doing a lot of sitting around and waiting.

I've tried to run jQuery(document).trigger("heartbeat-send"); from the console with no luck.
I'm unsure of how to trigger the heartbeat at any time, or if it's even possible :)

2

There are 2 answers

1
CookiesForDevo On

Was just looking for this myself and came across this answer on another site to manually trigger the heartbeat:

wp.heartbeat.connectNow();
1
Tejas Silicon On

Please refer this below link its help you

https://developer.wordpress.org/plugins/javascript/heartbeat-api/

jQuery(document).on('heartbeat-tick', function(event, data) {
    // Check for our data, and use it.
    if (!data.myplugin_customfield_hashed) {
        return;
    }
    alert('The hash is ' + data.myplugin_customfield_hashed);
});