admin管理员组文章数量:1435531
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!
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!
1 Answer
Reset to default 2You 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.
本文标签: pluginsCheck if a class exists within a method
版权声明:本文标题:plugins - Check if a class exists within a method 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745650774a2668415.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
init
which I guess is too early. When should I load it instead? – blogjunkie Commented Sep 6, 2012 at 3:59wp_loaded
maybe? I don’t know when the FB instance is created. Darshan’s advice is good. – fuxia ♦ Commented Sep 6, 2012 at 4:20