WordPress Pulse? – Heartbeat API

With WordPress 3.6, there will be a new API – Heartbeat. On Ticket 23216 in Trac all discussions and information be gathered together. Because Heartbeat may also have influences for users, here are some words and clues. Heartbeat is introduced to various activities, such as Autosave, locks of articles and to handle logon and logoff notifications. In parallel, the API can also be used for own developments.

On the Pulse

The default heartbeat is beating with a pulse of 15 seconds – the work the processor must do and so it may be useful to change this value. It can not be changed arbitrarily. The pulse of heartbeat should be between 5 and 60 seconds. Following small Plugin changes to the maximum value of 60s.

The heartbeat API it is nice, id think a little bid more about this. A example: If you have 10 different plugins all with their own server polling. There are going to have 10 different hits to your server, every 15seconds. With the Heartbeat API, those polling requests are going to be bundled so you are only hitting your server 1 time every 15 seconds on default. Here comes the benefit of API.

 * Plugin Name: Set Heartbeat pulse
! defined( 'ABSPATH' ) and exit;
add_filter( 'heartbeat_settings', 'fb_heartbeat_settings' );
function fb_heartbeat_settings( $settings = array() ) {

	$settings['interval'] = 60;
	return $settings;

In parallel, you can also stop Heartbeat, disconnect the pulse of what the following small Plugin does. But, this is a hard way to deactivate the API and not easy to use. If you will stop the API, please test after deactivation.

 * Plugin Name: Remove Heartbeat pulse
! defined( 'ABSPATH' ) and exit;

remove_action( 'admin_init', 'wp_auth_check_load' );


The API was implemented in the core of WordPress, so that the console can give infos. Therefore the parameter wp.heartbeat.debug has to set on TRUE and the JavaScript can give informations.

if ( typeof console !== 'undefined' ) {
	// Show debug info
	wp.heartbeat.debug = true;


A simple example can find in Trac, where the Dashboard Widget for comments gets refreshed by the pulse – so you can see a refresh of the numbers every 15s, as new comments come in. The example shows the most important hooks and functions and there doesn’t need more explanation.

Further information, links to this topic


3 responses to “WordPress Pulse? – Heartbeat API”

  1. Zach Smith Avatar

    this is a great article!

  2. WTI Avatar

    Heartbeat..looks interesting… need to see it…let wordpress 3.6 come…

    Just on a lighter note,
    You misspelled HeartBeat in below line

    “Because Hearteat may also have influences for users”

  3. Frank Avatar

    Thanks a lot, now I fixed the misspelling.