• 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
  • Twitch Conditional – A WordPress Plugin for Twitch Streamers

    Twitch Conditional – A WordPress Plugin for Twitch Streamers

    Reading time: 2 minutes

    I love Twitch. I actually spend my work day with one browser dedicated to Twitch, and subscribe to MrHappy’s daily Stream. So when rumors surfaced a few years ago their API, of course I wanted a way to interface with that API. In doing research, I realized that a lot of streamers don’t have real…

    WordPress
  • WordPress.com Announces Premium Themes

    WordPress.com Announces Premium Themes

    Reading time: 1 minute

    News from the WordPress.com blog – premium themes are becoming available to WordPress.com subscribers. I am proud to introduce the very first two premium themes on WordPress.com: Headlines and Shelf. Headlines is a sophisticated magazine theme from WooThemes with a Featured Post slideshow, multiple menus, and 15 beautiful color schemes. It’s available now for a…

    WordPress