Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugins Loaded When?

  • @adergaard

    Member

    I’ve created a couple of plugins for the admin side, are those loaded with each request that hits the bb-load.php?

    I fear it is and have *ugly code ahead* hijacked the admin.php and added a require-instruction there for my adminplugins since I don’t want them to drain resources on the front-end so to speak.

    Is this at all a relevant fear or is the reading and attaching to the event-loop so minimal in resource demand that it really doesn’t matter if it’s loaded each time?

Viewing 1 replies (of 1 total)
  • @mdawaffe

    Member

    The plugins are loaded everytime bbPress is loaded.

    If you’re don’t want any code from your plugin to execute unless you’re in the admin, you could put something like this hack at the top of your “admin-only” plugins:

    if ( false === strpos($_SERVER['REQUEST_URI'], '/bb-admin/') )

    return;

    But just loading the plugin file shouldn’t add too much overhead. You could do something a little nicer, if you weren’t worried about loading your plugin file:

    function my_admin_only() {

    if ( false === strpos($_SERVER['REQUEST_URI'], '/bb-admin/') )

    return;

    else load_my_plugin_stuff();

    }

    add_action( 'init', 'my_admin_only' );

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar