Plugin Development

WordPress Dropins

To extend the functionality of WordPress most people have only heard of the use of plugins. Not many people have heard of the term Dropins.

WordPress has it's core functionality which can be added to by the use of plugins which take advantage of multiple WordPress hooks and actions, but it also allows you to replace functionality with the use of Dropin files.

Unlike a plugin the Dropin file will not need to be activated and will become activate when it is placed in the wp-content folder. This folder will by default be at the root of your WordPress install, but can be defined by changing the constant variable WP_CONTENT_DIR.

// Custom content directory
define( 'WP_CONTENT_DIR',  dirname( __FILE__ ) . '/wp-content' );
define( 'WP_CONTENT_URL',  'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );

An example of how WordPress will include these Dropin files can be seen in the WordPress core code, here is an example of displaying the maintenance.php as you can see it uses the constant WP_CONTENT_DIR.

if ( file_exists( WP_CONTENT_DIR . '/maintenance.php' ) ) {
	require_once( WP_CONTENT_DIR . '/maintenance.php' );
	die();
}

When you place your Dropin files in the wp-content folder you can see this from the plugin maintenance screen /wp-admin/plugins.php?plugin_status=dropins.

dropins

To get a list of available dropin's there is a function in /wp-admin/includes/plugin.php called _get_dropins(), this will return the following list of dropin's.

Single Site Install

  • advanced-cache.php - Advanced caching plugin. Allows you to replace the caching functionality of your WordPress site. Activated by defining a constant variable WP_CACHE in the wp-config.php file.
  • db.php - Custom database class. Used to create you own database class. Activated on load.
  • db-error.php - Custom database error message. Used to display your own custom database error message. Activated on load.
  • install.php - Custom install script. Used to customise your own WordPress install script. Activated on load.
  • maintenance.php - Custom maintenance message. Used to create your own WordPress custom message. Activated on load.
  • object-cache.php - External object cache. Used to create your own object caching class. Activated on load.

Additional Multisite Dropin's

  • sunrise.php - Executed before Multisite is loaded. Used to change the way multisite functionality is loaded. Activated by placing a constant variable in wp-config.php file.
  • blog-deleted.php - Custom site deleted message. Activated on load.
  • blog-inactive.php - Custom site inactive message. Activated on load.
  • blog-suspended.php - Custom site suspended message. Activated on load.
Back to top

Learn how to code with Treehouse

  • Learn projects with access to 1000+ videos
  • Practice live with our Code Challenge Engine
  • Get help in our members-only forums

Start with a 7 day free trial