is_network_only_plugin( string $plugin ): bool
- Since
- 3.0.0, 7.1.1
- Source
wp-admin/includes/plugin.php:608
Description
Checks for "Site Wide Only: true" for backward compatibility.
Compatibility
- WordPress
- since 7.1.1
- PHP
- 7.4–8.6-dev
- 6.7.10
- 6.8.11
- 6.9.10
- 7.0.7
- 7.1.3
Present in every tracked release (6.7.10 to 7.1.3), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$pluginstring- Path to the plugin file. Accepts a path relative to the plugins directory, or an absolute path, with or without surrounding whitespace.
Return value
bool- True if plugin is network only, false otherwise.
Performance profile
How much work a call to is_network_only_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
- Trivial
- Scaling
- Constant
- Instructions
- 15–16
- Plugin surface
- None
- Called by
- 7
Touches nothing outside its own arguments.
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 17.
Nothing here hands control to plugin code.
7 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost is_network_only_plugin() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 15–16 | plugin_basename(), get_plugin_data() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 17 | 15–16 | 1 | |
| 8.5 | 17 | 15–16 | 1 | |
| 8.4 | 17 | 15–16 | 1 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 19 | 17–18 | 1 | |
| 8.2 | 19 | 17–18 | 1 | |
| 8.1 | 19 | 17–18 | 1 | |
| 7.4 | 19 | 17–18 | 1 |
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_plugin_data()Parses the plugin contents to retrieve plugin's metadata.
Used by · 7
- WP_Plugins_List_Table::prepare_items()
- WP_Plugins_List_Table::single_row()
- WP_REST_Plugins_Controller::check_read_permission()Checks if the given plugin can be viewed by the current user.
- WP_REST_Plugins_Controller::handle_plugin_status()Handle updating a plugin's status.
- activate_plugin()Attempts activation of plugin in a "sandbox" and redirects on success.
- is_wpmu_sitewide_plugin()Deprecated functionality for determining if the current plugin is network-only.
- wp_ajax_activate_plugin()Handles activating a plugin via AJAX.
Source code
function is_network_only_plugin( $plugin ) { // Normalize the path the same way activate_plugin() does, so both agree on the file. $plugin = plugin_basename( trim( $plugin ) ); $plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); if ( $plugin_data ) { return $plugin_data['Network']; } return false;}Changelog
Introduced in 3.0.0. Unchanged from 6.7.10 through 7.1.3.
Signature, return type and hooks compared across 5 parsed releases.
$plugin path is normalized with plugin_basename() and trim(), matching how activate_plugin() resolves it.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.0.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.