. */ $activeplugins = new activeplugins(); class activeplugins { function activeplugins() { add_action('admin_menu', array(&$this, 'menu')); } function menu() { add_submenu_page('ms-admin.php', 'Active Plugins', 'Active Plugins', 'unfiltered_html', __FILE__, array(&$this, 'page')); } function page() { global $wpdb; echo '
'.__('Does not include primary site, network activated plugins, or plugins with 0 users.').'
'; $query = "SELECT * FROM {$wpdb->blogs}, {$wpdb->registration_log} WHERE site_id = '{$wpdb->siteid}' AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id"; $blog_list = $wpdb->get_results( $query, ARRAY_A ); //get blogs $pi = array(); foreach($blog_list as $id=>$info) { $theid = $info['blog_id']; $query = "SELECT option_value, option_name FROM ".$wpdb->base_prefix.$theid."_options WHERE option_name='active_plugins'"; //get active plugin info for each blog from above $active = $wpdb->get_results( $query, ARRAY_A ); $pi[$theid] = unserialize($active['0']['option_value']); //store active plugin array as value to $pi['blog_id'] unset($query); } $pi = array_filter($pi); //remove empties $pi_count = array(); foreach($pi as $k=>$v_array) { $pi_count = array_merge($pi_count, $v_array); //put all active plugins into one array, we can then count duplicate values } echo 'Totals (each active plugin and how many users):'."\n";
$totals = array_count_values($pi_count);
$tags = $totals;
ksort($totals);
foreach($totals as $name=>$tot) {
if (strpos($name,'/') !== false) {
$dir = WP_PLUGIN_DIR.'/'.dirname($name);
$dottags = (glob($dir.'/*.tag'));
if (!empty($dottags) )
$tags[ $name ] = str_replace($dir.'/','',str_replace('.tag','',$dottags['0']));
}
echo "\t" . $name . (!is_numeric($tags[ $name ]) ? ' (tagged: '.$tags[ $name ].')' : '') . ' is used by ' . $tot . ' site' . (($tot == '1') ? '' : 's') . "\n";
}
echo '';
echo 'Blog (ID, URL) -> plugins:'."\n";
foreach($pi as $siteid=>$list) {
$details = get_blog_details($siteid);
echo $details->blogname . ' (' . $siteid . ', ' . $details->siteurl . ' Go to plugins page →)' . "\n";
$tagged = array(); $nottagged = '';
foreach($list as $name) {
if ( is_numeric( $tags[ $name ] ) )
$nottagged .= "\t".$name . "\n";
else
$tagged["\t(" . $tags[ $name ] . ') ' . $name . "\n"] = $tags[$name];
}
asort($tagged);
$tagged = array_keys($tagged);
echo implode($tagged) . $nottagged . "\n";
unset( $tagged ); unset( $nottagged );
}
echo '';
echo '