Categories
PHP WordPress

What are WordPress Drop-in Plugins?

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.

All WordPress Drop-In Plugins

FileDescriptionLoadedType
advanced-cache.phpAdvanced caching plugin.If WP_CACHE is trueNormal
db.phpCustom database class.on loadNormal
db-error.phpCustom database error message.on errorNormal
install.phpCustom installation script.on installNormal
maintenance.phpCustom maintenance message.on maintenanceNormal
object-cache.phpExternal object cache.on loadNormal
php-error.phpCustom PHP error message.on errorNormal
fatal-error-handler.phpCustom PHP fatal error handler.on errorNormal
sunrise.phpExecuted before Multisite is loaded.If SUNRISE is trueMultisite
blog-deleted.phpCustom site deleted message.on deleted blogMultisite
blog-inactive.phpCustom site inactive message.on inactive blogMultisite
blog-suspended.phpCustom site suspended message.on archived or spammed blogMultisite

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.

  1. Browse through the WordPress core and you will find the _get_dropins() function that lists all of the available drop-ins you could install.
  2. To install a drop-in plugin you simply add it directly in the wp-content folder.
  3. 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).
  4. 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

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.