Building a Pluggable Plugin

building a pluggable plugin

Building plugins is something that’s near and dear to our business. We build and sell our own premium plugins. And just about every project we take on has some sort of custom functionality that we roll into a plugin. Over the years, we’ve evolved our process to make it easier to extend or modify these plugins in specific situations. We like to call these kinds of plugins, Pluggable Plugins.

Using AdSanity as an example, our entire add-on architecture is built from this methodology. But this isn’t a concept that we conjured out of thin air. We’re utilizing actions and filters available through WordPress Core’s Plugin API. In fact, WordPress Core uses these APIs throughout its codebase. This allows the codebase to be modified without developers having to hard code changes into the software. This would make it complicated to update without losing your changes. You see, that’s the beauty of using actions and filters.

Doing an Action

Actions allow you or another developer to tap into the execution of your code at specific places to execute code. The Gravity Forms plugin uses actions extensively, so I’ll use their code as an example.

Every time a form is submitted, the “gform_after_submission” action is triggered. Along with that action being triggered, the action passes along some data that I can use in my own callback. That data is the entry object and form object. Let’s say I wanted to send the data that was submitted to a third party Customer Relationship Management (CRM) system. I could write my own functionality and hook it into the action provided by Gravity Forms. This would fire off an API call to my CRM of choice. Additionally, since I have access to the data submitted in the entry object, I can write in conditional logic to process different submissions in different ways. The possibilities are endless!

Applying a Filter

With filters you are changing data. Functionally, the code to implement a filter is very similar to action. But the use case is definitely different. Actions allow you to execute some new code. Filters change data to achieve a different result. Beaver Builder is a plugin that takes advantage of filters in a number of different ways.

For example, we wanted to be able to schedule certain modules to publish and sunset on particular days. So we built a user interface to select a publish date and a sunset date within each module. The developers at Beaver Builder built a filter to add sections to each module’s settings screen, “fl_builder_register_settings_form”. Similar to how actions work, data can be passed on through filters. The list of tabs for the module and the ID of the element being shown are passed through this filter. We received the tab data, add our tabs, and then send the data back into the Beaver Builder machine.

Go Out and Make Pluggable Plugins

WordPress Core makes use of actions and filters throughout its codebase. So by no means do you have to be using plugins to utilize the Plugins API. But if you build plugins for you or for your clients, you owe it to yourself to utilize the Plugins API in your own code. This will make your projects more versatile both for you and anyone else working on your codebase.

Please note: Links to external companies may be affiliate links. If you use our links, we may earn a small commission.

Written by the Team at Pixel Jar

We hope you got something useful out of that post. If you'd like to read more we have an active blog with topics across the spectrum of website development. If you're researching information for a project we'd love to talk to you about it.

limited website design templates

Limited Website Design Templates

This is the third part of a five part series dealing with custom web design. In this part we’re going to focus on limited website design templates on a project. Focusing on What’s Important Sometime a Full Design overshoots the target. With some projects, only key designs need to be developed and the rest of…
Read More
pixel jar website redesign

The New Improved Pixel Jar – Our Website Redesign

Pixel Jar is always really busy working on client projects, we haven’t had a good opportunity to focus on our own website redesign. As a web development agency we knew it was time to make some changes. We were suffering from the “cobbler’s kids” syndrome – we had no shoes. We started talking about the…
Read More

How Can We Help You?

We want to build your next project.

Connect with Pixel Jar

Our Community

Subscribe to learn more about the goings on at Pixel Jar.
  • Note: Your email will be added to our CRM and be used to receive emails from Pixel Jar. You can unsubscribe at any time.

  • This field is for validation purposes and should be left unchanged.