João Paulo Cercal

Staff Security Engineer at LastPass

  • PHP

WordPress Tip: How to check whether a plugin is active?

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn

Read this article in

When you’re developing a theme or a plugin for the WordPress platform, you may need to check whether a specific plugin is activated. Well, here’s a simple script to check whether a plugin is activated or not in the wordpress administration panel.

You’ll only need to change line 4 to your plugin’s directory name.

Note: Plugins are located in the directory: /wp-content/plugins/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<?php

// Adicione esta linha se este pedaço de código
// não estiver sendo executado no painel administrativo
require_once(ABSPATH . '/wp-admin/includes/plugin.php');

// Verifica se o plugin está ativado...
if (is_plugin_active('plugin-directory/plugin-file.php')) {
    // o plugin está ativado...
} else {
    // O plugin está desativado...
}

That was another tip for the WordPress platform.

You can find more details about the is_plugin_active() function in the official WordPress Documentation.

Questions? Leave a comment!