is_uninstallable_plugin( string $plugin ): bool
- Since
- 2.7.0
- Source
wp-admin/includes/plugin.php:1267
Compatibility
- WordPress
- since 2.7.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.
Parameters
$pluginstring- Path to the plugin file relative to the plugins directory.
Return value
bool- Whether plugin can be uninstalled.
Performance profile
How much work a call to is_uninstallable_plugin() 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
- Constant
- Instructions
- 12–21
- Plugin surface
- None
- Called by
- 2
Reads or writes the filesystem via file_exists().
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 22.
Nothing here hands control to plugin code.
2 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
get_option()called directly - filesystemfilesystem access
file_exists()called directly - hookthird-party callbacks
apply_filters()one call below is_uninstallable_plugin() - cacheobject cache
wp_cache_get()one call below is_uninstallable_plugin() - serializeserialisation
maybe_unserialize()one call below is_uninstallable_plugin()
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 · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost is_uninstallable_plugin() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
isset($uninstallable_plugins[$file]) | 12 | plugin_basename(), get_option() |
!isset($uninstallable_plugins[$file]) | 21 | plugin_basename(), get_option(), file_exists() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 22 | 12–21 | 2 | |
| 8.5 | 22 | 12–21 | 2 | |
| 8.4 | 22 | 12–21 | 2 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 24 | 12–23 | 2 | |
| 8.2 | 24 | 12–23 | 2 | |
| 8.1 | 24 | 12–23 | 2 | |
| 7.4 | 24 | 12–23 | 2 |
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 · 2
- plugin_basename()Gets the basename of a plugin.
- get_option()Retrieves an option value based on an option name.
Used by · 2
- WP_Plugins_List_Table::single_row()
- delete_plugins()Removes directory and files of a plugin for a list of plugins.
Source code
function is_uninstallable_plugin( $plugin ) { $file = plugin_basename( $plugin ); $uninstallable_plugins = (array) get_option( 'uninstall_plugins' ); if ( isset( $uninstallable_plugins[ $file ] ) || file_exists( WP_PLUGIN_DIR . '/' . dirname( $file ) . '/uninstall.php' ) ) { return true; } return false;}Changelog
Introduced in 2.7.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 6.7.7 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.