1

I'm new to multisite development, and I'm struggling to answer this question: I have a Multisite network setup that I inherited, and I have been tasked with removing a few plugins network-wide.

The plugins in question are currently deactivated at the top network level, I am wondering if there's a quick check I run to see if they are individually active throughout sites on the network?

After doing a few spot checks I see the deactivated plugin as an option on some of the sub-sites, with the option to activate them individually, I assume the activation on this level will not affect the network?

There are about 50 sites total so checking each manually is not optimal.

Thanks

1

2 Answers 2

0

Though the question is quite old I would like to share the small code snippet with you guys.

So here is how to check whether a plugin is activated individually for some websites:

$sites = get_sites();
foreach( $sites as $site ) {
    switch_to_blog( $site->blog_id );
    
    if( in_array( 'YOUR PLUGIN TO CHECK', (array) get_option( 'active_plugins', array() ) ) ) {
        // yes, it is active for $site->blog_id
    }
    
    restore_current_blog();
}

This code is fully functional, you just need to replace 'YOUR PLUGIN TO CHECK' with the actual plugin, for example woocommerce/woocommerce.php.

If you need more details about this snippet, you can find them in this tut: https://rudrastyh.com/wordpress/check-if-plugin-is-active-in-multisite.html

-1

To check if a plugin is active on individual sites within a WordPress Multisite network, you can use the is_plugin_active_for_network function. This function takes the plugin file path as an argument and returns true if the plugin is active on the network, and false if it is not.

Here is an example of how you could use this function to check if a plugin is active on individual sites within your network:

wp plugin list --status=active --network

This will show you a list of all active plugins on the network, including the ones that are active on individual sites within the network.

2
  • This is not what they are asking for. They have stated that they know the plugins are not network activated, but they want to know if they are activated on any individual sites. This will not do that. Commented Dec 9, 2022 at 3:59
  • Thanks for your useful comment.
    – VX3
    Commented Dec 9, 2022 at 19:31

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.