Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have 2 blogs, one which is multisite and one which isn't. I want to get a list of plugins active on both the blogs so I can compare them. On the multisite blog, I want to list the plugins which are enabled network-wide as well as site wide.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

The activated plugins are stored in the options table of a WordPress Blog under the key active_plugins

so you can use get_option('active_plugins'); of each blog and compare the arrays.

share|improve this answer
add comment

In form of a Dashboard Widget, one for Single Sites and Network Sites Dashboard, other for the Multisite Network Dashboard.

/*
 * Single Site Dashboard Widget
 */
add_action('wp_dashboard_setup', 'wpse_54742_wp_dashboard_setup');

function wpse_54742_wp_dashboard_setup() {
    wp_add_dashboard_widget( 'wpse_54742_active_site_plugins', __( 'Active Plugins' ), 'wpse_54742_active_site_plugins' );
}

function wpse_54742_active_site_plugins() {
    $the_plugs = get_option('active_plugins'); 
    echo '<ul>';
    foreach($the_plugs as $key => $value) {
        $string = explode('/',$value); // Folder name will be displayed
        echo '<li>'.$string[0] .'</li>';
    }
    echo '</ul>';
}


/*
 * Multisite Dashboard Widget
 */
add_action('wp_network_dashboard_setup', 'wpse_54742_network_dashboard_setup');

function wpse_54742_network_dashboard_setup() {
    wp_add_dashboard_widget( 'wpse_54742_active_network_plugins', __( 'Network Active Plugins' ), 'wpse_54742_active_network_plugins' );
}

function wpse_54742_active_network_plugins() {
    /*
     * Network Activated Plugins
     */
    $the_plugs = get_site_option('active_sitewide_plugins'); 
    echo '<h3>NETWORK ACTIVATED</h3><ul>';
    foreach($the_plugs as $key => $value) {
        $string = explode('/',$key); // Folder name will be displayed
        echo '<li>'.$string[0] .'</li>';
    }
    echo '</ul>';


    /*
     * Iterate Through All Sites
     */
    global $wpdb;
    $blogs = $wpdb->get_results($wpdb->prepare("
        SELECT blog_id
        FROM {$wpdb->blogs}
        WHERE site_id = '{$wpdb->siteid}'
        AND spam = '0'
        AND deleted = '0'
        AND archived = '0'
    "));

    echo '<h3>ALL SITES</h3>';

    foreach ($blogs as $blog) {
        $the_plugs = get_blog_option($blog->blog_id, 'active_plugins'); 
        echo '<hr /><h4><strong>SITE</strong>: '. get_blog_option($blog->blog_id, 'blogname') .'</h4>';
        echo '<ul>';
        foreach($the_plugs as $key => $value) {
            $string = explode('/',$value); // Folder name will be displayed
            echo '<li>'.$string[0] .'</li>';
        }
        echo '</ul>';
    }
}
share|improve this answer
    
This was much more than I required but really appreciate you putting in the time to provide such detailed answer. Hopefully, it will help someone else. Thank You. –  mehulved Sep 2 '12 at 1:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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