Opened 3 weeks ago
Last modified 3 weeks ago
#64665 new feature request
Add mu-plugins loading filter
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Bootstrap/Load | Keywords: | has-patch |
| Focuses: | Cc: |
Description
There are some occasions where having the ability to filter the mu-plugins being loaded would be useful.
Regular plugins and network activated plugins can be filtered through option filters, but the mu-plugins can't, as no option exists.
In my case, I'd like to avoid loading any plugin content via a sunrise.php file, before a wp-env environment is fully configured, but without having to have to start the environment without mappings and then add them in.
The attached PR adds filters to wp_get_mu_plugins(), wp_get_active_network_plugins(), wp_get_active_and_valid_plugins(), and wp_ get_active_and_valid_themes() for good measure.
Change History (3)
This ticket was mentioned in PR #10962 on WordPress/wordpress-develop by @dd32.
3 weeks ago
#1
- Keywords has-patch added
#2
@
3 weeks ago
Some previous related discussion: #34936
First note is that documentation similar to what is on functions such as enable_wp_debug_mode_checks and enable_loading_advanced_cache_dropin explaining that these filters run before plugins are loaded would be helpful.
For the regular plugins and network activated plugins, I think filtering on the option makes more sense for two reasons:
- When removing plugins, you avoid the wasted calls to things such as
validate_file. - When adding plugins, you get the benefit of things such as the network_plugins collision prevention and recovery mode.
In my case, I'd like to avoid loading any plugin content via a sunrise.php file, before a wp-env environment is fully configured, but without having to have to start the environment without mappings and then add them in.
To avoid loading any mu-plugins, you can always define WPMU_PLUGIN_DIR to a non directory in your sunrise.php. But this is hacky and an actual extension point makes better sense.
@SergeyBiryukov commented on PR #10962:
3 weeks ago
#3
Nitpicking: is there a reason the wp_get_active_network_plugins filter has the wp_ prefix, while the others don't?
Trac ticket: https://core.trac.wordpress.org/ticket/64665
## Use of AI Tools