WordPress 5.3 contains a number of REST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/. improvements designed to make it easier and faster to work with API An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. data from the block Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. editor or other client applications.
Register Array & Object Metadata
As covered previously in this developer note on array & object metadata, it is now possible to use
register_term_meta (as well as the underlying method
Nested response filtering with _fields query parameter
This developer note on the changes to the REST API’s
_fields= query parameter shows how you may now filter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. your REST API response objects to include only specific nested properties within the response body.
Ticket Created for both bug reports and feature development on the bug tracker. #42094
Set drafts back to “floating date” status
Once a date has been set for a draft, it was previously impossible to set the post back to showing “publish immediately” (also referred to as a “floating date,” where the post will be dated whenever it is published). As of 5.3, passing
null for a date value will unset the draft date and restore this floating state.
We have introduced a caching wrapper around the generation of REST resource schema objects, which initial testing has shown to yield up to a 30-40% performance increase in large API responses. If you work with expensive or large REST API queries, things should be quite a bit faster now. (Ticket #47871)
The REST API has also been improved to avoid unnecessary controller object instantiation (#45677) and to skip generation of sample permalinks when that data is not requested (#45605).
Please Note: if your team has existing performance benchmarking tooling for the REST API, please contact the component maintainers in the
#core-restapi Slack Slack is a Collaborative Group Chat Platform https://slack.com/. The WordPress community has its own Slack Channel at https://make.wordpress.org/chat/. channel; we very much desire to expand our metrics in this area.
Additional Changes of Note
In addition to these key enhancements, there are a number of smaller improvements to the REST API which may be of interest to developers.
- It is no longer possible to DELETE a Revision resource using the REST API, as this behavior could break a post’s audit trail. Ticket #43709
/search endpoint will now correctly embed the full original body of each matched resource when passing the
_embed query parameter. Ticket #47684
rest_ensure_request now accept a string API path, so it is possible to instantiate a request in PHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher using nothing more than the desired endpoint string, e.g.
rest_do_request( '/wp/v2/posts' );
- Creating or updating a Terms resource via the REST API now returns the updated object using the “edit” context. Ticket #41411
- It is now possible to edit a posted comment through the REST API when authenticating the request as a user with the
moderate_comments capability. Previously a full editor- or admin (and super admin)-level role was needed. Ticket #47024
rest_get_avatar_urls now receives the entire User or Comment object, not just the object’s email address. Ticket #40030
Welcoming Timothy Jacobs as a REST API component maintainer
Last but not least, many of you have no doubt seen @timothyblynjacobs active in trac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress., slack, and community events. Timothy has driven much of the momentum that resulted in the above improvements, and I’m excited to (belatedly) announce that he has joined the REST API team as an official component maintainer. Thank you very much for your energy and dedication!
Thank you also to every other person who contributed to API changes this cycle; it’s the best version of the REST API yet, and we couldn’t have done it without the dozens of contributors who helped create, review and land these patches.
We’ve got some ambitious ideas about how we can make the REST API even better in 5.4. Interested in helping out, with code, docs, or triage The act of evaluating and sorting bug reports, in order to decide priority, severity, and other factors.? Join us for weekly office hours, every week on Thursdays at 1800 UTC!