Created
April 5, 2016 01:15
-
-
Save woodwardtw/8f1df03e58a4256bf1b98b8f89a3f37d to your computer and use it in GitHub Desktop.
yet another count plugins to csv - hand progression
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 | |
/** | |
* Template Name: count all of the plugins and put them in a csv file - do it | |
* 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']); | |
} | |
$csvData = []; | |
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = {$wpdb->siteid} AND blog_id >".$last_id." LIMIT 400"; | |
$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'); | |
foreach($the_plugs as $key => $value) { | |
$string = explode('/',$value); // Folder name will be displayed | |
echo '<tr><td>' .get_blog_option($blog->blog_id, 'siteurl'). ' - ' .$string[0] .'</td></tr>'; | |
$the_site_url = get_blog_option($blog->blog_id, 'siteurl'); | |
$the_plugin = $string[0]; | |
array_push ($csvData, $the_site_url . ', ' . $the_plugin); | |
} | |
} | |
$file = fopen('plugindata.csv',"a+"); | |
foreach ($csvData as $line) | |
{ | |
fputcsv($file,explode('ˇ',$line)); | |
} | |
fclose($file); | |
echo '</table>'; | |
// 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