Micro Plugins In WordPress

I have been thinking about the concept of micro plugins for a while now. A few months ago, I was having a discussion with some folks from my local WordPress meetup group and we got on the topic of the best way to handle modifying a theme’s functions.php file.

When we really started digging into it, it’s interesting to approach the topic from a plugin perspective. I think it makes a really strong case for how site owners and developers can improve how they add code snippets to their site without running into errors.

Starting in version 5.2, WordPress handles PHP errors with a recovery mode that prevents the “white screen of death” and helps site owners debug what caused the issue. Most of these issues present themselves after a user tries to modify their theme and incorrectly copy/pastes something from Stack Overflow (as I do on a daily basis).

Instead of adding code snippets to the functions.php file, they should be made into stand alone plugins.

I like to refer to these kinds of plugins as “micro plugins”.

Micro plugins should be extremely precise in solving a single issue. When you use micro plugins to add code snippets to WordPress, your site has better encapsulation and changes in functionality are easier to manage.

Encapsulation Helps Keep Code Separate

When working with WordPress, it’s usually a good idea to keep things separate. When plugins operate in their own space, it’s easier to swap them out.

Most plugins do this through alternate database tables, specific prefixes for function names, and name-spacing. Unfortunately, I have seen too many plugins that don’t separate themselves well enough. So it’s very difficult to debug when things break.

Micro Plugins Reduce Complexity

A plugin that does a single job helps reduce the complexity of your site because you can enable & disable a single feature without worry about what else the plugin handles.

Too often I find that plugins in the WordPress repository try to do too many things. When you look for specific functionality, sometimes you’re limited by the selection. I have been guilty of downloading a bloated membership plugin because I needed a single piece of functionality. I want to keep others from doing the same.

Additionally, if you need to hire someone to help you debug an issue, usually they’ll start the process by deactivating plugins to see if there’s a conflict.

I’ve supported hundreds of WordPress sites in the past and I always hated trying to figure out what a plugin did solely by its title. By naming a micro plugin specifically, you help save your hired help some time and frustration.

Proof of Concept

Here’s an example of a micro plugin I made the other day.

Lately, I’ve been migrating some sites I manage to a new server. So I wanted to prevent everyone except logged in users from seeing the site until it had been fully transferred.

I added a new file maintenance-mode.php file to the wp-content/plugins directory of the site I was working on. Then added the specific functionality I needed (a single function):

A micro plugin in the WordPress admin of a site
My Maintenance Mode micro plugin listed in the plugin list of the admin.

Now I have an extremely specific plugin that gives me the functionality I need, without extra features I don’t. And I can easily activate/deactivate it as I need to.

Plugins were originally created to extend the functionality of WordPress. I believe micro plugins are at the core of that purpose. They provide precise solutions to problems—nothing more, nothing less.

2 responses to “Micro Plugins In WordPress”

  1. Michael Beckwith Avatar

    it’s how I typically added customizations needed for the company you and I both worked at together.

  2. Niedoszły Bibliotekarz Avatar

    I like the concept, thank you very much