我想我迟到了,但根据新的指导方针,我发现这是最好的解决方案
// Set the arguments. For brevity of code, I will set only a few fields.
$args = array(
\'slug\' => \'akismet\', // or any plugin slug
\'fields\' => array(
\'version\' => true
)
);
// Make request and extract plug-in object. Action is query_plugins
$response = wp_remote_post(
\'http://api.wordpress.org/plugins/info/1.0/\',
array(
\'body\' => array(
\'action\' => \'plugin_information\',
\'request\' => serialize((object)$args)
)
)
);
//
if ( !is_wp_error($response) ) {
$returned_object = unserialize(wp_remote_retrieve_body($response));
if ($returned_object) {
$downloaded = $returned_object->downloaded;
print_r($downloaded);
}
else {
// Response body does not contain an object/array
echo "An error has occurred.";
}
}
else {
// Error object returned
echo "An error has occurred";
}