I use the WordPress heartbeat to check a setting on my server from the front-end. If that setting has a specific value I want to stop bothering the server. There for I want to stop/pause the heartbeat. There are no other things depending on the heartbeat.
I found wp.heartbeat.stop() over here, but it doesn’t work.
jQuery(document).ready(function ($) {
$(document).on('heartbeat-tick', function (e, data) {
[...]
if (true == x) {
wp.heartbeat.stop();
}
[...]
}
});
I get this error in the console:
TypeError: wp.heartbeat.stop is not a function
wp.heartbeat.stop();
Can’t find the stop() function in the heartbeat.js file.
This code doesn’t produce an error, but doesn’t work too.
jQuery(document).ready(function ($) {
$(document).on('heartbeat-tick', function (e, data) {
[...]
if (true == x) {
$(window).trigger('unload.wp-heartbeat');
}
[...]
}
});
Do I trigger the unload.wp-heartbeat event the wrong way?