* Tries to resume a single plugin.
* If a redirect was provided, we first ensure the plugin does not throw fatal
* The way it works is by setting the redirection to the error before trying to
* include the plugin file. If the plugin fails, then the redirection will not
* be overwritten with the success message and the plugin will not be resumed.
* @param string $plugin Single plugin to resume.
* @param string $redirect Optional. URL to redirect to. Default empty string.
* @return true|WP_Error True on success, false if `$plugin` was not paused,
function resume_plugin( $plugin, $redirect = '' ) {
* We'll override this later if the plugin could be resumed without
* creating a fatal error.
if ( ! empty( $redirect ) ) {
wp_create_nonce( 'plugin-resume-error_' . $plugin ),
// Load the plugin to test whether it throws a fatal error.
plugin_sandbox_scrape( $plugin );
list( $extension ) = explode( '/', $plugin );
$result = wp_paused_plugins()->delete( $extension );
'could_not_resume_plugin',
__( 'Could not resume the plugin.' )
* Renders an admin notice in case some plugins have been paused due to errors.
* @global string $pagenow The filename of the current screen.
* @global WP_Paused_Extensions_Storage $_paused_plugins
function paused_plugins_notice() {
if ( 'plugins.php' === $GLOBALS['pagenow'] ) {
if ( ! current_user_can( 'resume_plugins' ) ) {
if ( ! isset( $GLOBALS['_paused_plugins'] ) || empty( $GLOBALS['_paused_plugins'] ) ) {
'<strong>%s</strong><br>%s</p><p><a href="%s">%s</a>',
__( 'One or more plugins failed to load properly.' ),
__( 'You can find more details and make changes on the Plugins screen.' ),
esc_url( admin_url( 'plugins.php?plugin_status=paused' ) ),
__( 'Go to the Plugins screen' )
array( 'type' => 'error' )
* Renders an admin notice when a plugin was deactivated during an update.
* Displays an admin notice in case a plugin has been deactivated during an
* upgrade due to incompatibility with the current version of WordPress.
* @global string $pagenow The filename of the current screen.
* @global string $wp_version The WordPress version string.
function deactivated_plugins_notice() {
if ( 'plugins.php' === $GLOBALS['pagenow'] ) {
if ( ! current_user_can( 'activate_plugins' ) ) {
$blog_deactivated_plugins = get_option( 'wp_force_deactivated_plugins' );
$site_deactivated_plugins = array();
if ( false === $blog_deactivated_plugins ) {
// Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
update_option( 'wp_force_deactivated_plugins', array(), false );
$site_deactivated_plugins = get_site_option( 'wp_force_deactivated_plugins' );
if ( false === $site_deactivated_plugins ) {
// Option not in database, add an empty array to avoid extra DB queries on subsequent loads.
update_site_option( 'wp_force_deactivated_plugins', array() );
if ( empty( $blog_deactivated_plugins ) && empty( $site_deactivated_plugins ) ) {
// No deactivated plugins.
$deactivated_plugins = array_merge( $blog_deactivated_plugins, $site_deactivated_plugins );
foreach ( $deactivated_plugins as $plugin ) {
if ( ! empty( $plugin['version_compatible'] ) && ! empty( $plugin['version_deactivated'] ) ) {
/* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version, 4: Compatible plugin version. */
__( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s, please upgrade to %1$s %4$s or later.' ),
$plugin['version_deactivated'],
$plugin['version_compatible']
/* translators: 1: Name of deactivated plugin, 2: Plugin version deactivated, 3: Current WP version. */
__( '%1$s %2$s was deactivated due to incompatibility with WordPress %3$s.' ),
! empty( $plugin['version_deactivated'] ) ? $plugin['version_deactivated'] : '',
$plugin['version_compatible']
'<strong>%s</strong><br>%s</p><p><a href="%s">%s</a>',
/* translators: %s: Name of deactivated plugin. */
__( '%s plugin deactivated during WordPress upgrade.' ),
esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ),
__( 'Go to the Plugins screen' )
wp_admin_notice( $message, array( 'type' => 'warning' ) );
update_option( 'wp_force_deactivated_plugins', array(), false );
update_site_option( 'wp_force_deactivated_plugins', array() );