DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • WireMock: The Ridiculously Easy Way (For Spring Microservices)
  • How to Optimize CPU Performance Through Isolation and System Tuning
  • HashMap Performance Improvements in Java 8
  • Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices

WordPress Dropins Extend the Functionality of WordPress

Paul Underwood user avatar by
Paul Underwood
·
Oct. 04, 13 · Interview
Like (0)
Save
Tweet
Share
3.51K Views

Join the DZone community and get the full member experience.

Join For Free

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 its core functionality, which can be added to by the use of plugins that 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 activated 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 Dropins, there is a function in /wp-admin/includes/plugin.php called _get_dropins(). This will return the following list of Dropins.

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 Dropins

  • 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.
WordPress

Published at DZone with permission of Paul Underwood, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • WireMock: The Ridiculously Easy Way (For Spring Microservices)
  • How to Optimize CPU Performance Through Isolation and System Tuning
  • HashMap Performance Improvements in Java 8
  • Integration Testing Tutorial: A Comprehensive Guide With Examples And Best Practices

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: