好的-这里有一个方法-感谢@Rarst为我指明了正确的方向。
如果找不到plugins\\u api函数,请包含require文件:
if ( ! function_exists( \'plugins_api\' ) ) {
require_once( ABSPATH . \'wp-admin/includes/plugin-install.php\' );
}
然后,准备一个查询以传递给plugins\\u api():
// set the arguments to get latest info from repository via API ##
$args = array(
\'slug\' => \'plugin-slug-name\',
\'fields\' => array(
\'version\' => true,
)
);
/** Prepare our query */
$call_api = plugins_api( \'plugin_information\', $args );
/** Check for Errors & Display the results */
if ( is_wp_error( $call_api ) ) {
$api_error = $call_api->get_error_message();
} else {
//echo $call_api; // everything ##
if ( ! empty( $call_api->version ) ) {
$version_latest = $call_api->version;
}
}
参考号:
http://wp.tutsplus.com/tutorials/plugins/communicating-with-the-wordpress-org-plugin-api/