is_plugin_active

Check whether a plugin is active.

Description

is_plugin_active( (string) $plugin ); 

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.

Parameters (1)

0. $plugin (string)
Base plugin path from plugins directory.

Usage

  1. if ( !function_exists( 'is_plugin_active' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/plugin.php'; 
  3.  
  4. // Base plugin path from plugins directory. 
  5. $plugin = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = is_plugin_active($plugin); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/plugin.php  
  1. function is_plugin_active( $plugin ) { 
  2. return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || is_plugin_active_for_network( $plugin );