Skip to:

load an extension directly in a component (not in a plugin way)

  • grosbouff


    Hi, i’ve created an extension for my component.

    If I use it as a plugin (with a header, etc); it works perfectly.

    But I would like to include it directly in my component;

    require ( WP_PLUGIN_DIR . '/bp-classifieds/bp-classifieds-groups.php' );

    but then it does a fatal error :

    Class ‘BP_Group_Extension’ not found in F:webkinewordpress-muwp-contentpluginsbp-classifiedsbp-classifieds-groups.php on line 5

    So I guess I have to load in with a hook.

    But which one ?

    I did try

    function classifieds_group_extension_init() {

    require ( WP_PLUGIN_DIR . ‘/bp-classifieds/bp-classifieds-groups.php’ );






    But it does not work.

    Please help ;)

Viewing 2 replies - 1 through 2 (of 2 total)

  • JJJ


    When you are including directly code that is usually a plugin, you need to make sure that you include all of its dependencies before you proceed through the file you’re using to load that code.

    In my opinion, the only way to make this transition is to do so knowing that you’re totally bypassing the ability to update the plugin and that it is now something that you’re including manually, either within your template or maybe even bp-custom.php. If the plugin itself was all you needed, then you’d just activate it and let it do it’s thing, right?

    So, rather than hook the loading of those files into a WordPress action, load them via your parent themes’ functions.php file, and put that code in your parent/functions/ folder…

    I try to keep things clean and logical, but I also reinvent a lot of wheels and re-factor existing WordPress plugins for my own custom applications. Breadcrumbs, taxonomy clouds, custom kses, etc… My parent themes are loaded with additional code that started out as someone else’s plugin that now is part of my theme. ( I know this goes against the entire reason why plugins exist, and I know it would be better karma to help contribute to a plugin than disassemble it and use its parts as my own, but sometimes that isn’t realistic, and sometimes it helps to see someone else’s perspective on how to achieve a goal. )

    Maybe I misunderstood your question entirely… If so, then forget everything I just said. :)

    Long story short, require ( WP_PLUGIN_DIR . '/bp-classifieds/bp-classifieds-groups.php' ); isn’t included everything that plugin needs to live. That file uses another file that’s missing.

    Jeff Sayre



    Did you use the new Group Extension API and create a new class that extends the BP_Group_Extension class?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘load an extension directly in a component (not in a plugin way)’ is closed to new replies.
Skip to toolbar