WordPress drop-in plugins are a hidden feature of WordPress used to replace, add, or enhance a limited set of advanced core WordPress features. They are only created by developers or other regular plugins. WordPress drop-in plugins are not regular plugins.
Drop-in plugins are special files that each have a singular and unique purpose within WordPress. For example, you can use a drop-in plugin to replace the core WordPress db.php file and it’s wpdb
class. You could also use the advanced-cache.php WordPress drop-in to add “Advanced Caching” to your website (how the caching works is entirely up to the developer, there are no training wheels with drop-ins). Basically each drop-in has its own purpose and each drop-in works in a different way.
Again, to be clear. Even though drop-in plugins appear on the WordPress plugins page, drop-in plugins are not like regular WordPress plugins that you install through the WordPress admin. Nor are they anything like must-use plugins.
Dare To Code
Get the tips, links, and tricks on full-stack PHP development in your inbox from me: Kevin Dees.
"*" indicates required fields
All WordPress Drop-In Plugins
File | Description | Loaded | Type |
---|---|---|---|
advanced-cache.php | Advanced caching plugin. | If WP_CACHE is true | Normal |
db.php | Custom database class. | on load | Normal |
db-error.php | Custom database error message. | on error | Normal |
install.php | Custom installation script. | on install | Normal |
maintenance.php | Custom maintenance message. | on maintenance | Normal |
object-cache.php | External object cache. | on load | Normal |
php-error.php | Custom PHP error message. | on error | Normal |
fatal-error-handler.php | Custom PHP fatal error handler. | on error | Normal |
sunrise.php | Executed before Multisite is loaded. | If SUNRISE is true | Multisite |
blog-deleted.php | Custom site deleted message. | on deleted blog | Multisite |
blog-inactive.php | Custom site inactive message. | on inactive blog | Multisite |
blog-suspended.php | Custom site suspended message. | on archived or spammed blog | Multisite |
Frequently Asked Questions About WordPress Drop-in Plugins
When were drop-in plugins added to WordPress source? Drop-in plugins were added to WordPress in version 3.0.
When do drop-in plugins get loaded? Most drop-in plugins run before any other regular plugin or MU plugin. The table above also demonstrates the run time of each drop-in.
Where can I see my active WordPress drop-in plugins? Drop-in plugins can be seen in the WordPress admin on the plugins page under Plugins | Drop-in
.
How can I activate, deactivate, or uninstall drop-in plugins from the WordPress plugins dashboard? You can not manage drop-in plugins from the WordPress admin, drop-ins can only be managed on your server.
How to Get Started with WordPress Drop-in Plugins
If you wanted to start using drop-in plugins you will not find any organized documentation on wordpress.org about them. This is not the answer you were hoping to hear but it is true.
To get started you will need to look through the WordPress source code and start searching Google. Drop-ins certainly are a hidden feature of WordPress for advanced development.
However, there are a few getting started pointers I can offer if you want to dig deeper.
- Browse through the WordPress core and you will find the _get_dropins() function that lists all of the available drop-ins you could install.
- To install a drop-in plugin you simply add it directly in the
wp-content
folder. - When researching a drop-in plugin be specific. Search for the single file that is relevant to your needs (see the list of files below).
- Find other regular plugins, like WP Rocket, that install drop-ins and see how they use them.
Below I’ve listed the contents of the _get_dropins()
function.
/**
* Returns drop-ins that WordPress uses.
*
* Includes Multisite drop-ins only when is_multisite()
*
* @since 3.0.0
* @return array Key is file name. The value is an array, with the first value the
* purpose of the drop-in and the second value the name of the constant that must be
* true for the drop-in to be used, or true if no constant is required.
*/
function _get_dropins() {
$dropins = array(
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
'db.php' => array( __( 'Custom database class.' ), true ), // auto on load
'db-error.php' => array( __( 'Custom database error message.' ), true ), // auto on error
'install.php' => array( __( 'Custom installation script.' ), true ), // auto on installation
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // auto on maintenance
'object-cache.php' => array( __( 'External object cache.' ), true ), // auto on load
'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // auto on error
'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // auto on error
);
if ( is_multisite() ) {
$dropins['sunrise.php'] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
$dropins['blog-deleted.php'] = array( __( 'Custom site deleted message.' ), true ); // auto on deleted blog
$dropins['blog-inactive.php'] = array( __( 'Custom site inactive message.' ), true ); // auto on inactive blog
$dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // auto on archived or spammed blog
}
return $dropins;
}
I wish you all the best and hope this article helps you with your WordPress drop-ins plugin journey.
Leave a Reply