I'm looking for a way to get the list of all plugins listed in the WordPress Plugin Directory.
There is one other post I've found on StackOverflow regarding this which recommends using the subversion repository.
I'd like to do something that organizes them by number of downloads.
I think this is probably possible using the WordPress API, but I'm not positive. My attempts thus far have failed. Any ideas?
I'm looking for a way to get the list of all plugins listed in the WordPress Plugin Directory.
There is one other post I've found on StackOverflow regarding this which recommends using the subversion repository.
I'd like to do something that organizes them by number of downloads.
I think this is probably possible using the WordPress API, but I'm not positive. My attempts thus far have failed. Any ideas?
Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Aug 10, 2015 at 3:41 davemackeydavemackey 3152 silver badges18 bronze badges 3- close voted as this is not related to wordpress development. If you have questions about wordpress you should simply ask the people maintaining it. – Mark Kaplun Commented Aug 10, 2015 at 4:35
- 3 This is related to WordPress development, the WordPress Plugin Directory is integrated into WordPress core via the Plugins API. – davemackey Commented Aug 10, 2015 at 13:20
- 3 Can you post code of what you have tried? – czerspalace Commented Aug 10, 2015 at 22:02
3 Answers
Reset to default 7You can start with something like this:
https://api.wordpress/plugins/info/1.2/?action=query_plugins&request[page]=1&request[per_page]=400
I think it's self-explanatory.
Without seeing some code or results it is difficult to advise beyond linking you to other tutorials on the web. A quick Google revealed these:
- https://dd32.id.au/projects/wordpressorg-plugin-information-api-docs/
- http://code.tutsplus/tutorials/communicating-with-the-wordpressorg-plugin-api--wp-33069
As with a lot of the WP codex the official documentation is a little lacking.
good day dear Davemackey - hello Michael Field its been a long time that this has been asked - but anyway.. here my little idea that i can come up with..
Not the best answer but I tried to solve my own problem the best way I could.
Getting a list of plugins
This will not return ALL plugins but it will return the top rated ones:
$plugins = plugins_api('query_plugins', array(
'per_page' => 100,
'browse' => 'top-rated',
'fields' =>
array(
'short_description' => false,
'description' => false,
'sections' => false,
'tested' => false,
'requires' => false,
'rating' => false,
'ratings' => false,
'downloaded' => false,
'downloadlink' => false,
'last_updated' => false,
'added' => false,
'tags' => false,
'compatibility' => false,
'homepage' => false,
'versions' => false,
'donate_link' => false,
'reviews' => false,
'banners' => false,
'icons' => false,
'active_installs' => false,
'group' => false,
'contributors' => false
)));
Save the data as JSON
Since the data that we get is huge and it will be bad for performance, we try to get the name
and the slug
out of the array and then we write it in a JSON file:
$plugins_json = '{' . PHP_EOL;
// Get only the name and the slug
foreach ($plugins as $plugin) {
foreach ($plugin as $key => $p) {
if ($p->name != null) {
// Let's beautify the JSON
$plugins_json .= ' "'. $p->name . '": {' . PHP_EOL;
$plugins_json .= ' "slug": "' . $p->slug . '"' . PHP_EOL;
end($plugin);
$plugins_json .= ($key !== key($plugin)) ? ' },' . PHP_EOL : ' }' . PHP_EOL;
}
}
}
$plugins_json .= '}';
file_put_contents('plugins.json', $plugins_json);
Now we have a slim JSON file with only the data that we need.
To keep updating the JSON file, we run that script to create a JSON file every 24 hours by setting up a Cron Job.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742314512a4420566.html
评论列表(0条)