JSON REST API: Version 1.1
I’m happy to announce the availability of version 1.1 of the JSON REST API.
This release is a bit of a smaller, more focussed release as we work on increasing test coverage and squashing bugs. Here’s the juicy details:
Add new routes for taxonomies and terms.
Taxonomies and terms have now been moved from the
namespace to global routes:
Test coverage for taxonomy endpoints has also been increased to 100%.
Deprecation warning: The
sub-endpoints with the same prefix) have been deprecated in favour of the new
endpoints. These deprecated endpoints will now return a
X-WP-DeprecatedFunctionheader indicating that the endpoint should not be
used for new development, but will continue to work in the future.
Allow customizing the API resources prefix
The API base (typically
wp-json/) can now be customized to a different
prefix using the
json_url_prefixfilter. Note that rewrites will need to be
flushed manually after changing this.
nullas date for draft posts.
Draft posts would previously return “0000-00-00 00:00:00” or
“1970-01-01T00:00:00”, as draft posts are not assigned a publish date. The API
nullwhere a date is not available.
Compatibility warning: Clients should be prepared to accept
value for date/time fields, and treat it as if no value is set.
Fix errors with excerpt.
Posts without excerpts could previously return nonsense strings, excerpts from
other posts, or cause internal PHP errors. Posts without excerpts will now
always return an excerpt, typically automatically generated from the post
excerpt_rawfield was added to the edit context on posts. This field
contains the raw excerpt data saved for the post, including empty
Only expose email for edit context.
User email addresses are now only exposed for
context=edit, which requires
edit_userspermission (not required for the current user).
The email address field will now return
falseinstead of a string if the
field is not exposed.
Correct password-protected post handling.
Password-protected posts could previously be exposed to all users, however
could also have broken behaviour with excerpts. Password-protected posts are
now hidden to unauthenticated users, while content and excerpts are shown
correctly for the
(Note that hiding password-protected posts is intended to be a temporary
measure, and will likely change in the future.)
Add documentation on authentication methods.
Full documentation on authentication
is now available. This documentation explains the difference between the
various available authentication methods, and notes which should be used.
Include new client JS from github.io
wp-api.github.ioto ensure it is always up-to-date.
Don’t allow setting the modification date on post creation/update.
As it turns out, WP core doesn’t allow us to set this, so this was previously
a no-op anyway. Discovered during test coverage phase.
Check post parent correctly on insertion.
Posts could previously be added with an invalid parent ID. These IDs are now
checked to ensure the post exists.
Make sure the type is actually evaluated for
This value was previously not interpolated correctly, due to the use of the
single-quoted string type.
WP_Errorinstead of array of empty objects for a revisions
Previously, when trying to access post revisions without correct permissions,
a JSON list of internal error objects would be returned. This has been
corrected to return a standard API error instead.
Flip user parameters check for insert/update.
Previously, you could add a user without specifying username/password/email,
but couldn’t update a user without those parameters. The logic has been
inverted here instead.
Add revision endpoints tests
Add post endpoint testing
Now at >54% coverage for the whole class, and >80% for the main methods. This
figure will continue to rise over the next few releases.
Separate helper functions into global namespace.
all been moved into the global namespace to decouple them from the server
Deprecation warning: These methods have been deprecated. The new
json_parse_date()methods should now be used instead.
$ git shortlog 1.0...1.1 --summary 8 Daniel Bachhuber 12 DrewAPicture 3 Eric Lewis 2 JDGrimes 9 K.Adam White 54 Rachel Baker 128 Ryan McCue 4 Taylor Lovett 1 jeremyfelt 1 pkevan
We’ve already started work on 1.2, and as always, we’re looking for help!
With version 1.2 and onwards, we’ll be tackling a bunch of extra testing for our endpoints, with the aim of eventually reaching >90% coverage. As always, we’ll also be adding new features and fixing bugs.
We’re also working on improving the new documentation site, and expect to see the majority of documentation migrated over there. Thanks to Sarah Gooding for helping out on the documentation side.
In case you missed it, the API is now slated for integration in WordPress 4.1. WP Tavern has a great writeup on the details.
As always, we look forward to seeing you at the team o2 and on GitHub. Now’s also a great time to remind you that you can get support for the plugin on W.org, or by tweeting at me. Thanks to everyone who made this release great, and thanks to everyone using the plugin!