1

I have a plugin activated and working, and I installed and activated another plugin I wrote to communicate with it. However when I run is_plugin_active() I get false returned - does anyone have any idea why and how to rectify it?

EDIT: some basic code. I am in the admin area, and I'm trying to use the functions of the other plugin ultimately. But the initial check is quite basic:

if (is_plugin_active('Plugin2')) {
    echo 'Thanks for installing Plugin2';
} else {
    echo 'Please install Plugin2';
}

EDIT2: Per the codex, you do NOT need the filepath if you're using in the admin side. But I tried with the full path, as modified here, which also did not work.

if (is_plugin_active('Plugin2/Plugin2.php')) {
    echo 'Thanks for installing Plugin2';
} else {
    echo 'Please install Plugin2';
}
5
  • 2
    Can you post some code or give some context as to how/where you are using it? Commented Mar 6, 2012 at 18:59
  • Is this example code the actual code you're using? Because if it is, then your code won't work ... as cale_b answered below, you need the plugin directory and file name (with .php extension) for this to work correctly.
    – EAMann
    Commented Mar 6, 2012 at 19:15
  • Is Plugin2 the actual slug of the Plugin, or is it an "example" Plugin slug? Also: in what directory is Plugin2 installed? Commented Mar 6, 2012 at 19:29
  • Did you ever figure this out?
    – codewizard
    Commented Apr 23, 2015 at 15:40
  • I just checked for a class I knew the plugin to have, using class_exists.. Commented Apr 23, 2015 at 16:32

1 Answer 1

3

Per the WP Codex, you need to be sure you are passing the directory and file:

<?php
   If (is_plugin_active('plugin-directory/plugin-file.php')) {
     //plugin is activated
  }
?> 
2
  • 1
    Not working, and I'm the admin area anyway so it shouldn't matter. Commented Mar 6, 2012 at 19:08
  • Per your question above, it doesn't appear you are passing the file name.... Commented Mar 6, 2012 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.