deactivated_plugins_notice()
- Since
- 5.8.0
- Source
wp-admin/includes/plugin.php:2594
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
- Scaling
- Scales with input
- Instructions
- 4–57
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 131.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()one call below deactivated_plugins_notice() - cacheobject cache
wp_cache_get()one call below deactivated_plugins_notice() - serializeserialisation
maybe_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.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 4 | none |
!current_user_can() | 8 | current_user_can() |
current_user_can() && $blog_deactivated_plugins !== false && !is_multisite() && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins) | 22 | current_user_can(), get_option(), is_multisite() |
current_user_can() && $blog_deactivated_plugins === false && !is_multisite() && empty($blog_deactivated_plugins) && empty($site_deactivated_plugins) | 27 | current_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) | 28 | current_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) | 32 | current_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) | 33 | current_user_can(), get_option(), update_option(), is_multisite(), get_site_option() |
current_user_can() && $blog_deactivated_plugins !== false && !is_multisite() | 35–38 | current_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) | 37 | current_user_can(), get_option(), update_option(), is_multisite(), get_site_option(), update_site_option() |
current_user_can() && $blog_deactivated_plugins !== false | 39–42 | current_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–43 | current_user_can(), get_option(), update_option(), is_multisite(), array_merge(), update_option(), is_multisite() |
current_user_can() && $blog_deactivated_plugins !== false && $site_deactivated_plugins !== false | 41–44 | current_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 === false | 44–47 | current_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 !== false | 45–48 | current_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 === false | 45–48 | current_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 !== false | 46–49 | current_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 === false | 49–52 | current_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 !== false | 50–53 | current_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 === false | 50–53 | current_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 === false | 54–57 | current_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 131 | 4–57 | 13 | |
| 8.5 | 131 | 4–57 | 13 | |
| 8.4 | 131 | 4–57 | 13 | 2 more instructions than PHP 8.3 |
| 8.3 | 129 | 4–57 | 13 | |
| 8.2 | 129 | 4–57 | 13 | |
| 8.1 | 129 | 4–57 | 13 | 4 fewer instructions than PHP 7.4 |
| 7.4 | 133 | 5–58 | 13 |
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
- current_user_can()Returns whether the current user has the specified capability.
- get_option()Retrieves an option value based on an option name.
- update_option()Updates the value of an option that was already added.
- is_multisite()Determines whether Multisite is enabled.
- get_site_option()Retrieve an option value for the current network based on name of option.
- update_site_option()Updates the value of an option that was already added for the current network.
- __()Retrieves the translation of $text.
- esc_url()Checks and cleans a URL.
- admin_url()Retrieves the URL to the admin area for the current site.
- wp_admin_notice()Outputs an admin notice.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.