wppaste
WordPress

deactivated_plugins_notice()

Since
5.8.0
Source
wp-admin/includes/plugin.php:2599
Renders an admin notice when a plugin was deactivated during an update.

Description

Displays an admin notice in case a plugin has been deactivated during an upgrade due to incompatibility with the current version of WordPress.

Compatibility

WordPress
since 5.8.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Performance profile

How much work a call to deactivated_plugins_notice() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Heavy

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
4–57

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 131.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • optionoption read or writeget_option()called directly
  • hookthird-party callbacksapply_filters()one call below deactivated_plugins_notice()
  • cacheobject cachewp_cache_get()one call below deactivated_plugins_notice()
  • serializeserialisationmaybe_unserialize()one call below deactivated_plugins_notice()

Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 20 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost deactivated_plugins_notice() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always4none
!current_user_can()8current_user_can()
current_user_can() && $blog_deactivated_plugins !== false && !is_multisite() && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins)22current_user_can(), get_option(), is_multisite()
current_user_can() && $blog_deactivated_plugins === false && !is_multisite() && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins)27current_user_can(), get_option(), update_option(), is_multisite()
current_user_can() && $blog_deactivated_plugins !== false && is_multisite() && $site_deactivated_plugins !== false && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins)28current_user_can(), get_option(), is_multisite(), get_site_option()
current_user_can() && $blog_deactivated_plugins !== false && is_multisite() && $site_deactivated_plugins === false && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins)32current_user_can(), get_option(), is_multisite(), get_site_option(), update_site_option()
current_user_can() && $blog_deactivated_plugins === false && is_multisite() && $site_deactivated_plugins !== false && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins)33current_user_can(), get_option(), update_option(), is_multisite(), get_site_option()
current_user_can() && $blog_deactivated_plugins !== false && !is_multisite()35–38current_user_can(), get_option(), is_multisite(), array_merge(), update_option(), is_multisite()
current_user_can() && $blog_deactivated_plugins === false && is_multisite() && $site_deactivated_plugins === false && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins)37current_user_can(), get_option(), update_option(), is_multisite(), get_site_option(), update_site_option()
current_user_can() && $blog_deactivated_plugins !== false39–42current_user_can(), get_option(), is_multisite(), array_merge(), update_option(), is_multisite(), update_site_option()
current_user_can() && $blog_deactivated_plugins === false && !is_multisite()40–43current_user_can(), get_option(), update_option(), is_multisite(), array_merge(), update_option(), is_multisite()
current_user_can() && $blog_deactivated_plugins !== false && $site_deactivated_plugins !== false41–44current_user_can(), get_option(), is_multisite(), get_site_option(), array_merge(), update_option(), is_multisite()
8 further outcomes, up to 57 instructions
current_user_can() && $blog_deactivated_plugins === false44–47current_user_can(), get_option(), update_option(), is_multisite(), array_merge(), update_option(), is_multisite(), update_site_option()
current_user_can() && $blog_deactivated_plugins !== false && is_multisite() && $site_deactivated_plugins !== false45–48current_user_can(), get_option(), is_multisite(), get_site_option(), array_merge(), update_option(), is_multisite(), update_site_option()
current_user_can() && $blog_deactivated_plugins !== false && $site_deactivated_plugins === false45–48current_user_can(), get_option(), is_multisite(), get_site_option(), update_site_option(), array_merge(), update_option(), is_multisite()
current_user_can() && $blog_deactivated_plugins === false && $site_deactivated_plugins !== false46–49current_user_can(), get_option(), update_option(), is_multisite(), get_site_option(), array_merge(), update_option(), is_multisite()
current_user_can() && $blog_deactivated_plugins !== false && is_multisite() && $site_deactivated_plugins === false49–52current_user_can(), get_option(), is_multisite(), get_site_option(), update_site_option(), array_merge(), update_option(), is_multisite(), update_site_option()
current_user_can() && $blog_deactivated_plugins === false && is_multisite() && $site_deactivated_plugins !== false50–53current_user_can(), get_option(), update_option(), is_multisite(), get_site_option(), array_merge(), update_option(), is_multisite(), update_site_option()
current_user_can() && $blog_deactivated_plugins === false && $site_deactivated_plugins === false50–53current_user_can(), get_option(), update_option(), is_multisite(), get_site_option(), update_site_option(), array_merge(), update_option(), is_multisite()
current_user_can() && $blog_deactivated_plugins === false && is_multisite() && $site_deactivated_plugins === false54–57current_user_can(), get_option(), update_option(), is_multisite(), get_site_option(), update_site_option(), array_merge(), update_option(), is_multisite(), update_site_option()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev1314–5713
8.51314–5713
8.41314–57132 more instructions than PHP 8.3
8.31294–5713
8.21294–5713
8.11294–57134 fewer instructions than PHP 7.4
7.41335–5813

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 10

Source code

function deactivated_plugins_notice() {	if ( 'plugins.php' === $GLOBALS['pagenow'] ) {		return;	} 	if ( ! current_user_can( 'activate_plugins' ) ) {		return;	} 	$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 );	} 	if ( is_multisite() ) {		$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.		return;	} 	$deactivated_plugins = array_merge( $blog_deactivated_plugins, $site_deactivated_plugins ); 	foreach ( $deactivated_plugins as $plugin ) {		if ( ! empty( $plugin['version_compatible'] ) && ! empty( $plugin['version_deactivated'] ) ) {			$explanation = sprintf(				/* 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['plugin_name'],				$plugin['version_deactivated'],				$GLOBALS['wp_version'],				$plugin['version_compatible']			);		} else {			$explanation = sprintf(				/* 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.' ),				$plugin['plugin_name'],				! empty( $plugin['version_deactivated'] ) ? $plugin['version_deactivated'] : '',				$GLOBALS['wp_version'],				$plugin['version_compatible']			);		} 		$message = sprintf(			'<strong>%s</strong><br>%s</p><p><a href="%s">%s</a>',			sprintf(				/* translators: %s: Name of deactivated plugin. */				__( '%s plugin deactivated during WordPress upgrade.' ),				$plugin['plugin_name']			),			$explanation,			esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ),			__( 'Go to the Plugins screen' )		);		wp_admin_notice( $message, array( 'type' => 'warning' ) );	} 	// Empty the options.	update_option( 'wp_force_deactivated_plugins', array(), false );	if ( is_multisite() ) {		update_site_option( 'wp_force_deactivated_plugins', array() );	}}

Changelog

Introduced in 5.8.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-admin/includes/plugin.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.