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' ) )
return;
// Continue if Facebook plugin is not active
...
}
}
My if (class_exists())
statement isn’t working. Appreciate any advice and pointers. Thanks!
You should use
is_plugin_active()
method to check if a certain plugin is activated. The classFacebook_WP
will still exists even you deactivate the plugin.