我想要使用这个函数来获取一些信息,但是如何获取我所需要的数据呢?例如,对于wp_get_data(),我会这样做
$example = wp_get_update_data();
echo $example ['title'];或
echo $example['count']['plugins']; 打印我想要的数据。对于get_plugin_updates(),不要调用我需要的东西。我想要回显名称-plugin\实际版本/更新版本
发布于 2020-02-07 07:48:04
欢迎。
函数返回所有可能更新的数组。意味着您需要指定需要获取其信息的插件。
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;https://wordpress.stackexchange.com/questions/358047
复制相似问题