Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Active Multisite Plugins: List of active plugins on a Multisite installation. https://www.damiencarbery.com/2019/05/active-multisite-plugins/
<?php
/*
Plugin Name: Multisite Plugins Activate
Plugin URI: http://www.damiencarbery.com
Description: List of active plugins on a Multisite installation.
Author: Damien2
*/
// 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
You can’t perform that action at this time.