Make WordPress Core

Opened 20 months ago

Last modified 2 months ago

#22631 new enhancement

Allow change of dropins folder

Reported by: bungeshea Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 3.5
Component: Bootstrap/Load Keywords:
Focuses: Cc:


Dropins are stored in the wp-content directory. Currently there is no way to alter this (short of editing core code).

The get_dropins() function does not utilize filters or predefined constants in any way.

Probably the best method here would be to define WP_DROPINS_DIR constant in /wp-includes/default-constants.php that can be overridden in wp-config.php.

Attachments (1)

dropins-dir-constant.21573.diff (11.5 KB) - added by bungeshea 6 months ago.
Use WP_DROPINS_DIR constant instead of WP_CONTENT_DIR

Download all attachments as: .zip

Change History (7)

comment:1 bungeshea20 months ago

For example, you may want the dropins directory to be wp-content/dropins

comment:2 toscho20 months ago

  • Cc info@… added

comment:3 nacin6 months ago

  • Component changed from General to Bootstrap/Load

bungeshea6 months ago

Use WP_DROPINS_DIR constant instead of WP_CONTENT_DIR

comment:4 jeremyfelt5 months ago

Thanks for the ticket and patch @bugeshea!

I'm personally a fan of this. It would be great to have a directory to separate out things that exist in a different frame of mind from plugins and themes.

I do wonder about backward compatibility. I know there are several plugins—some very popular—that create dropins for database connections or object caching when installed and place them automatically. Without looking, my guess is that they toss these to WP_CONTENT_DIR because that's how it has been.

Would it be safe to make a change like this in core?

comment:5 knutsp5 months ago

  • Severity changed from normal to minor

Not safe, unless both WP_CONTENT_DIR and WP_DROPINS_DIR are checked for dropin files across some major versions. WP_DROPINS_DIR must have precedence (for the same dropin file). If a dropin is found in WP_CONTENT_DIR then a deprecated warning should be issued, at least in the major version following the version this is implemented. Two versions or more later the backwards compatibility may be removed.

Occasionally, like when (just before) plugins activated, a cleanup routine may check for dropin files that exist in both folders and delete the one in WP_CONTENT_DIR (which is then unused).

When WP_DROPINS_DIR is undefined it should be set to WP_CONTENT_DIR . '/dropins' at load time.

comment:6 bungeshea2 months ago

It looks like implementing the changes suggested by @knutsp would require the introduction of at least two new functions:

load_dropin(), which would take a dropin name (or filename) as a parameter and look for the file in the WP_DROPINS_DIR followed by the WP_CONTENT_DIR, and then load it if found. A deprecated notice would be issued if the dropin is loaded from WP_CONTENT_DIR.

cleanup_dropins(), which would be hooked to the appropriate actions such as activate_plugin and clean up unused dropins from WP_CONTENT_DIR.

In which file would it be appropriate to introduce these functions?

Last edited 2 months ago by bungeshea (previous) (diff)
Note: See TracTickets for help on using tickets.