JSON REST API: Version 0.8

Hi everyone! Sorry about the late release, I’ve been a bit sick for most of the week, which has helped my blogging abilities but hindered my coding abilities. In any event, version 0.8 of the JSONJSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. 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/. is now available.

As always, here’s what’s changed:

  • Add compatibility layer for JsonSerializable. You can now return arbitrary
    objects from endpoints and use the jsonSerialize() method to return the data
    to serialize instead of just using the properties of the object.

    (props @rmccue, #24)

  • Fix page parent links to use /pages

    (props @thenbrent, #27)

  • Remove redundant WP_JSON_Pages::type_archive_link() function

    (props @thenbrent, #29)

  • Removed unneeded executable bit on all files

    (props @tierra, #31)

  • Don’t include the featured_image property for post types that don’t
    support thumbnails

    (props @phh, #43)

  • Use wp_json_server_before_serve instead of plugins_loaded in the Extending
    documentation for plugins

    (props @phh, #43)

  • Parse the avatarAvatar An avatar is an image or illustration that specifically refers to a character that represents an online user. It’s usually a square box that appears next to the user’s name. URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org from the get_avatar() function in coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress., allowing custom
    avatar implementations

    (props @rachelbaker, #47, #35)

  • Ensure that the author is set if passed

    (props @kuchenundkakao, #44)

  • Clarify the usage of WP_JSON_CustomPostType in plugins

    (props @rmccue, #45)

  • Ensure JSON disabled error messages are translated

    (props @rmccue, #38)

  • Remove extra “Link: ” from link headers

    (props @jmusal, #56, #30)

  • Remove redundant get_avatar method in WP_JSON_Posts

    (props @rachelbaker, #35)

  • Rename WP_JSON_Server::get_avatar() to WP_JSON_Server::get_avatar_url()

    (props @rachelbaker, #35)

You can also check out the full list of changes. We had seven contributors to this release, and I’d like to thank everyone who helped us, including creating support issues in the forum.

The big change this week is the introduction of JsonSerializable support for all versions of PHPPHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 5.6.20 or higher. This allows more complex APIs to return full objects and ensure that no data leaks via the 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.. This should help with reuse of the API internally, as you can now return objects with methods, private data, etc. It’s also a key stepping stone towards adding response objects, which should land in version 0.9.

For those that have been following along, you may notice that OAuth authentication has been bumped to 0.9. The implementation of OAuth has been a bit of a thorny one, so we’re still deciding some of the implementation for this. Given the size and scope of authentication, we don’t want to rush anything this important. That said, however, I’m aiming to push out both versions 0.9 and 1.0 in the next week to meet our Christmas deadline for version 1.0. This will result in a bit of rescheduling, but shouldn’t be a major concern.

We’re also desperately seeking help with testing the pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party. Unfortunately, while many of us are familiar with unit testing and can write the tests easily, the framework for doing so is evading us. If anyone can help us set up a testing framework, your help would be greatly appreciated.