Skip to content

ENGINEERING LEADER

WordPress Developer

Speaker

Unapologetic Punk

Mitch Canter

  • Threads
  • Instagram
  • Bluesky
  • LinkedIn
  • GitHub
  • YouTube
WordPress

WordPress Heartbeat API: An Introduction

Mitch Canter

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
  • An Intro to WordPress 3.0 – Navigational Menus

    An Intro to WordPress 3.0 – Navigational Menus

    Reading time: 2 minutes

    WordPress 3.0 has plenty of new features, and all of them are worth mentioning and diving deeper into.  Over the next few days I’ll be diving into the finer features of the newest incarnation of the WordPress platform.  Everything from Custom Post Types and Taxonomies to navigational menus and all of the custom functions you…

    WordPress
  • BlogInfo – One Tag with a Whole Lot of Awesomeness

    BlogInfo – One Tag with a Whole Lot of Awesomeness

    Reading time: 1 minute

    One of the most versitile tags in my arsenal that WordPress gives me is a fun little tag called <?php bloginfo(); ?>.  By itself, it’s not much fun, but when you add in a variable, it can tell you anything you need to know about your blog.  Like what, you ask? name description admin_email url…

    WordPress
  • Home
  • About
  • Speaking
  • Articles
  • Contact