Just days before the first conference dedicated to the REST API, we bring you: 2.0 BetaBeta A pre-release of software that is given out to a large group of users to trial under real conditions. Beta versions have gone through alpha testing in-house and are generally fairly close in look, feel and function to the final product; however, design changes often occur as part of the process. 11 “Give me a white wine spritzer!”. Download it from the plugin repository or from GitHub.
Here are some highlightsbreaking changes from the changelog:
- Moves Post->Term relations to the Post Resource. Previously, a client would fetch a Post’s Tags with
GET /wp/v2/posts/<id>/tags. In Beta 11, an array of term ids is included on the Post resource. The collection of terms for a Post can be fetched withGET /wp/v2/tags?post=<id>. TheWP_REST_Posts_Terms_Controllerclass no longer exists. - Changes
featured_imageattribute on Posts tofeatured_media. While featuring other attachment types isn’t yet officially supported, this makes it easier for us to introduce the possibility in the future. - Uses discrete schema title for categories and tags. If you’ve used
register_rest_field( 'term' ), you’ll need to change'term'to'tag'and/or'category'. - Makes many filters dynamic based on the controller type. If you were using the
rest_prepare_termfilterFilter 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., you’ll need to change it torest_prepare_post_tagorrest_prepare_category. If you were usingrest_post_queryorrest_terms_query, you’ll need update your use torest_page_query, etc. If you were usingrest_post_trashable,rest_insert_postorrest_delete_post, they are now dynamic based on the post type slug.
As always, we have a detailed changelog as well as the full set of changes if you’re interested.