Plugins: When loading a plugin in a "sandbox" on activation, do it in a separate function.
This avoids accidentally overriding some variables in the scope of `activate_plugin()`, e.g. `$silent` or `$network_wide`. Plugins expecting to have access to `$network_wide` directly on inclusion should receive it as an argument of the activation hook callback instead, on any of these actions: * `activate_plugin` * `activate_{$plugin}` * `activated_plugin` Follow-up to [28644]. Props Mike_Cowobo, dd32, DrewAPicture, mensmaximus, SergeyBiryukov. Fixes #31104. Built from https://develop.svn.wordpress.org/trunk@50787 git-svn-id: http://core.svn.wordpress.org/trunk@50396 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
926cd0afee
commit
fe549286d5
|
@ -661,14 +661,8 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
|
|||
|
||||
ob_start();
|
||||
|
||||
if ( ! defined( 'WP_SANDBOX_SCRAPING' ) ) {
|
||||
define( 'WP_SANDBOX_SCRAPING', true );
|
||||
}
|
||||
|
||||
wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $plugin );
|
||||
$_wp_plugin_file = $plugin;
|
||||
include_once WP_PLUGIN_DIR . '/' . $plugin;
|
||||
$plugin = $_wp_plugin_file; // Avoid stomping of the $plugin variable in a plugin.
|
||||
// Load the plugin to test whether it throws any errors.
|
||||
plugin_sandbox_scrape( $plugin );
|
||||
|
||||
if ( ! $silent ) {
|
||||
/**
|
||||
|
@ -732,6 +726,7 @@ function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silen
|
|||
$output = ob_get_clean();
|
||||
return new WP_Error( 'unexpected_output', __( 'The plugin generated unexpected output.' ), $output );
|
||||
}
|
||||
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-alpha-50786';
|
||||
$wp_version = '5.8-alpha-50787';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue