Check If Required Plugin Is Active

It might be, that your own written Plugin requires another stand alone Plugin to be active. For example if you like to offer a version with enhanced functionality of a Plugin. There are certainly a variety of usage and the implementation is not difficult.

For the implementation, we need the active Plugins, which are found in the database, table options, the active_plugins. Afterwards, I will simply look in the array, which contains the active Plugins, whether the required plugin included and active or not:

$plugins = get_option('active_plugins');
$required_plugin = 'debug_queries/debug_queries.php';
$debug_queries_on = FALSE;
if ( in_array( $required_plugin , $plugins ) ) {
	$debug_queries_on = TRUE; // Example for yes, it's active
}

Comments are closed.

5 comments

  1. Brad

    There is also a lesser known WP Core function to check this. I just created the Codex page so more people know about it:

    http://codex.wordpress.org/Function_Reference/is_plugin_active

  2. Michael

    Thanks Brad!

  3. Guillem

    Is there a way to display an alert message on top of the plugin list into the plugin section?

2 pingbacks

  1. Comprobando si un plugin está activo en Wordpress | aNieto2K
  2. Check If Required Plugin Is Active – Plugin, Plugins, Example, TRUE;, Afterwards, There – WP Engineer | Tom Altman’s Wedia Conversation