I would like to defer the loading of an othervise active plugin for certain pages.

Since all plugins reside in the same folder, and WordPress only loads the activated ones, it must have an array of active plugin-handles at some point that it goes through. There's probably even a filter available to modify this array just before its being read (I'm hoping..).

So is it possible to conditionally bypass the loading of an otherwise active plugin, by removing it's handle from the list of active plugins, dynamically, without deactivating the plugin using deactivate_plugins()?

  • 1) Why? 2) Where would you put the code to do this? Add it to a plugin and timing is going to be tricky, and a themes load too late.
    – s_ha_dum
    Dec 6, 2013 at 14:36
  • I can see your point, that it will be difficult to actually control this. I want to bypass loading WooCommerce on my sites blog. I have a site with 2 mil pageviews per month, and I can see woocommerce is the single biggest resource eater, the site is too slow, and most visit hit the blog, not the shop. I don't show a cart or any shop related elements on the blog, so I though that it woud be best to simply prevent woocommerce from loading at all on those pages. Dec 7, 2013 at 17:45

1 Answer 1


The list of active plugins is provided by wp_get_active_and_valid_plugins() during core load and comes from active_plugins option (multisite details aside).

While there is no explicit filter for it as any option it can be filtered via 'option_' . $option hook (so option_active_plugins) and mu-plugin (which are being loaded earlier) should be able to do it.

Note that it is more common and better practice to control what plugin does (such as thing it hooks) rather than if it loads completely.

  • Going from your hint on using the 'option_active_plugins' filter I got it working. I've added my solution to the original question above. Dec 7, 2013 at 23:27
  • @mwb please move solution to an answer, that is more inline with site's mechanics. Also that doesn't seem like it should work since loading plugins is extremely early and long before conditional tags are supposed to work reliably.
    – Rarst
    Dec 7, 2013 at 23:31
  • Ok I added it to the original, because that's wat SE instructed me to do, rather than add it as an answer. Anyway it does seem to work, I'll double check.. Dec 8, 2013 at 12:59
  • no it doesn't work Dec 8, 2013 at 13:01
  • @mikkelbreum to be clear updates and details about original questions are appropriate as edits, final solution you might have worked out is appropriate as answer. Also issue with timing is exactly kind of a thing why this is not commonly done this way.
    – Rarst
    Dec 8, 2013 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.