Articles of heartbeat api

Log of Heartbeat Calls

I’ve read that Heartbeat can slow a WP site down and I’m assuming if our admins/store managers have a lot of admin windows/tabs open, this will exacerbate the issue. If yes, is there a condition to test and log the calls that Heartbeat makes so I can see if the site slowdown could be related […]

CPU usage: AJAX and Heartbeat API on admin pages

My (shared) web host recently sent me this: “Our server monitoring systems keep indicating high server load persistently maintained by your website (…). Most of the hits are to the /www/www/wp-admin/admin-ajax.php script. We would advise the following: Do not stay logged into the WordPress dashboard through the day. Once you finish your work, you should […]

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

How can I get correct action hook on publish_posts for multiple custom types ? I have a following problem, I can use this hook for posts or single custom post_type, but I don’t know correct hook for multiple custom post types: // Post publication for posts add_filter ( ‘publish_post’, ‘notify_published_post’ ); function notify_published_post( $post_id ) […]

Heartbeat API oEmbed

By default running content through the_content filter automatically checks for oEmbed content. However when returning data through heartbeat_received the filter for oEmbed doesn’t seem to work. For example – function test_heartbeat_received( $response, $data ) { if( $data[‘test_heartbeat’] == ‘test’ ) { $content = “https://twitter.com/WordPress/status/456502643738030080”; // Doesn’t work global $wp_embed; $content = $wp_embed->autoembed( $content ); $response[‘test_heartbeat’] […]

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

My aim is to use the Heartbeat API to check if new posts have been published since the blog’s homepage was loaded. If new posts have been published, I will display a link at the top of the screen “16 new posts” which, when clicked, will insert the new posts into the DOM. My problem: […]

Heartbeat API long polling

I recently noticed that in Heartbeat API js client there was added option for speed of ticks called “long polling” with 0 interval. I pretty much understand what they try to achieve but I’m confused about how to implement plugin using this feature. For now every time my server received request from browser, hook was […]

Stop/Pause WordPress Heartbeat using Javascript

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. […]

Are WordPress Heartbeat API 'beats' staggered or do they occur simultaneously for all users?

The WordPress Heartbeat API uses admin-ajax.php to run AJAX calls. If User X leaves their browser open, many calls will be made to the server, with each call happening when there is a ‘beat’. Now if User Y leaves their browser open, many more calls will be made to the server, with each of these […]

How to disable the “Post Lock/Edit Lock”?

I want to disable this just for one Post Type, as it doesn’t really matters if there’s another user editing it (the main content editing area is Ajaxified and non-admins can only see that). I looked at the core functions but couldn’t find an entry point. From the function wp_set_post_lock I’m guessing that I’d have […]