Post edit ignores interval set by plugin
-
I have the plugin set to an interval of 60 seconds.
When on the post edit page, I can also see that heartbeatSettings.interval = “60”
However, I see admin-ajax XHR requests being fired every 15 seconds regardless, and each XHR request’s contains interval: 15 in the POST data sent to the server.
If I check wp.heartbeat.interval(); in the console, it returns 15. I can change this using wp.heartbeat.interval(‘slow’); and it starts ticking at 60 seconds instead of 15. Using ‘fast’ makes it tick at 5 seconds. Passing a number such as 22 makes it revert to ‘slow’ setting of 60.
It appears that you can use a couple of filters “heartbeat_received” and “heartbeat_nopriv_received” to return ‘heartbeat_interval’ = ‘slow’ in the response to make it change to 60 seconds instead of the 15 seconds default, but you can’t fine tune it with an exact number. fast = 5, standard = 15, slow = 60 is as good as it gets.
Based on this, it appears that WP takes heartbeat_settings[‘interval’] as a recommendation, and can choose to completely ignore it if they want. It probably overrides the default, but if a heartbeat specifies a specific interval, it will use that instead.
Hopefully this information can help you with a version update. I’m not sure if WP devs changed something recently, or if it’s always been this behavior and nobody noticed. If you update it, you’ll probably end up having only options for 5, 15, 60 seconds to match what they allow you to override using either wp.heartbeat.interval() via JS or the two filters mentioned.
- The topic ‘Post edit ignores interval set by plugin’ is closed to new replies.