Created
May 1, 2017 20:44
-
-
Save damiencarbery/16b329aa67c801356d6b2a35513cc09d to your computer and use it in GitHub Desktop.
List of active plugins on a Multisite installation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Multisite Plugins Activate | |
Plugin URI: http://www.damiencarbery.com | |
Description: List of active plugins on a Multisite installation. | |
Author: Damien Carbery | |
Version: 0.1 | |
$Id: multisite-plugins-activated.php 3308 2016-01-20 11:04:27Z damien $ | |
*/ | |
// Based on: http://wordpress.stackexchange.com/a/54782/57684 | |
// Updated to fix $wpdb->prepare warning and display plugin name. | |
/* | |
* 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) { | |
$plugin_data = get_plugin_data( WP_PLUGIN_DIR.'/'.$key ); | |
echo '<li>'. $plugin_data['Name'] .'</li>'; | |
} | |
echo '</ul>'; | |
/* | |
* Iterate Through All Sites | |
*/ | |
global $wpdb; | |
$blogs = $wpdb->get_results(" | |
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'); | |
printf('<hr /><h4><strong>SITE</strong>: <a href="%s" title="Go to the Dashboard for %s">%s</a></h4>', get_admin_url( $blog->blog_id), get_blog_option($blog->blog_id, 'blogname'), get_blog_option($blog->blog_id, 'blogname')); | |
echo '<ul>'; | |
foreach($the_plugs as $key => $value) { | |
$plugin_data = get_plugin_data( WP_PLUGIN_DIR.'/'.$value ); | |
echo '<li>'. $plugin_data['Name'] .'</li>'; | |
} | |
echo '</ul>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment