WP-Mix

A fresh mix of code snippets and tutorials

Must-Use (mu) Plugins & Drop-Ins

Two little interesting tidbits about WordPress: must-use (mu) plugins and drop-ins. Do you know them?

Must use plugins

Must-use or “mu” plugins are plugins that are loaded automatically regardless of how anything else is configured. They don’t even need the usual plugin headers, just PHP works fine. mu plugins must be placed in the directory: /wp-content/mu-plugins/. Note that two constants are available: WPMU_PLUGIN_DIR and WPMU_PLUGIN_URL.

Drop Ins

The other interesting thing about WordPress is the “drop in”. Drop-ins are used to add or replace default WordPress functionality. So for example, if a file named db.php exists in the /wp-content/ directory, it will be processed as a custom database class. All drop-in files are placed in the wp-content directory by default. To use a different directory you may specify it using the WP_CONTENT_DIR variable.

Drop-ins are a scattered lot of useful scripts for a variety of tasks:

File Type of Plugin Loaded Context
advanced-cache.php Advanced caching plugin. on WP_CACHE value Single
db.php Custom database class always Single
db-error.php Custom database error message on error Single
install.php Custom install script on install Single
maintenance.php Custom maintenance message on maintenance Single
object-cache.php External object cache always Single
sunrise.php Executed before Multisite is loaded on SUNRISE value Multi
blog-deleted.php Custom blog deleted message on deleted blog Multi
blog-inactive.php Custom blog inactive message on inactive blog Multi
blog-suspended.php Custom blog suspended message on archived or spammed blog Multi

Source: Data taken from global function _get_dropins() in wp-admin/includes/plugin.php. Table data grabbed from here.

Related

Learn more

Digging Into WordPressWordPress Themes In DepthWizard’s SQL Recipes for WordPress