Over the years, I think the concept of a “drop-in” plugin has become overloaded. What once referred to a very specific type of functionality has evolved to mean a couple of things.

- One of the definitions retains the original definition which is you can place specific files into the
plugins
directory to replace core WordPress functionality. These are not standard WordPress plugins, though. For example, you’ll likely often see files likeadvanced-cache.php
orobject-cache.php
in theplugins
directory. These are the original type of ‘drop-ins’ when it comes to working with WordPress. - Another definition are plugins that aren’t specifically
mu-plugins
and they aren’t standalone plugins either. Instead, these are pieces of functionality that can be dropped into any other plugin and add functionality. Say you have two different plugins that are used by a lot of people and you want to give them the ability to add a feature without activating a new plugin. The way in which you can do this is have them drop a file into their existing plugin.
Here’s the challenge with the second definition: When you drop functionality of into the context of another plugin, that plugin may not be the only one already running the same code.
In other words, say you have a file called acme-functionality.php
that can be added to any plugin. If you drop acme-functionality.php
into multiple, activated plugins then you may end up with all kinds of results none of which are ideal. And why isn’t it ideal? Because you want the code to run only once.
What’s a way to check to see if a file is already running in the context of another plugin before running it’s code?
Continue reading