plugin development - BuddyPress and namespacing

admin2025-06-06  11

I'm using PSR-4 autoloading and namespacing for a new plugin. However, because my plugin is namespaced (and all it's classes are), I can't seem to extend a BuddyPress class (BP_Attachment) successfully as it doesn't want to pass the if ( class_exists( 'BP_Attachment', false ) ) check. I've tried to require it, "use" it, and more. Nothing works. Since BuddyPress doesn't use namespacing am I out of luck?

I'm using PSR-4 autoloading and namespacing for a new plugin. However, because my plugin is namespaced (and all it's classes are), I can't seem to extend a BuddyPress class (BP_Attachment) successfully as it doesn't want to pass the if ( class_exists( 'BP_Attachment', false ) ) check. I've tried to require it, "use" it, and more. Nothing works. Since BuddyPress doesn't use namespacing am I out of luck?

Share Improve this question asked Oct 30, 2018 at 10:57 mrpritchettmrpritchett 134 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Try using if ( class_exists( '\BP_Attachment', false ) )?

Could be that you need to tell PHP that the class is in the global namespace

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749220662a317373.html

最新回复(0)