On this page
is_plugin_active_for_network( string $plugin ): bool
Determines whether the plugin is active for the entire network.
Description
Only plugins installed in the plugins/ folder can be active.
Plugins in the mu-plugins/ folder can’t be "activated," so this function will return false for those plugins.
For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.
Parameters
$pluginstring Required-
Path to the plugin file relative to the plugins directory.
Return
bool True if active for the network, otherwise false.
More Information
The file that defines this function (wp-admin/includes/plugin.php) is only loaded in the admin sections. In order to use is_plugin_active_for_network outside the admin pages, it’s necessary to include or require plugin.php before trying to use it (as shown in the example).
Source
File: wp-admin/includes/plugin.php. View all references
function is_plugin_active_for_network( $plugin ) {
if ( ! is_multisite() ) {
return false;
}
$plugins = get_site_option( 'active_sitewide_plugins' );
if ( isset( $plugins[ $plugin ] ) ) {
return true;
}
return false;
}
Related
Uses
| Uses | Description |
|---|---|
| is_multisite() wp-includes/load.php | If Multisite is enabled. |
| get_site_option() wp-includes/option.php | Retrieve an option value for the current network based on name of option. |
Used By
| Used By | Description |
|---|---|
| WP_REST_Plugins_Controller::get_plugin_status() wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php | Get’s the activation status for a plugin. |
| WP_Plugins_List_Table::single_row() wp-admin/includes/class-wp-plugins-list-table.php | |
| WP_Plugins_List_Table::prepare_items() wp-admin/includes/class-wp-plugins-list-table.php | |
| Plugin_Upgrader_Skin::__construct() wp-admin/includes/class-plugin-upgrader-skin.php | Constructor. |
| wp_plugin_update_row() wp-admin/includes/update.php | Displays update information for a plugin. |
| is_plugin_active() wp-admin/includes/plugin.php | Determines whether a plugin is active. |
| deactivate_plugins() wp-admin/includes/plugin.php | Deactivates a single plugin or multiple plugins. |
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_plugin_active_for_network