Reading list Switch to dark mode

    WordPress Dropins

    Updated 22 February 2024

    WordPress dropins are likely a hidden feature of WordPress. Using dropins developers can replace, add, or enhance some advance core functionality of WordPress.
    Even though Dropin Plugin are available on WordPress plugins page but they are much different from regular plugins. And we can not manage dropin directly from Plugin page unlike a regular plugin.

    Dropin Plugin List

    There are a total of 12 dropins in WordPress. These are single php files, we create in wp-content folder to achieve our desired goals.

    Dropin FileInstallationLoading triggersDescription
    db.phpNormalOn site loadTo implement custom database in WordPress.
    db-error.phpNormalOn a DB ErrorTo show custom alert message a DB error.
    install.phpNormalOn WP InstallationTo run own script on installion.
    maintenance.phpNormalOn maintenance mode activationTo display custom maintenance message.
    object-cache.phpNormalOn site loadTo enable Redis object caching.
    advanced-cache.phpNormalIf WP_CACHE is set as trueTo enable advance caching in WordPress.
    php-error.phpNormalOn a PHP errorTo display custom PHP error message.
    fatal-error-handler.phpNormalOn a Fatal errorTo display custom message on PHP Fatal error.
    sunrise.phpMultisiteIf SUNRISE is set as trueTo execute custom script before a multi-site is loaded.
    blog-deleted.phpMultisiteOn deleting a blogTo display a custom message on a sub-site deleted.
    blog-inactive.phpMultisiteOn a blog deactivationTo display custom blog deactivation message.
    blog-suspended.phpMultisiteOn archiving or spamming a blogTo display custom message on marking a blog as Archived or spam.
    WordPress Dropin Plugins list

    Use Cases

    1. One of the most popular plugin Query Monitor uses db.php dropin to analyse the queries running a page load.
    2. Most of caching plugins like W3 Total Cache, LiteSpeed Cache and WP Fastest Cache use the dropin ‘advanced-cache.php’ to implement their own caching mechanism in WordPress.
    3. Redis Object Cache plugin uses the ‘object-cache.php’ dropin to implement object caching for speedup the php code execution.

    Using sunrise.php Dropin

    To use a dropin we need to put the Dropin plugin PHP file into our wp-content folder openly without any folder. WordPress loads these unique named files at different triggers dynamically as mentioned in above table.

    To achieve a custom domain mapping in a multisite network we have implemented the sunrise.php dropin.

    <?php
    /**
     * Domain mapping using sunrise dropins.
     *
     * We need to Map our domain from https://www.webkul.com/wordpress/ to https://www.webkul.com/web/wordpress/
     */
    
    $extra_domains = array(
    	'webkul.com/web/wordpress/' => 8, // 8 us the blog id of the subsite https://www.webkul.com/wordpress/
    );
    $server_uri    = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    if ( isset( $_SERVER['REQUEST_URI'] ) && array_key_exists( $server_uri, $extra_domains ) ) {
    	$mask_domain = $_SERVER['HTTP_HOST'] . '/web/wordpress/';
    
    	// Set globals.
    	$blog_id      = $extra_domains[ $mask_domain ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    	$current_blog = get_site( $blog_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    
    	// This should always be 1, unless you are running multiple WordPress networks.
    	$current_site = get_network( 1 ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
    
    	$origin_domain = $current_blog->domain . untrailingslashit( $current_blog->path );
    
    	add_filter(
    		'home_url',
    		function( $url ) use ( $mask_domain, $origin_domain ) {
    			return str_replace( $origin_domain, $mask_domain, $url );
    		}
    	);
    }

    Dropins in WP Dashboard

    WordPress shows all the implemented dropins under the Plugins page. However we can not manage them for activation, deactivation directly from the plugin page unlike a regular plugin.

    Searching for an experienced
    WordPress Company ?
    Find out More
    Dropins
    WodPress Dropin on Plugin page

    Myths

    Dropins are Harmful for WordPress Dropins are very less explained (or Hidden) feature of WordPress that is why there are some misconception among WordPress developers and users. One of them is Dropins are harmful for WordPress, they might break the site and slow down the performace.

    We have done so much R&D before writing this blog and din’t found any reason dropins are harmful for WordPres.

    Further Reading

    To Get all Dropins use function _get_dropins

    Enable Advance Caching Dropin

    Support

    For any kind of technical assistance, please raise a ticket or send us a mail at [email protected]

    You may also check out our exclusive WooCommerce Addons and can also explore our WooCommerce Development Services.

    . . .

    Leave a Comment

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


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home

    Table of Content