Respuestas:
Los complementos activados se almacenan en la tabla de opciones de un blog de WordPress debajo de la tecla active_plugins
para que pueda usar get_option('active_plugins');
cada blog y comparar las matrices.
En forma de un Panel de Control, uno para Sitios Únicos y Panel de Sitios de Red, otro para el Panel de Red Multisitio.
/*
* 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>';
}
}
Si desea saber qué complemento está activado actualmente y en qué sitio, puede usar una función como esa:
function wpstars_list_active_plugins() {
if ( function_exists( 'get_sites' ) && class_exists( 'WP_Site_Query' ) ) {
echo "<table class='active-plugins'>";
echo "<tr><th>Plugin name</th><th>Sites</th></tr>";
$plugins = get_plugins();
// Network activated
$active_plugins = get_site_option('active_sitewide_plugins');
foreach($active_plugins as $active_path => $active_plugin) {
$plugins[$active_path]['Sites'] = "A,";
}
// Per site activated
$sites = get_sites();
foreach ( $sites as $site ) {
$active_plugins = get_blog_option($site->blog_id, 'active_plugins');
foreach($active_plugins as $active_plugin) {
$plugins[$active_plugin]['Sites'] .= $site->blog_id . ",";
}
}
foreach($plugins as $plugin) {
echo "<tr><td>{$plugin['Name']}</td><td>{$plugin['Sites']}</td></tr>";
}
echo "</table>";
}
}
WP-CLI es solo el boleto. ¡Lo he usado para tantas cosas que he perdido la cuenta!
wp plugin list --status=active
Si lo desea, puede ejecutar estos comandos en su máquina local con alias ...
Entonces usarías la función @site
wp @all plugin list --status=active
o
wp @multisite list --status=active
wp @blog list --status=active