The marketplace for Premium Themes — & — Templates

146,466 People using Mojo
353,270 Downloaded items
2157 Marketplace items
2 Green Monsters

The Mojo Blog

Blog | WordPress is Alive

WordPress is Alive

Posted By MikeHansenMe

1 Comment

Say hello to the second WordPress Wednesday from MOJO. Once again we are highlighting the coming features for version 3.6 coming out very soon. For this post we wanted to highlight the new Heartbeat API.

The Heartbeat API is an new feature introduced in WordPress 3.6. It was introduced to help deliver login expiration notifications, trigger autosaves and post locking.

To quote Andrew Ozz in the original Trac ticket #23216

“The purpose of this API is to simulate bidirectional connection between the browser and the server. Initially it will be used for autosave, post locking and log-in expiration warning while a user is writing or editing.

The idea is to have a relatively simple API that sends XHR requests to the server every 15 seconds and triggers events (or callbacks) on receiving data. Other components would be able to “hitch a ride” or get notified about another user’s activities.

In the future this can be used to block simultaneous editing of widgets and menus or any other tasks that require regular updates from the server.”

So the plan for this now is to focus on the features mentioned, but as noted in the future there are other possibilities with this API.  I can’t wait to see what plugin and theme sellers can come up with in the future leveraging this API.

You can hook into this by using the following actions or filters.

  • heartbeat_nopriv_tick(action)
  • heartbeat_nopriv_send(filter)
  • heartbeat_nopriv_receive(filter)
  • heartbeat_tick(action)
  • heartbeat_send(filter)
  • heartbeat_receive(filter)
  • heartbeat_settings(filter)

Here is a few screen shots for what it has been used for already with post locking.


For Theme Developers

Over here at MOJO we have been discussing some cool ideas to use the heartbeat in your themes. Here are some initial ideas:

  • Comments on posts auto populate as someone is viewing comments.
  • Blog posts auto populate as you are viewing all posts.
  • Forums such as bbPress can instantly become interactive like a chat room.

So huge props to Andrew Ozz, Mike Schroder and everyone else who contributed to this feature.

1 Responses

You must be logged in to post a comment.