How to create notification on frontend using heartbeat api for multiple custom post types

I think you can achieve this by: 1.determine the custom post types by using get_post_types() fx It returns a list of post names or objects on basis of parameter you pass <?php $args = array( ‘public’ => true, ‘_builtin’ => false ); //pass parameter to array according to get all custom post types( parameter pass … Read more

How to link WordPress heartbeat to ajax form

Saving data Based on Heartbeat API, you can add custom data to the sent heartbeat on heartbeat-send event in js. This would be used instead of the ajax function you have in your code example. jQuery( document ).on( ‘heartbeat-send’, function ( event, data ) { // Grab the required form data data.location = jQuery(‘input[name=”location”]:checked’).val(); data.userid … Read more

Log of Heartbeat Calls

From quick look at the code, there is number of hooks firing in wp_ajax_heartbeat(). Out of which heartbeat_tick action seems quite appropriate to hook some logging logic too. For the sake of completeness, while you are interested in logged in activity, the hook would be heartbeat_nopriv_tick for logged out users.

How to check if new posts have been published since page load?

Determining the current time There’s the current_time() function in core that allows to pass three different values as first argument and gmt (the offset) as second argument. About the 1st: mysql -> gmdate( ‘Y-m-d H:i:s’ ), human readable e.g 2004/07/8 13:35:19 timestamp -> time(), the UNIX timestamp for e.g. 1335939007 A custom argument that is … Read more

Stop/Pause WordPress Heartbeat using Javascript

Drivingralle, You are on the right trail here with your code. I’ve done some work in the JavaScript console, and my conclusion from debugging heartbeat.min.js temporarily (source came from heartbeat.js) is that settings.suspend is properly triggered on the ‘unload.wp-heartbeat’ event. However, I believe it to be a bug that the focused() function sets settings.suspend back … Read more

Heartbeat API long polling

The Hearbeat API works by periodically sending an XHR request to the server, with hooks available for WordPress/plug-ins/themes to attach data to be returned to the client. Once the data is returned, a new beat is scheduled. The speed (or ‘pulse’) of the heartbeat may be tempered, either server-side or client side in reaction to … Read more