WP REST API: Version 2.0 Beta 2

A mere four weeks since releasing the first 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. of version 2, the REST APIREST 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/. team has returned to announce the second beta of version 2 is available. Adding more than forty enchancements and bugfixes, WP REST API: 2.0 Beta 2 “You Finally Made a Monkey Out of Me” is available for download on Github.

Some important highlights in version 2.0 Beta 2 are:

  • Load the WP REST API before the main query runs.

    The rest_api_loaded function now hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. into the parse_request action. This change prevents the main query from being run on every request and allows sites to set WP_USE_THEMES to false. Previously, the main query was always being run (SELECT * FROM wp_posts LIMIT 10), even though the result was never used and couldn’t be cached.

    (props @rmccue, #1270)

  • Register a new field on an existing WordPress object type.

    Introduces register_api_field() to add a field to an object and its schema. For example, adding a seo_title to all post objects, you provide register_api_field with a callback function to get the value for a post, a callback for updating the value and a schema to describe the field to APIAPI 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. clients.

    (props @joehoyle, @rachelbaker, #927)
    (props @joehoyle, #1207)
    (props @joehoyle, #1243)

  • Add endpoints for viewing, creating, updating, and deleting Terms for a Post.

    The new WP_REST_Posts_Terms_Controller class controller supports routes for
    Terms that belong to a Post. You can now remove and add terms on posts (finally!)

    (props @joehoyle, @danielbachhuber, #1216)

  • Add pagination headers for collection queries.

    The X-WP-Total and X-WP-TotalPages are now present in terms, comments, and users collection responses.

    (props @danielbachhuber, #1182)
    (props @danielbachhuber, #1191)
    (props @danielbachhuber, @joehoyle, #1197)

  • List registered namespaces in the index for feature detection.

    The index (/wp-json by default) now contains a list of the available namespaces. This allows for simple feature detection. You can grab the index and check namespaces for wp/v3 or pluginname/v2, which indicate the supported endpoints on the site.

    (props @rmccue, #1283)

  • Standardize link property relations and support embedding for all resources.

    Change link properties to use IANA-registered relations. Also adds embedding support to Attachments, Comments and Terms.

    (props @rmccue, @rachelbaker, #1284)

  • Add support for Composer dependency management.

    Allows you to recursively install/update the WP REST API inside of WordPress plugins or themes.

    (props @QWp6t, #1157)

  • Return full objects in the delete response.

    Instead of returning an inconsistent message when deleting a Post, Comment, Term, or User, the API will now return the original resource data.

    (props @danielbachhuber, #1253)
    (props @danielbachhuber, #1254)
    (props @danielbachhuber, #1255)
    (props @danielbachhuber, #1256)

View all changes

#json-api, #rest-api