is_plugin_active_for_network() WordPress Function

The is_plugin_active_for_network() function determines whether a plugin is active for the entire network. This is useful for plugin authors who need to know whether their plugin is active on a multisite installation. By default, the is_plugin_active() function only checks if a plugin is active on the current site.

is_plugin_active_for_network( string $plugin ) #

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.


Top ↑

Parameters

$plugin

(string)(Required)Path to the plugin file relative to the plugins directory.


Top ↑

Return

(bool) True if active for the network, otherwise false.


Top ↑

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).


Top ↑

Source

File: wp-admin/includes/plugin.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.