Created
October 5, 2016 19:30
-
-
Save kasparsd/8a1f1ff7a17c036617383ffcdcc9b466 to your computer and use it in GitHub Desktop.
Top 1000 most popular WordPress plugins
This file contains hidden or 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 | |
// To create one CSV file: | |
// $ cat stats/stats-* > stats.csv | |
$query = array( | |
'browse' => 'popular', | |
'per_page' => 100, | |
'fields' => array( | |
'name' => true, | |
'slug' => true, | |
'downloaded' => true, | |
'last_updated' => true, | |
'description' => false, | |
'contributors' => false, | |
'ratings' => false, | |
'short_description' => false, | |
'rating' => false, | |
'num_ratings' => false, | |
'compatibility' => false, | |
'contributors' => false, | |
'author' => false, | |
'author_profile' => false, | |
) | |
); | |
$page = 1; | |
$request = true; | |
while ( $page < 11 ) { | |
$query['page'] = $page; | |
$filename = sprintf( 'stats/stats-%d.csv', $page ); | |
$request = wp_remote_post( | |
'http://api.wordpress.org/plugins/info/1.0/', | |
array( | |
'body' => array( | |
'action' => 'query_plugins', | |
'request' => serialize( (object) $query ), | |
) | |
) | |
); | |
$rows = unserialize( $request['body'] ); | |
$fp = fopen( $filename, 'w' ); | |
foreach ( $rows->plugins as &$plugin ) { | |
unset( $plugin->contributors ); | |
fputcsv( $fp, (array)$plugin ); | |
} | |
$page++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment