• Home
  • About Mitch
  • Speaking
  • Articles
  • Contact
  • Home
  • About Mitch
  • Speaking
  • Articles
  • Contact

Digital Strategist

WordPress Developer

Content Creator

Unapologetic Punk

Mitch Canter

  • X
  • Bluesky
  • GitHub
  • Twitch
  • YouTube
  • LinkedIn
WordPress

WordPress Heartbeat API: An Introduction

CMDR Mitchcraft

Reading time: 2 minutes

If I were to mention to a casual WordPress user something about the WordPress Heartbeat API, most would have never even heard of it, much less know that it’s been in WordPress since version 3.6(!) with very little fanfare.  But, as it turns out, the Heartbeat API has gained traction in the developer community, as people are starting to utilize it to create some amazing plugins and use cases for WordPress.  With this newfound popularity, I thought it would be great for us to dive into the WordPress Heartbeat API and see exactly what makes it… tick (see what I did there?)

What is the WordPress Heartbeat API

Heartbeat (not to be confused with Heartbleed) can be described, at its easiest, as the pulse of your blog.  Like a literal heart, your blog has a steady rhythm that it keeps running in the background as users are surfing the site.  At certain point, and if certain conditions are met, you can trigger actions onto the Heartbeat.  It’s a continuous conversation between a user’s browser and the server.  Unlike a lot of these technologies, the WordPress Heartbeat API can be accessed both by PHP _and_ by Javascript (and, conversely, Ajax!).  This brings a whole slew of options that we can hook into and do some really cool things.

Plugins Utilizing the WordPress Heartbeat API

Here’s a list of the ones I’ve found that work well on the front-end that utilize the WordPress Heartbeat API:

  • WP Heartbeat Notify – live notification of new blog posts to current site visitors.
  • WooCommerce Live Stock Notification – This plugin refreshes automatically WooCommerce products stock using the Heart Beart API.

…and that’s it.  Really.  There are quite a few that use Heartbeat on the back-end, but these are the ones that utilize it for “forward facing” items such as store stock and notifications.

To be honest, I feel like there’s a huge gap when it comes to the Heartbeat API that goes beyond lack of utilization – there seems to be a lack of understanding as to what it does.  Documentation exists, as do a few tutorials, but there’s an opportunity for someone savvy in WordPress, Javascript, and AJAX to come in and completely dominate using this technology.

Of real interest is the WP Heartbeat Notify, which is designed as a template for other plugins.

So, if you’re a developer and want to tinker with one of WordPress’ most underutilized features, I would look into the Heartbeat API.  There’s tons of potential there, but with such little integration there’s a golden opportunity for someone with the right idea to come along and crush it.

444444
  • WordPress 3.2: A First Look

    WordPress 3.2: A First Look

    Reading time: 2 minutes

    I’ve just downloaded a local copy of the brand spanking new WordPress 3.2beta1 – and let me be the first to say… it’s gorgeous. Simplicity is the motto here, and the UI design team has done an outstanding job in streamlining a lot of the elements down.  I mean, take a look at this new…

    WordPress
  • WordPress 3.3’s roadmap has been set… at least, it will be.

    WordPress 3.3’s roadmap has been set… at least, it will be.

    Reading time: 3 minutes

    Here’s the email I received of some of the proposed changes to WordPress – a lot of them look super exciting (goodbye IE7!) and plenty of them are just amazing.  What’s your favorite? User Feature: Media Uploader (azaozz) · Definitely v1: Integrate Plupload into dashboard. (GSoC project) · Probably v2: Improve our image manipulation and…

    WordPress