Checks if a plugin is activated.
NOTE: defined in wp-admin/includes/plugin.php, so this is only available from within the admin pages, and any references to this function must be hooked to admin_init or a later action. If you want to use this function from within a template or a must-use plugin, you will need to manually require plugin.php, an example is below.
In the Admin Area:
<?php is_plugin_active($plugin) ?>
In the front end, in a theme, etc...
<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); ?>
<?php is_plugin_active($plugin) ?>
Admin area
<?php
/**
* Detect plugin. For use in Admin area only.
*/
if ( is_plugin_active( 'plugin-directory/plugin-file.php' ) ) {
//plugin is activated
}
Front end
<?php
/**
* Detect plugin. For use on Front End only.
*/
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// check for plugin using plugin name
if ( is_plugin_active( 'plugin-directory/plugin-file.php' ) ) {
//plugin is activated
}
Since Version 2.5
is_plugin_active()
is defined in wp-admin/includes/plugin.php
.