admin管理员组

文章数量:1130349

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

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

本文标签: plugin developmentBuddyPress and namespacing