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.

wordpress website performance

At 120,000 Miles, How Does Your WordPress Website Hold Up?

A friend of mine once told me how he often compares having a WordPress website to owning a car. At the time I didn’t think much about it. Reflecting back on it, I think the comparison makes a lot of sense. Let me tell you why. The Make, Model, and Color of Your Vehicle Surely…
Read More
ultimate addons for beaver builder

Ultimate Addons for Beaver Builder

Out of the box, Beaver Builder has a lot of options available to build what you need. The Ultimate Addons for Beaver Builder turns this up to “11.” Similar to The Powerpack Beaver Addons, Ultimate Addons for Beaver Builder extends the key capabilities of Beaver Builder by providing you with a lot of pre-made and…
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.