0

I'm developing a plugin using this boilerplate and I designed it to be extensible. The boilerplate supports namespacing and uses it and namespaces are bind to folder structure. The extensible part is about loading a class from the extension and I want to require extension developers to:

  1. check the existance of the class loader (namespace: Plugin_Name\Inc\Admin)
  2. extend their class from a base class (namespace: Plugin_Name\Inc\Admin)

I'm looking for the easiest way to fulfill the above so that they won't get involved with my plugin's namespaces.

  • Isn't the class loader located in wp-plugin-name/inc/core/class-loader.php ? Checking for a class is done with ie. class_exists, and extending a class is done with extends, so what is the actual problem? – Michael Oct 7 '18 at 8:41
  • i don't want to hide namespaces. for example class_exists works with just class name and without namespaces prefix or some design pattern technique to implement – Ali Sh Oct 7 '18 at 9:40
  • Okay, so developers would use your class loader with ie use Plugin_Name\Inc\Admin\ClassLoader and the base class with use Plugin_Name\Inc\Admin\BaseClass. To extend the class, they could then class NewClass extends BaseClass. – Michael Oct 7 '18 at 9:51
  • sorry i was rewriting the comment and made a mistake: i want to hide namespaces. for example class_exists works with just class name and without namespaces prefix or some design pattern technique to implement – Ali Sh Oct 7 '18 at 10:03
  • 1
    If a class is defined within a namespace, it can only be accessed through that namespace, as far as I know. It's the point of the whole concept, to avoid conflicts in naming. – Michael Oct 7 '18 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.