Articles of heartbeat api

Heartbeat API NOT disabling

I’m hoping this is something easy to fix although from my tests (very new to WordPress so please go easy with me if these tests are not very good!) doesn’t appear to be. I have a site hosted on SiteGround which was eating through the CPU seconds like nobody’s business. I’ve now managed to put […]

Why does WordPress Heartbeat login not refresh the nonces?

Here’s an interesting experiment: Go to wordpress plugins listing page, notice the activate, deactivate links all have a nonce part in the request. In a second tab, log out of the site, and go back to plugin listing page. After awhile, the page realizes it’s not logged in, and pops up a log in screen. […]

admin-ajax.php + load-scripts.php hanging for minutes

My issue is that when I do a simple Admin Dashboard change, like updating a post or page, I sometimes wait up to 10 minutes for the request to finish. I have tried restarting the process and my server many times; the only way it works is if I wait all 10 minutes or so […]

Heartbeat API: How to access data already enqueued?

I’m having problems when trying to access data that I’ve queued using the Heartbeat API. I’m queuing data using wp.heartbeat.enqueue(). For example: var data = { my_key: ‘value’ }; wp.heartbeat.enqueue( ‘my_handle’, data, false ); Then later on in my script, I’d like to access the data I’ve queued. For example: $( document ).on( ‘click’, ‘#button’, […]

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 = “”; // 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 […]