Use is_plugin_active() to check If a WordPress Plugin is Activate

Check If a WordPress Plugin is Activated with PHP

WordPress has a ton of hooks and methods to check specific tasks. These are very useful when developing plugins and themes.

In this post I’ll show you how to use the is_plugin_active() method to check if another plugin is installed and activated.

Why would you use is_plugin_active()? Let’s say you’re creating a custom plugin that depends on another plugin being installed and activated. For example: your new plugin will add new features to WooCommerce.

The code

If your code is executed on the admin area, use this sample code:

{codecitation php}if ( is_plugin_active( ‘plugin-folder/plugin-file.php’ ) ):

echo ‘The plugin IS activated’;


echo ‘The plugin is NOT activated’;


Replace ‘plugin-folder/plugin-file.php’ with the folder and main file name of the plugin you want to target. For example: ‘woocommerce/woocommerce.php’ to check if WooCommerce is installed and activated.

If the code will execute in the public area of the site, add this line of PHP code above the previous one:

{codecitation php}include_once( ABSPATH . ‘wp-admin/includes/plugin.php’ );{/codecitation}


  • Valentin Garcia

    Valentin discovered Joomla in 2010, and since then he has considered it as the best CMS. Valentin has been coding extensions and templates for Joomla for many years and truly enjoys helping people build their own websites with Open Source tools. He lives in San Julián, Jalisco, México.

0 0 votes
Blog Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments

Thank you so much, i was looking for a quick example and this post is probably the best i could i have found


¡Muchas gracias Valentín! I believe you’re the only one with a clear example on this function in the whole Internet. The ‘plugin-folder/plugin-file.php’ path wasn’t totally clear to me until I read your example! Wohoo!

Brian Brown, Ph.D.

I think that to make this compatible with WordPress coding best practices, you need to use WP_PLUGIN_DIR (if defined) instead of a hard-coded path.
Also see:




Would love your thoughts, please comment.x