我正在寻找一种方法来获取WordPress.org Plugin Directory.
我还有一个帖子found on StackOverflow 对此,建议using the subversion repository.
我想做一些事情,按下载次数来组织它们。
我认为这可能是使用WordPress实现的。org-API,但我不能肯定。到目前为止,我的尝试都失败了。有什么想法吗?
我正在寻找一种方法来获取WordPress.org Plugin Directory.
我还有一个帖子found on StackOverflow 对此,建议using the subversion repository.
我想做一些事情,按下载次数来组织它们。
我认为这可能是使用WordPress实现的。org-API,但我不能肯定。到目前为止,我的尝试都失败了。有什么想法吗?
您可以从以下内容开始:
https://api.wordpress.org/plugins/info/1.2/?action=query_plugins&request[page]=1&request[per_page]=400
我认为这是不言而喻的。如果看不到一些代码或结果,除了将您链接到web上的其他教程之外,很难给出建议。谷歌快速发布了以下信息:
你好,亲爱的戴夫·麦基,你好,迈克尔·菲尔兹,这个问题已经问了很久了,但无论如何。。这是我能想到的一个小主意。。
这不是最好的答案,但我尽力用最好的方式解决自己的问题。
$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
)));
将数据另存为JSON,因为我们得到的数据非常大,对性能不利,所以我们尝试获取name
以及slug
然后将其写入JSON文件:$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);
现在我们有了一个精简的JSON文件,其中只包含我们需要的数据。为了不断更新JSON文件,我们通过设置Cron作业,每24小时运行该脚本来创建一个JSON文件。
我试图在表单提交后向用户发送电子邮件,但出现错误Call to undefined function wp_mail() in C:\\xampp\\htdocs\\wordpress\\wp-content\\plugins\\contact form\\contact-form-plugin.php on line 46<我在谷歌上搜索了一下,发现它与add_action( \'plugins_loaded\', \'functionShowForm\' );.我在代码中添加了这一行,但它在主窗