admin管理员组文章数量:1300199
I'm trying out adding WordPress REST API endpoints. I would now like to add an endpoint that retrieves a list of available plugin, theme and core updates.
I found the following functions: get_plugin_updates()
, get_theme_updates()
and get_core_updates()
. With these functions I could retrieve info about which plugins to update.
How do I start the update proces for a plugin/theme/core? I'm especially looking for updating an individual item. Similar to WP Manage and GoDaddy Hub.
It would be great if someone could tell me how to implement this and how to start the update process!
I'm trying out adding WordPress REST API endpoints. I would now like to add an endpoint that retrieves a list of available plugin, theme and core updates.
I found the following functions: get_plugin_updates()
, get_theme_updates()
and get_core_updates()
. With these functions I could retrieve info about which plugins to update.
How do I start the update proces for a plugin/theme/core? I'm especially looking for updating an individual item. Similar to WP Manage and GoDaddy Hub.
It would be great if someone could tell me how to implement this and how to start the update process!
Share Improve this question asked Mar 23, 2021 at 17:06 ralphjsmitralphjsmit 4026 silver badges23 bronze badges1 Answer
Reset to default 1REST or anything RESTful is a generally adhered to standard of getting things done via API. It also has the capability of documenting itself.
Now I had expected to write an answer here about how it's not a great idea to allow endpoints to update or modify any of your codebase but I see it seems the good folks at Automattic have thought it ok and they know the core a lot better than I do, I also presume you need to be authenticated before using it.
Go to [yourwordpresswebsite]/wp-json/
It brings up a sort of library of endpoints and how to use them
If you go to routes
then find "/wp/v2/plugins/(?P<plugin>[^.\/]+(?:\/[^.\/]+)?)"
and endpoints
You can see the following
0 "GET"
args {…}
1
methods
0 "POST"
1 "PUT"
2 "PATCH"
args {…}
2
methods
0 "DELETE"
Which you can match up in the REST API docs on plugins
This sort of updating via API should IMO only be done for ease of something like mass-rollout. Say you have a hundred servers running the same core setup and your testing has concluded it's safe.
You can also just set up WordPress to update itself automatically instead and save yourself the bother.
There are some interesting examples of using composer to install / update WordPress. Look at johnpbloch, satispress. Also off the shelf Wordfence Central
本文标签: How to execute plugin and theme updates from a web hookendpoint
版权声明:本文标题:How to execute plugin and theme updates from a web hookendpoint? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741659294a2390941.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论