WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new to OOP and I'm writing my first plugin. I want to check if the Facebook plugin has already been activated. If so, I want to skip some code:

class MyClass {
    function fb_js_sdk_setup() {
        // Check if Facebook plugin is activated 
        if ( class_exists( 'Facebook_WP' ) )
        // Continue if Facebook plugin is not active


My if (class_exists()) statement isn't working. Appreciate any advice and pointers. Thanks!

share|improve this question
On which action do your create your instance? Make sure to wait until the Facebook plugin has started. – toscho Sep 6 '12 at 3:56
@toscho oh, good point. My instance is attached to init which I guess is too early. When should I load it instead? – blogjunkie Sep 6 '12 at 3:59
wp_loaded maybe? I don’t know when the FB instance is created. Darshan’s advice is good. – toscho Sep 6 '12 at 4:20
up vote 1 down vote accepted

You should use is_plugin_active() method to check if a certain plugin is activated. The class 'Facebook_WP' will still exists even you deactivate the plugin.

share|improve this answer
Thanks Darshan & toscho :) – blogjunkie Sep 6 '12 at 5:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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