Skip to content

Instantly share code, notes, and snippets.

@woodwardtw
Last active April 2, 2016 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woodwardtw/1de732cad0b6f0fb368f377fbc78ca5b to your computer and use it in GitHub Desktop.
Save woodwardtw/1de732cad0b6f0fb368f377fbc78ca5b to your computer and use it in GitHub Desktop.
spits out plugin count for wp to array as a custom page
<?php
/**
* Template Name: network plugins
* read the title
* modded from http://wordpress.stackexchange.com/questions/54742/how-to-do-i-get-a-list-of-active-plugins-on-my-wordpress-blog-programmatically
*
**/
?>
<?php get_header(); ?>
<div id="content" class="clearfix row dark">
<div id="main" class="col col-md-10 col-md-offset-1 clearfix" role="main">
<?php
if (empty($_GET['id'])){
$last_id = 1;
}
else {
$last_id = urlencode($_GET['id']);
}
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = {$wpdb->siteid} AND blog_id >".$last_id." LIMIT 100";
$csvArray =[];
$blogs = $wpdb->get_results($query);
//var_dump($blogs);
echo '<table class="table table-striped" >';
foreach ( $blogs as $blog ) {
// Do your thing!
$the_plugs = get_blog_option($blog->blog_id, 'active_plugins');
if($the_plugs !=null){
foreach($the_plugs as $key => $value) {
$string = explode('/',$value); // Folder name will be displayed
array_push($csvArray, $string[0]);
//var_dump($csvArray);
}
}
}
$vals = array_count_values($csvArray);
echo '<pre>';
var_dump($vals);
echo '</pre>';
// Record the last ID for the next loop
$last_id = $blog->blog_id;
echo '<a class="btn btn-primary" href="?id=' . $last_id . '">next round of records ' . $last_id . '</a>';
?>
</div>
</div>
<footer>
<p class="clearfix"><?php the_tags('<span class="tags">' . __("Tags","wpbootstrap") . ': ', ', ', '</span>'); ?></p>
</footer> <!-- end article footer -->
</article> <!-- end article -->
</div> <!-- end #main -->
<?php //get_sidebar(); // sidebar 1 ?>
</div> <!-- end #content -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment