Powered by Blogger.

how to check if a Plugin is Active on your Mulitplesite Network


On WordPress Mulitplesite Network a plugin can be “Network Activate ” or only “Activate” on the child site. If your plugin depends on others then you may want to use the following codes to check if a plugin is active on your multiple site networks. The following codes tested under WordPress 3.8.1


function wpprogramming_check_if_a_plugin_active_on_mulitplesite_network(){
    //first check if the plugin is active on child site
    $child_site_plugins = get_option( 'active_plugins' );
    if( !in_array('akismet/akismet.php',$child_site_plugins) ) { 
        //check again to see if the plugin is Network Activated
        $network_activated_plugins = get_site_option( 'active_sitewide_plugins' );
        if( !array_key_exists('akismet/akismet.php',$network_activated_plugins) ) {
           return false;
        }
    }

    return true;
}

No comments