欢迎
函数返回所有可能更新的数组。意味着您需要指定获取其信息所需的插件。
的样本输出get_plugin_updates
拜访admin_init
:
array(1) {
["fast-velocity-minify/fvm.php"]=>
object(stdClass)#7844 (14) {
["Name"]=>
string(20) "Fast Velocity Minify"
["PluginURI"]=>
string(23) "http://fastvelocity.com"
["Version"]=>
string(5) "2.7.7"
["Description"]=>
string(192) "Improve your speed score on GTmetrix, Pingdom Tools and Google PageSpeed Insights by merging and minifying CSS and JavaScript files into groups, compressing HTML and other speed optimizations."
["Author"]=>
string(12) "Raul Peixoto"
["AuthorURI"]=>
string(23) "http://fastvelocity.com"
["TextDomain"]=>
string(20) "fast-velocity-minify"
["DomainPath"]=>
string(0) ""
["Network"]=>
bool(false)
["RequiresWP"]=>
string(0) ""
["RequiresPHP"]=>
string(0) ""
["Title"]=>
string(20) "Fast Velocity Minify"
["AuthorName"]=>
string(12) "Raul Peixoto"
["update"]=>
object(stdClass)#7799 (12) {
["id"]=>
string(34) "w.org/plugins/fast-velocity-minify"
["slug"]=>
string(20) "fast-velocity-minify"
["plugin"]=>
string(28) "fast-velocity-minify/fvm.php"
["new_version"]=>
string(5) "2.7.8"
["url"]=>
string(51) "https://wordpress.org/plugins/fast-velocity-minify/"
["package"]=>
string(69) "https://downloads.wordpress.org/plugin/fast-velocity-minify.2.7.8.zip"
["icons"]=>
array(1) {
["1x"]=>
string(73) "https://ps.w.org/fast-velocity-minify/assets/icon-128x128.jpg?rev=1440946"
}
["banners"]=>
array(1) {
["1x"]=>
string(75) "https://ps.w.org/fast-velocity-minify/assets/banner-772x250.jpg?rev=1440936"
}
["banners_rtl"]=>
array(0) {
}
["tested"]=>
string(5) "5.3.2"
["requires_php"]=>
string(3) "5.6"
["compatibility"]=>
object(stdClass)#7800 (0) {
}
}
}
}
因此,您需要在获取插件名称之前指定插件。您需要将代码更改为以下代码:
$plugin_updates = get_plugin_updates();
// Print plugin name.
echo [\'my-plugin/my-plugin.php\']->Name;
// Print plugin update version.
echo [\'my-plugin/my-plugin.php\']->update->new_version;