diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 9079a5df66..487df7f4f6 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -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(); }