Check If Required Plugin Is Active
September 7th, 2009 by Frank • WordPress Hacks • 5 Comments
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
}
Info
- Published in WordPress Hacks
- Tags: Code, PHP, Plugin, WordPress, WordPress Plugins, WP
- Comment feed
- read: 11910 | today: 5
- leave a Comment




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
Thanks Brad!
Is there a way to display an alert message on top of the plugin list into the plugin section?