is_plugin_active() WordPress Function

The is_plugin_active() function is a built-in WordPress function that checks whether a given plugin is active or not. This function is useful for conditionally loading plugin-specific code only when the plugin is active.

is_plugin_active( string $plugin ) #

Determines whether a plugin is active.


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 in the active plugins list. False, not in the list.


Top ↑

Source

File: wp-admin/includes/plugin.php

function is_plugin_active( $plugin ) {
	return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
}


Top ↑

Changelog

Changelog
VersionDescription
2.5.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.