Drop-ins

WordPress drop-ins are used to enhance or replace a set of WordPress core functionalities. WordPress provides following drop-ins. See _get_dropins().

  • advanced-cache.php
  • db.php
  • db-error.php
  • install.php
  • maintenance.php
  • object-cache.php
  • php-error.php
  • fatal-error-handler.php

Following drop-ins are only available for multisite.

  • sunrise.php
  • blog-deleted.php
  • blog-inactive.php
  • blog-suspended.php

Drop-ins are not regular plugins. You cannot install, activate, deactivate, or delete from WordPress admin. If any drop-in exists on your site, you can see that on WordPress admin plugins page under “Drop-in” filter. Drop-ins can be added by either developers or by external plugins in “wp-content” directory or directory set by “WP_CONTENT_DIR” constant.

Let’s learn about each drop-in.


advanced-cache.php

Advanced caching plugin drop-in will load when “WP_CACHE” constant is set to true and enable_loading_advanced_cache_dropin filter returns true.

Note: The above filter runs before it can be used by plugins. It is designed for non-web run-times. If false is returned, advanced-cache.php will never be loaded.

You can use this drop-in to implement cache functionality. It’s up to you how you want to implement cache functionality.

db.php

Using this drop-in, you can add custom class to interact with database. You can replace wpdb class with your own by setting the $wpdb global variable in this drop-in file to your class. The wpdb class will still be included, so you can extend it or simply use your own.

See how Query Monitor plugin uses db.php drop-in to provide additional features for developers.

db-error.php

This drop-in is used to display custom database error messages instead of displaying the WordPress database errors. You can customize database error messages to match the design of your site. Also, you can send email whenever a database error happens.

install.php

Using this drop-in, you can add custom installation script. In this drop-in, you can override WordPress functions available in wp-admin/includes/upgrade.php file. For example, wp_install() function you can override.

maintenance.php

This drop-in is used to display custom maintenance messages. You can customize it and design it as per the site design.

object-cache.php

This drop-in is used for external object cache. If this drop-in exists, then WordPress core WP_Object_Cache class will not load and this class will be implemented in this drop-in.

enable_loading_object_cache_dropin – this filter is used to enable/disable loading of the object-cache.php drop-in. By default, it returns true so drop-in will load. This filter runs before it can be used by plugins. It is designed for non-web runtimes. If false is returned, object-cache.php will never be loaded.

You will learn more about object cache in the Object Cache API topic.

php-error.php and fatal-error-handler.php

WordPress introduced a fatal error recovery mode in 5.2 version. Read this article for more details.

sunrise.php

If SUNRISE constant is set to true, then this drop-in is executed before Multisite is loaded. This drop-in loads early in the WordPress loading sequence, before mu-plugins, any active plugins, and the active theme. Because of this, what can be done in sunrise.php is limited, and confined to executing pure PHP to set constants that override WordPress Core behavior.

blog-deleted.php, blog-inactive.php and blog-suspended.php

blog-deleted.php – This drop-in is used to display customized site deleted message.

blog-inactive.phpThis drop-in is used to display customized message when the site is inactive.

blog-suspended.phpThis drop-in is used to display customized message when the site is suspended or archived.

References