Forked from damiencarbery/multisite-plugins-activated.php
Created
December 9, 2022 13:47
-
-
Save stgoos/90fa4dd53aa1c5bef74e3e18be343f3d to your computer and use it in GitHub Desktop.
Active Multisite Plugins: List of active plugins on a Multisite installation. https://www.damiencarbery.com/2019/05/active-multisite-plugins/
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: 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
Very useful - thanks for sharing!!