-
Introduce support for Post Meta, Term Meta, User Meta, and Comment Meta in their parent endpoints.
For your meta fields to be exposed in the REST API, you need to register them. WordPress includes a
register_meta()
function which is not usually required to get/set fields, but is required for API support.To register your field, simply call register_meta and set the show_in_rest flag to true. Note: register_meta must be called separately for each meta key.
(props @rmccue, @danielbachhuber, @kjbenk, @duncanjbrown, #2765)
-
Introduce Settings endpoint.
Expose options to the REST API with the
register_setting()
function, by passing$args = array( 'show_in_rest' => true )
. Note: WordPress 4.7 is required. See changeset [38635][https://core.trac.wordpress.org/changeset/38635].(props @joehoyle, @fjarrett, @danielbachhuber, @jonathanbardo, @greatislander, #2739)
-
Attachments controller, change permissions check to match core.
Check for the
upload_files
capability when creating an attachment.(props @nullvariable, @adamsilverstein, #2743)
-
Add
?{taxonomy}_exclude=
query parameterThis mirrors our existing support for ?{taxonomy}= filtering in the posts controller (which allows querying for only records with are associated with any of the provided term IDs for the specified taxonomy) by adding an equivalent
_exclude
variant to list IDs of terms for which associated posts should NOT be returned.(props @kadamwhite, #2756)
-
Use
get_comment_type()
when comparing updating comment status.Comments having a empty
comment_type
within WordPress bites us again. Fixes a bug where comments could not be updated because of bad comparison logic.(props @joehoyle, #2753)
-
Add support for password protected posts
Password protected posts are now fully supported, you can create edit and read password protected posts in the REST API. There is now a
protected
attribute in thecontent
andexcerpt
fields in post response.To view password protected posts via the API, use the
password
query parameter to provide the post's password.(props @joehoyle, #2720)
-
Allow returning an error from field update callbacks
Fields added via
register_rest_field
can now return an instance ofWP_Error
in theupdate_callback
.(props @rmccue, #2702)
-
Update the wp-api.js client from the client-js repo.
(props @joehoyle, #2746)
-
Add
relevance
orderby
to posts endpoint(props @websupporter, #2579)
-
Ability to order by
slug
,email
andurl
on the users endpoints.(props @joehoyle, #2721)
-
Add
sticky
parameter to the posts endpoint.(props @joehoyle, #2708)
-
Add link to comment children, allowing threaded comment querying
-
Avoid unnecessary SQL query by passing
$user_nicename
(props @danielbachhuber, #2435)
-
Don't allow reading / creating of posts with no parent
(props @rachelbaker, #2744)
-
Mark Users'
capabilities
property as readonly(props @danielbachhuber, #2440)
-
Mark some post properties as readonly
-
Use WPINC instead of wp-includes/
(props @websupporter, #2461)
-
Return error, if user can't list users & content=edit
(props @websupporter, #2463)
-
Conditionally model the term response based on its schema
(props @danielbachhuber, #2470)
-
Include Post data on the response object when declared
-
Add boolean type support to rest_validate_request_arg()
(props @westonruter, #2478)
-
Fix create/update requests not processing data included in the schema
(props @websupporter, #2479)
-
Remove Unused Parameter in lib/endpoints/class-wp-rest-controller.php
(props @hideokamoto, #2500)
-
Update post schema status description to reflect csv support.
(props @coderkevin, #2534)
-
Allow Comments to be created with a passed
author_ip
(props @rachelbaker, #1880)
-
The get_the_excerpt filter expects the post object as of WP 4.5.
(props @lgedeon, #2553)
-
Introduce WP_REST_Controller::get_post() for allowing plugins to mutate get_post()'s return value
(props @westonruter, #2535)
-
Use
show_in_rest
to determine "public" post types to check(props @danielbachhuber, #2384)
-
#2426 Fix inconsistent type for user caps
-
Define user
type
as a string, not an array(props @danielbachhuber, #2556)
-
Fix failing test: Typecast the user_id in search to a string
(props @rachelbaker, #2617)
-
#2587 Fix registered date schema
-
Fix forum url and installer-name in readme
(props @torounit, #2656)
-
Document options of the "status" parameter for Post collection GETs
(props @kadamwhite, #2645)
-
Improve WP_REST_Controller::filter_response_by_context().
(props @tfrommen, #2641)
-
#2424 Consistent slashes in rest_url() usage
-
Add filters to allow for relevance search
(props @websupporter, #2665)
-
Alter default comment sort order to be "desc"
(props @kadamwhite, #2684)
-
Add raw and rendered to revisions schema
(props @websupporter, #2693)
-
"WP API" -> "WordPress REST API" in README files
(props @kadamwhite, #2697)
-
Improve boolean validation from schema
-
Fix typo (PUT vs POST) in readme.md
(props @kadamwhite, #2716)
-
Add Codecov configuration
(props @danielbachhuber, #2718)
-
Fix inefficiency in users endpoint using
search => **
(props @joehoyle, #2722)
-
Ensure the terms list is a list
(props @joehoyle, #2724)
-
Added @return on handle_featured_media() doc
(props @vishalkakadiya, #2725)
-
#2730 Update attachments fields added with
register_rest_field
-
#2582 Ensure the
roles
property is always an array -
Move post_password_required filtering to preparation
(props @rmccue, #2735)
-
Use wrapper for
sanitize_title
to avoid messed up slugs.(props @joehoyle, #2723)
-
Force per_page to override the filter variable
(props @rmccue, #2699)
-
BREAKING CHANGE: Fix Content-Disposition header parsing.
Allows regular form submissions from HTML forms, as well as properly formatted HTTP requests from clients. Note: this breaks backwards compatibility, as previously, the header parsing was completely wrong.
(props @rmccue, #2239)
-
BREAKING CHANGE: Use compact links for embedded responses if they are available.
Introduces curies for sites running WordPress 4.5 or greater; no changes for those running WordPress 4.4.
(props @joehoyle, #2412)
-
JavaScript client updates:
- Support lodash, plus older and newer underscore: add an alias for
_.contains
- Add args and options on the model/collection prototypes
- Rework category/tag mixins to support new API structure
- Add workaround for the null/empty values returned by the API when creating a new post - these values are not accepted for subsequent updates/saves, so explicitly excluding them. See WP-API#2393
- Better handling of the (special)
me
endpoint - Schema parsing cleanup
- Introduce
wp.api.loadPromise
so developers can ensure api load complete before using
(props @adamsilverstein, #2403)
- Support lodash, plus older and newer underscore: add an alias for
-
Only adds alternate link header for publicly viewable CPTs.
(props @bradyvercher, #2387)
-
Adds
roles
param forGET /wp/v2/users
.(props @BE-Webdesign, #2372)
-
Declares
password
in user schema, but never displays it.(props @danielbachhuber, #2386)
-
Permits
edit
context for requests which can edit the user.(props @danielbachhuber, #2383)
-
Adds
rest_pre_insert_{$taxonomy}
filter for terms.(props @kjbenk, #2377)
-
Supports taxonomy collection args on posts endpoint.
(props @joehoyle, #2287)
-
Removes post meta link from post response.
(props @joehoyle, #2288)
-
Registers
description
attribute when registering args from schema.(props @danielbachhuber, #2362)
-
Uses
$comment
from the database withrest_insert_comment
action.(props @danielbachhuber, #2349)
-
Removes unnecessary global variables from users controller.
(props @claudiosmweb, #2335)
-
Ensures
GET /wp/v2/categories
with out of bounds offset doesn't return results.(props @danielbachhuber, #2313)
-
Adds top-level support for date queries on posts and comments.
-
Respects
show_avatars
setting for comments.(props @BE-Webdesign, #2271)
-
Uses cached
get_the_terms()
for terms-for-post for better performance.(props @rmccue, #2257)
-
Ensures comments search is an empty string.
(props @rmccue, #2256)
-
If no title is provided in create attachment request or file metadata, falls back to filename.
(props @danielbachhuber, #2254)
-
Removes unused
$img_url_basename
variable in attachments controller.(props @danielbachhuber, #2250)
-
BREAKING CHANGE: Removes meta endpoints from primary plugin.
If your project depends on post meta endpoints, please install WP REST API Meta Endpoints. For the gory history of meta, read #1425 and linked issues. At this time, we recommend using
register_rest_field()
to expose meta (docs).(props @danielbachhuber, #2172)
-
BREAKING CHANGE: Returns original resource when deleting PTCU.
Now that all resources require the
force
param, we don't need to wrap delete responses with thetrash
state.(props @danielbachhuber, #2163)
-
BREAKING CHANGE: Uses
roles
rather thanrole
in the Users controller.Building the REST API gives us the opportunity to standardize on
roles
, instead of having bothroles
androle
.(props @joehoyle, #2177)
-
BREAKING CHANGES: Moves to consistent use of
context
throughout controllers.Contexts limit the data present in the response. Here's how to think of them:
embed
correlates with sidebar representation,view
represents the primary public view, andedit
is the data expected for an editor.(props @danielbachhuber, #2205, #2204, #2203, #2218, #2216, #2230, #2184, #2235)
-
BREAKING CHANGE: Removes
post_*
query param support forGET /wp/v2/comments
.The proper pattern is to use
GET /wp/v2/posts
to fetch the post IDs to limit the request to.(props @danielbachhuber, #2165)
-
BREAKING CHANGE: Introduces
rest_validate_request_arg()
/rest_sanitize_request_arg()
.Dedicated functions means we can use them for validating / sanitizing query args too. Removes
WP_REST_Controller::validate_schema_property()
andWP_REST_Controller::sanitize_schema_property()
. -
Requires minimum value of 1 for
page
param.(props @danielbachhuber, #2241)
-
Introduces
media_type
andmime_type
params forGET /wp/v2/media
.(props @danielbachhuber, #2231)
-
Uses the term cache for post data.
(props @rmccue, #2234)
-
Supports for querying comments where
post=0
.(props @danielbachhuber, #1865)
-
Exposes taxonomy and post type capabilities in
context=edit
.(props @danielbachhuber, #2216)
-
Errors early when user can't GET types or taxonomies when
context=edit
.(props @danielbachhuber, #2218)
-
Passes original $request context to
prepare_items_query
.(props @danielbachhuber, #2211)
-
Adds
parent
andparent_exclude
params to GET Comments.(props @danielbachhuber, #2206)
-
Enforces minimum 1 and maximum 100 values for
per_page
parameter.(props @danielbachhuber, #2209)
-
Adds
author
andauthor_exclude
params to GET Posts and Comments. -
Adds
menu_order
param forGET
Pages; supportmenu_order
orderby.(props @danielbachhuber, #2193)
-
Only calls
sanitize_text_field()
when sanitizingtype=string,format=email
.(props @danielbachhuber, #2185)
-
Validates
GET /wp/v2/comments
private query params.Returns an error when user doesn't have permission to use them, instead of silently discarding.
(props @danielbachhuber, #2178)
-
Explicitly prevents uploading attachments to other attachments or revisions.
(props @danielbachhuber, #2180)
-
Permits user urls to be edited through the API.
(props @danielbachhuber, #2182)
-
Marks all Status, Type and Taxonomy fields as
readonly
.(props @danielbachhuber, #2181)
-
Adds validation callbacks to collection query params.
-
Links taxonomy terms to the post type collections they support.
(props @danielbachhuber, #2167)
-
Returns error when making a
GET
request with invalid context.(props @danielbachhuber, #2169)
-
Adds
trash
status toGET /wp/v2/statuses
.(props @danielbachhuber, #2158)
-
Indicates when fields have HTML in schema.
(props @joehoyle, #2159)
-
Permits viewing of User who has published any Public posts.
(props @danielbachhuber, #2155)
-
Respects
show_avatars
option when adding avatars to Users.(props @nullvariable, #2151)
-
Controllers use
$namespace
and$rest_base
class variables for easier subclassing.(props @danielbachhuber, #2119, #2130, #2131, #2132, #2133, #2134, #2139, #2141, #2142)
-
BREAKING CHANGE: 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 with
GET /wp/v2/tags?post=<id>
.The
WP_REST_Posts_Terms_Controller
class no longer exists.(props @joehoyle, #2063)
-
BREAKING CHANGE: Adds latest JS client including a minified version.
See pull request for a summarized changelog.
(props @adamsilverstein, #1981)
-
BREAKING CHANGE: Changes
featured_image
attribute 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.
(props @danielbachhuber, #2044)
-
BREAKING CHANGE: 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'
.(props @danielbachhuber, #2005)
-
BREAKING CHANGE: Makes many filters dynamic based on the controller type.
If you were using the
rest_prepare_term
filter, you'll need to change it torest_prepare_post_tag
orrest_prepare_category
.If you were using
rest_post_query
orrest_terms_query
, you'll need update your use torest_page_query
, etc.If you were using
rest_post_trashable
,rest_insert_post
orrest_delete_post
, they are now dynamic based on the post type slug. -
Renames
GET /wp/v2/comments
user
param toauthor
to match resource attribute.Not a breaking change, because it didn't work in the first place.
(props @danielbachhuber, #2105)
-
Adds support for
GET /wp/v2/pages parent=1,2,3
.(props @danielbachhuber, #2101)
-
Persists image metadata title and caption when not present in the request.
(props @danielbachhuber, #2079)
-
Add
parent_exclude
param toGET /wp/v2/posts
.(props @danielbachhuber, #2077)
-
Adds
slug
param support for collections of Posts, Users, and Taxonomy Terms. -
When a comment is already trashed, returns
410:rest_already_trashed
.(props @danielbachhuber, #2069)
-
Filter the responses by context after processing additional fields.
(props @danielbachhuber, #2067)
-
Adds
offset
param support for collections of Posts, Users, Comments, and Taxonomy Terms. -
Adds
rest_insert_{$taxonomy}
andrest_delete_{$taxonomy}
actions.(props @danielbachhuber, #2060)
-
Provides more helpful error message/code on Post Create/Update fail.
(props @danielbachhuber, #2053)
-
Forces
GET /wp/v2/media
to be limited to'status' => [ inherit, private, trash ]
(props @danielbachhuber, #2026)
-
Uses more correct error code for
Comment::delete
permission check.(props @danielbachhuber, #2054)
-
Calls
prepare_item_for_response()
directly in create and update methods.This lets us pass the original request through, giving the method and its filter genuine context, and avoids an unnecessary call to
get_item()
. -
Moves permission check methods across controllers.
Placing them above the method they're supposed to check makes the code more readable.
(props @danielbachhuber, #2030, #2029, #2034, #2036, #2037, #2035, #2039)
-
Requires
force
argument forDELETE /wp/v2/<taxonomy>/<id>
.(props @danielbachhuber, #2028)
-
Conditionally requires and defines REST API classes and functions.
-
Avoid a duplicate query for the comment count.
(props @rmccue, #2015)
-
Parses
$date
if available inprepare_date_response()
(props @adamsilverstein, #1951)
-
Abstracts
POST /wp/v2/media
permissions check.(props @danielbachhuber, #2003)
-
Adds
exclude
param to getting collections of Posts, Users, Comments, and Taxonomy Terms. -
Adds
rest_comment_query
for filteringGET /wp/v2/comments
.(props @danielbachhuber, #2007)
-
Uses HTTP status code
500
fordb_update_error
when creating an attachment.(props @danielbachhuber, #1993)
-
Adds helpful description to
force
param across allDELETE
registrations -
In
GET /wp/v2/<taxonomy>
, drops support fororderby=>term_id
.Only one
id
is exposed through the REST API.(props @danielbachhuber, #1990)
-
SECURITY: Ensure media of private posts are private too.
Reported by @danielbachhuber on 2016-01-08.
-
BREAKING CHANGE: Removes compatibility repo for WordPress 4.3.
WordPress 4.4 is now the minimum supported WordPress version.
(props @danielbachhuber, #1848)
-
BREAKING CHANGE: Changes link relation for types and taxonomies.
In Beta 9, this link relation was introduced as
item
, which isn't correct. The relation has been changed tohttps://api.w.org/items
.(props @danielbachhuber, #1853)
-
BREAKING CHANGE: Introduces
edit
context forwp/v2/types
andwp/v2/taxonomies
.Some fields have moved into this context, which require
edit_posts
andmanage_terms
, respectively. -
BREAKING CHANGE: Removes
post_format
as a term_link
for Posts.Post formats aren't a custom taxonomy in the eyes of the REST API.
(props @danielbachhuber, #1854)
-
Declares
parent
query param for Pages.(props @danielbachhuber, #1975)
-
Permits logged-in users to query for media.
(props @danielbachhuber, #1973)
-
Removes duplicated query params from Terms controller.
(props @danielbachhuber, #1963)
-
Adds
include
param to/wp/v2/posts
,/wp/v2/users
,/wp/v2/<taxonomy>
and/wp/v2/comments
. -
Ensures
GET /wp/v2/posts
respectsorder
andorderby
params.(props @danielbachhuber, #1962)
-
Fixes fatal by loading
wp-admin/includes/user.php
to exposewp_delete_user()
.(props @danielbachhuber, #1958)
-
Permits making a post sticky when also supplying an empty password.
(props @westonruter, #1949)
-
Uses
WP_REST_Request
internally across controllers. -
Cleans up permissions checks in
WP_REST_Terms_Controller
.(props @danielbachhuber, #1941)
-
Uses
show_in_rest
to determine publicness for post types.(props @danielbachhuber, #1942)
-
Makes
description
strings available for translation.(props @danielbachhuber, #1944)
-
Checks
assign_terms
cap for taxonomy when managing post terms.(props @danielbachhuber, #1940)
-
Defer to
edit_posts
of the custom post type when accessing private query vars.(props @danielbachhuber, #1886)
-
Allows Terms collection params to be filtered.
(props @rachelbaker, #1882)
-
Renames post terms create/delete permissions callback.
(props @wpsmith, #1923)
-
Fixes invalid use of 'uri' as schema
type
.(props @wpsmith, #1913)
-
Casts integer with (int) over intval for speed.
(props @wpsmith, #1907)
-
Fixes PHP Doc typo for
validate_schema_property
andsanitize_schema_property
. -
Adds a helpful description to the
filter
argument.(props @danielbachhuber, #1885)
-
Changes order of Users response to match schema order.
(props @rachelbaker, #1879)
-
Adjusts Posts pagination headers for
filter
params.(props @rachelbaker, #1878)
-
Uses proper status code when failing to get comments of private post.
(props @danielbachhuber, #1866)
-
Fixes invalid capability for comments get items permissions callback.
manage_comments
doesn't exist;moderate_comments
does.(props @danielbachhuber, #1866)
-
Permits creating comments without an assigned post.
(props @danielbachhuber, #1857)
-
Prevents error notice when
show_in_rest
isn't set for a post type.(props @danielbachhuber, #1852)
-
BREAKING CHANGE: Move tags and categories to top-level endpoints.
Tags are now accessible at
/wp/v2/tags
, and categories accessible at/wp/v2/categories
. Post terms reside at/wp/v2/posts/<id>/tags
and/wp/v2/<id>/categories
.(props @danielbachhuber, #1802)
-
BREAKING CHANGE: Return object for requests to
/wp/v2/taxonomies
.This is consistent with
/wp/v2/types
and/wp/v2/statuses
.(props @danielbachhuber, #1825)
-
BREAKING CHANGE: Remove
rest_get_timezone()
.json_get_timezone()
was only ever used in v1. This function causes fatals, and shouldn't be used.(props @danielbachhuber, #1823)
-
BREAKING CHANGE: Rename
register_api_field()
toregister_rest_field()
.Introduces a
register_api_field()
function for backwards compat, which calls_doing_it_wrong()
. However,register_api_field()
won't ever be committed to WordPress core, so you should update your function calls.(props @danielbachhuber, #1824)
-
BREAKING CHANGE: Change taxonomies'
post_type
argument totype
.It's consistent with how we're exposing post types in the API.
(props @danielbachhuber, #1824)
-
Sync infrastructure with shipped in WordPress 4.4.
-
Change terms endpoints to use
term_id
nottt_id
.(props @joehoyle, #1837)
-
Standardize declaration of
context
param forGET
requests across controllers.However, we're still inconsistent in which controllers expose which params. Follow #1845 for further discussion.
-
Link types / taxonomies to their collections, and vice versa.
Collections link to their type / taxonomy with the
about
relation; types / taxonomies link to their colletion with theitem
relation, which is imperfect and may change in the future. -
Add missing 'wp/v2' in Location Response header when creating new Post Meta.
(props @johanmynhardt, #1790)
-
Expose Post collection query params, including
author
,order
,orderby
andstatus
.(props @danielbachhuber, #1793)
-
Ignore sticky posts by default.
(props @danielbachhuber, #1801)
-
Include
full
image size in attachmentsizes
attribute.(props @danielbachhuber, #1806)
-
In text strings, use
id
instead ofID
.ID
is an implementation artifact. Our Resources useid
.(props @danielbachhuber, #1803)
-
Ensure
attachment.sizes[]
usemime_type
instead ofmime-type
.(props @danielbachhuber, #1809)
-
Introduce
rest_authorization_required_code()
.Many controllers returned incorrect HTTP codes, which this also fixes.
(props @danielbachhuber, #1808)
-
Respect core's
comment_registration
setting.If it's enabled, require users to be logged in to comment.
(props @danielbachhuber, #1826)
-
Default to wildcard when searching users.
(props @danielbachhuber, #1827)
-
Bring the wp-api.js library up to date for v2 of the REST API.
(props @adamsilverstein, #1828)
-
Add
rest_prepare_status
filter.(props @danielbachhuber, #1830)
-
Make
prepare_*
filters more consistent.(props @danielbachhuber, #1831)
-
Add
rest_prepare_post_type
filter for post types.(props @danielbachhuber, #1833)
-
Prevent fatals when uploading attachment by including admin utilities.
(props @danielbachhuber, #1756)
-
Return 201 status code when creating a term.
(props @danielbachhuber, #1753)
-
Don't permit requesting terms cross routes.
Clients should only be able to request categories from the category route, and tags from the tag route.
(props @danielbachhuber, #1764)
-
Set
fields=>id
when usingWP_User_Query
to fix large memory usage(props @joehoyle, #1770)
-
Fix Post
_link
to attached attachments.(props @danielbachhuber, #1777)
-
Add support for getting a post with a custom public status.
(props @danielbachhuber, #1765)
-
Ensure post content doesn't get double-slashed on update.
(props @joehoyle, #1772)
-
Change 'int' to 'integer' for
WP_REST_Controller::validate_schema_property()
(props @wpsmith, #1759)
-
Sync infrastructure from WordPress core as of r35691.
- Remove
register_api_field()
because it's conceptually tied toWP_REST_Controller
#34730 - Update the REST API header links to use api.w.org #34303
- Require the
$namespace
argument inregister_rest_route()
#34416 - Include
enum
anddescription
in help data #34543 - Save
preg_match
iterations inWP_REST_Server
#34488 - Don't return route URL in
WP_REST_Request:get_params()
#34647
- Remove
-
Restore
register_api_field()
within the plugin.(props @danielbachhuber, #1748)
-
Require admin functions for use of
wp_handle_upload()
, fixing fatal.(props @joehoyle, #1746)
-
Properly handle requesting terms where
parent=0
and0
is a string.(props @danielbachhuber, #1739)
-
Prevent PHP error notice when
&filter
isn't an array.(props @danielbachhuber, #1734)
-
Change link relations to use api.w.org.
(props @danielbachhuber, #1726)
-
Remove global inclusion of wp-admin/includes/admin.php
For a long time, the REST API loaded wp-admin/includes/admin.php to make use of specific admin utilities. Now, it only loads those admin utilities when it needs them.
If your custom endpoints make use of admin utilities, you'll need to make sure to load wp-admin/includes/admin.php before you use them.
(props @joehoyle, #1696)
-
Link directly to the featured image in a Post's links.
-
Provide object type as callback argument for custom API fields.
(props @jtsternberg, #1714)
-
Change users schema order to be order of importance instead of alpha.
(props @rachelbaker, #1708)
-
Clarify documentation for
date
andmodified
attributes.(props @danielbachhuber, #1715)
-
Update the wp-api.js client from the client-js repo.
(props @rachelbaker, #1709)
-
Fix the
format
enum to be an array of strings.(props @joehoyle, #1707)
-
Run revisions for collection through
prepare_response_for_collection()
.(props @danielbachhuber, @rachelbaker, #1671)
-
Expose
date_gmt
forview
context of Posts and Comments.(props @danielbachhuber, #1690)
-
Fix PHP and JS docblock formatting.
(props @ahmadawais, #1699, #1699, #1701, #1700, #1702, #1703)
-
Include
media_details
attribute for attachments in embed context.For image attachments, media_details includes a sizes array of image sizes, which is useful for templating.
(props @danielbachhuber, #1667)
-
Make
WP_REST_Controller
error messages more helpful by specifying method to subclass.(props @danielbachhuber, #1670)
-
Expose
slug
inembed
context for Users.user_nicename
is a public attribute, used in user URLs, so this is safe data to present.(props @danielbachhuber, #1666)
-
Handle falsy value from
wp_count_terms()
, fixing fatal.(props @joehoyle, #1641)
-
Correct methods in
WP_REST_SERVER::EDITABLE
description.(props @rachelbaker, #1601)
-
Add the embed context to Users collection query params.
(props @rachelbaker, #1591)
-
Add Terms Controller collection args details.
(props @rachelbaker, #1603)
-
Set comment author details from current user.
(props @rmccue, #1580)
-
More hook documentation.
-
Return the trashed status of deleted posts/comments.
When a post or a comment is deleted, returns a flag to say whether it's been trashed or properly deleted.
(props @pento, #1499)
-
In
WP_REST_Posts_Controller::update_item()
, check the post ID based on the proper post type.(props @rachelbaker, #1497)
-
Load api-core as a compatibility library
Now api-core has been merged into WordPress trunk (for 4.4) we should no longer load the infrastructure code when it's already available. This also fixes a fatal error for users who were on trunk.
(props @rmccue)
-
Switch to new mysql_to_rfc3339
(props @rmccue)
-
Double-check term taxonomy
(props @rmccue)
-
Load admin functions
This was removed from the latest beta of WordPress in the REST API infrastructure, a more long term fix is planned.
(props @joehoyle)
-
Add Add compat shim for renamed
rest_mysql_to_rfc3339()
(props @danielbachhuber)
-
Compat shim for
wp_is_numeric_array()
(props @danielbachhuber)
-
Revert Switch to register_post_type_args filter
(props @joehoyle)
-
Show public user information through the user controller.
In WordPress as of r32683 (scheduled for 4.3),
WP_User_Query
now has support for getting users with published posts.To match current behaviour in WordPress themes and feeds, we now expose this public user information. This includes the avatar, description, user ID, custom URL, display name, and URL, for users who have published at least one post on the site. This information is available to all clients; other fields and data for all users are still only available when authenticated.
-
Send schema in OPTIONS requests and index.
Rather than using separate
/schema
endpoints, the schema for items is now available through an OPTIONS request to the route. This means that full documentation is now available for endpoints through an OPTIONS request; this includes available methods, what data you can pass to the endpoint, and the data you'll get back.This data is now also available in the main index and namespace indexes. Simply request the index with
context=help
to get full schema data. Warning: this response will be huge. The schema for single endpoints is also available in the collection's OPTIONS response.⚠️ This breaks backwards compatibility for clients relying on schemas being at their own routes. These clients should instead sendOPTIONS
requests.Custom endpoints can register their own schema via the
schema
option on the route. This option should live side-by-side with the endpoints (similar torelation
in WP's meta queries), so your registration call will look something like:register_rest_route( 'test-ns', '/test', array( array( 'methods' => 'GET', 'callback' => 'my_test_callback', ), 'schema' => 'my_schema_callback', ) );
-
Update JavaScript API for version 2.
Our fantastic JavaScript API from version 1 is now available for version 2, refreshed with the latest and greatest changes.
As a refresher: if you want to use it, simply make your script depend on
wp-api
when you enqueue it. If you want to enqueue the script manually, addwp_enqueue_script( 'wp-api' )
to a callback onwp_enqueue_scripts
. -
Embed links inside items in a collection.
Previously when fetching a collection of items, you only received the items themselves. To fetch the links as well via embedding, you needed to make a request to the single item with
_embed
set.No longer! You can now request a collection with embeds enabled (try
/wp/v2/posts?_embed
). This will embed links inside each item, allowing you to build interface items much easier (for example, post archive pages can get featured image data at the same time).This also applies to custom endpoints. Any endpoint that returns a list of objects will automatically have the embedding applied to objects inside the list.
-
Fix potential XSS vulnerability.
Requests from other origins could potentially run code on the API domain, allowing cross-origin access to authentication cookies or similar.
Reported by @xknown on 2015-07-23.
-
Move
/posts
WP_Query
vars back tofilter
param.In version 1, we had internal
WP_Query
vars available viafilter
(e.g.filter[s]=search+term
). For our first betas of version 2, we tried something different and exposed these directly on the endpoint. The experiment has now concluded; we didn't like this that much, sofilter
is back.We plan on adding nicer looking arguments to collections in future releases, with a view towards being consistent across different collections. We also plan on opening up the underlying query vars via
filter
for users, comments, and terms as well.⚠️ This breaks backwards compatibility for users using WP Query vars. Simply change yourx=y
parameter tofilter[x]=y
.(props @WP-API, #1420)
-
Respect
rest_base
for taxonomies.⚠️ This breaks backwards compatibility by changing the/wp/v2/posts/{id}/terms/post_tag
endpoint to/wp/v2/posts/{id}/tag
.(props @joehoyle, #1466)
-
Add permission check for retrieving the posts collection in edit context.
By extension of the fact that getting any individual post yields a forbidden context error when the
context=edit
and the user is not authorized, the user should also not be permitted to list any post items when unauthorized.(props @danielpunkass, #1412)
-
Ensure the REST API URL always has a trailing slash.
Previously, when pretty permalinks were enabled, the API URL during autodiscovery looked like
/wp-json
, whereas the non-pretty permalink URL looked like?rest_route=/
. These are now consistent, and always end with a slash character to simplify client URL building. -
Use
wp_json_encode
instead ofjson_encode
Since WordPress 4.1,
wp_json_encode
has been available to ensure encoded values are sane, and that non-UTF8 encodings are supported. We now use this function rather than doing the encode ourselves.(props @rmccue, @pento, #1417)
-
Add
role
to schema for users.The available roles you can assign to a user are now available in the schema as an
enum
.(props @joehoyle, #1400)
-
Use the schema for validation inside the comments controller.
Previously, the schema was merely a decorative element for documentation inside the comments controller. To bring it inline with our other controllers, the schema is now used internally for validation.
(props @joehoyle, #1422)
-
Don't set the Location header in update responses.
Previously, the Location header was sent when updating resources due to some inadvertent copypasta. This header should only be sent when creating to direct clients to the new resource, and isn't required when you're already on the correct resource.
(props @rachelbaker, #1441)
-
Re-enable the
rest_insert_post
action hook forWP_REST_Posts_Controller
This was disabled during 2.0 development to avoid breaking lots of plugins on the
json_insert_post
action. Now that we've changed namespaces and are Mostly Stable (tm), we can re-enable the action. -
Fix post taxonomy terms link URLs.
When moving the routes in a previous beta, we forgot to correct the links on post objects to the new correct route. Sorry!
-
Use
wp_get_attachment_image_src()
on the image sizes in attachments.Since the first versions of the API, we've been building attachment URLs via
str_replace
. Who knows why we were doing this, but it caused problems with custom attachment URLs (such as CDN-hosted images). This now correctly uses the internal functions and filters.(props @joehoyle, #1462)
-
Make the embed context a default, not forced.
If you want embeds to bring in full data rather than with
context=edit
, you can now change the link to specifycontext=view
explicitly.(props @rmccue, #1464)
-
Ensure we always use the
term_taxonomy_id
and never exposeterm_id
publicly.Previously,
term_id
was inadvertently exposed in some error responses.(props @jdolan, #1430)
-
Fix adding alt text to attachments on creation.
Previously, this could only be set when updating an attachment, not when creating one.
(props @joehoyle, #1398)
-
Throw an error when registering routes without a namespace.
Namespaces should always be provided when registering routes. We now throw a
doing_it_wrong
error when attempting to register one. (Previously, this caused a warning, or an invalid internal route.)If you really need to register namespaceless routes (e.g. to replicate an existing API), call
WP_REST_Server::register_route
directly rather than using the convenience function.(props @joehoyle, @rmccue, #1355)
-
Show links on embeds.
Previously, links were accidentally stripped from embedded response data.
(props @rmccue, #1472)
-
Clarify insufficient permisssion error when editing posts.
(props @danielpunkass, #1411)
-
Improve @return inline docs for rest_ensure_response()
(props @Shelob9, #1328)
-
Check taxonomies exist before trying to set properties.
(props @joehoyle, @rachelbaker, #1354)
-
Update controllers to ensure we use
sanitize_callback
wherever possible.(props @joehoyle, #1399)
-
Add more phpDoc documentation, and correct existing documentation.
-
Update testing infrastructure.
Travis now runs our coding standards tests in parallel, and now uses the new, faster container-based testing infrastructure.
-
Add ability to declare sanitization and default options for schema fields.
The
arg_options
array can be used to declare the sanitization callback, default value, or requirement of a field.(props @joehoyle, [#1345][gh-1345]) (props @joehoyle, [#1346][gh-1346])
-
Expand supported parameters for creating and updating Comments.
(props @rachelbaker, [#1245][gh-1245])
-
Declare collection parameters for Terms of a Post.
Define the available collection parameters in
get_collection_params()
and allow Terms of a Post to be queried by term order.(props @danielbachhuber, [#1332][gh-1332])
-
Improve the Attachment error message for an invalid Content-Disposition
(props @danielbachhuber, [#1317][gh-1317])
-
Return 200 status when updating Attachments, Comments, and Users.
(props @rachelbaker, [#1348][gh-1348])
-
Remove unnecessary
handle_format_param()
method.(props @danielbachhuber, [#1331][gh-1331])
-
Add
author_avatar_url
field to the Comment response and schema.(props @rachelbaker [#1327][gh-1327])
-
Introduce
rest_do_request()
for making REST requests internally.(props @danielbachhuber, [#1333][gh-1333])
-
Remove unused DateTime class.
(props @rmccue, [#1314][gh-1314])
-
Add inline documentation for
$wp_rest_server
global.(props @Shelob9, [#1324][gh-1324])
View all changes [gh-1245]: WP-API#1245 [gh-1314]: WP-API#1314 [gh-1317]: WP-API#1317 [gh-1318]: WP-API#1318 [gh-1324]: WP-API#1324 [gh-1326]: WP-API#1326 [gh-1327]: WP-API#1327 [gh-1331]: WP-API#1331 [gh-1332]: WP-API#1332 [gh-1333]: WP-API#1333 [gh-1345]: WP-API#1345 [gh-1346]: WP-API#1346 [gh-1347]: WP-API#1347 [gh-1348]: WP-API#1348
-
Load the WP REST API before the main query runs.
The
rest_api_loaded
function now hooks into theparse_request
action. This change prevents the main query from being run on every request and allows sites to setWP_USE_THEMES
tofalse
. 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][gh-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.(props @joehoyle, @rachelbaker, [#927][gh-927]) (props @joehoyle, [#1207][gh-1207]) (props @joehoyle, [#1243][gh-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.(props @joehoyle, @danielbachhuber, [#1216][gh-1216])
-
Add pagination headers for collection queries.
The
X-WP-Total
andX-WP-TotalPages
are now present in terms, comments, and users collection responses.(props @danielbachhuber, [#1182][gh-1182]) (props @danielbachhuber, [#1191][gh-1191]) (props @danielbachhuber, @joehoyle, [#1197][gh-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 forwp/v3
orpluginname/v2
, which indicate the supported endpoints on the site.(props @rmccue,, [#1283][gh-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][gh-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][gh-1157])
-
Return full objects in the delete response.
Instead of returning a random message when deleting a Post, Comment, Term, or User provide the original resource data.
(props @danielbachhuber, [#1253][gh-1253]) (props @danielbachhuber, [#1254][gh-1254]) (props @danielbachhuber, [#1255][gh-1255]) (props @danielbachhuber, [#1256][gh-1256])
-
Return programmatically readable error messages for invalid or missing required parameters.
(props @joehoyle, [#1175][gh-1175])
-
Declare supported arguments for Comment and User collection queries.
(props @danielbachhuber, [#1211][gh-1211]) (props @danielbachhuber, [#1217][gh-1217])
-
Automatically validate parameters based on Schema data.
(props @joehoyle, [#1128][gh-1128])
-
Use the
show_in_rest
attributes for exposing Taxonomies.(props @joehoyle, [#1279][gh-1279])
-
Handle
parent
when creating or updating a Term.(props @joehoyle, [#1221][gh-1221])
-
Limit fields returned in
embed
context User responses.(props @rachelbaker, [#1251][gh-1251])
-
Only include
parent
in term response when tax is hierarchical.(props @danielbachhuber, [#1189][gh-1189])
-
Fix bug in creating comments if
type
was not set.(props @rachelbaker, [#1244][gh-1244])
-
Rename
post_name
field topost_slug
.(props @danielbachhuber, [#1235][gh-1235])
-
Add check when creating a user to verify the provided role is valid.
(props @rachelbaker, [#1267][gh-1267])
-
Add link properties to the Post Status response.
(props @joehoyle, [#1243][gh-1243])
-
Return
0
forparent
in Post response instead ofnull
.(props @danielbachhuber, [#1269][gh-1269])
-
Only link
author
when there's a valid author(props @danielbachhuber, [#1203][gh-1203])
-
Only permit querying by parent term when tax is hierarchical.
(props @danielbachhuber, [#1219][gh-1219])
-
Only permit deleting posts of the proper type
(props @danielbachhuber, [#1257][gh-1257])
-
Set pagination headers even when no found posts.
(props @danielbachhuber, [#1209][gh-1209])
-
Correct prefix in
rest_request_parameter_order
filter.(props @quasel, [#1158][gh-1158])
-
Retool
WP_REST_Terms_Controller
to follow Posts controller pattern.(props @danielbachhuber, [#1170][gh-1170])
-
Remove unused
accept_json argument
from theregister_routes
method.(props @quasel, [#1160][gh-1160])
-
Fix typo in
sanitize_params
inline documentation.(props @Shelob9, [#1226][gh-1226])
-
Remove commented out code in dispatch method.
(props @rachelbaker, [#1162][gh-1162])
View all changes [gh-927]: WP-API#927 [gh-1128]: WP-API#1128 [gh-1157]: WP-API#1157 [gh-1158]: WP-API#1158 [gh-1160]: WP-API#1160 [gh-1162]: WP-API#1162 [gh-1168]: WP-API#1168 [gh-1170]: WP-API#1170 [gh-1171]: WP-API#1171 [gh-1175]: WP-API#1175 [gh-1176]: WP-API#1176 [gh-1177]: WP-API#1177 [gh-1181]: WP-API#1181 [gh-1182]: WP-API#1182 [gh-1188]: WP-API#1188 [gh-1189]: WP-API#1189 [gh-1191]: WP-API#1191 [gh-1197]: WP-API#1197 [gh-1200]: WP-API#1200 [gh-1203]: WP-API#1203 [gh-1207]: WP-API#1207 [gh-1209]: WP-API#1209 [gh-1210]: WP-API#1210 [gh-1211]: WP-API#1211 [gh-1216]: WP-API#1216 [gh-1217]: WP-API#1217 [gh-1219]: WP-API#1219 [gh-1221]: WP-API#1221 [gh-1226]: WP-API#1226 [gh-1235]: WP-API#1235 [gh-1243]: WP-API#1243 [gh-1244]: WP-API#1244 [gh-1249]: WP-API#1249 [gh-1251]: WP-API#1251 [gh-1253]: WP-API#1253 [gh-1254]: WP-API#1254 [gh-1255]: WP-API#1255 [gh-1256]: WP-API#1256 [gh-1257]: WP-API#1257 [gh-1259]: WP-API#1259 [gh-1267]: WP-API#1267 [gh-1268]: WP-API#1268 [gh-1269]: WP-API#1269 [gh-1270]: WP-API#1270 [gh-1276]: WP-API#1276 [gh-1277]: WP-API#1277 [gh-1279]: WP-API#1279 [gh-1283]: WP-API#1283 [gh-1284]: WP-API#1284 [gh-1295]: WP-API#1295 [gh-1301]: WP-API#1301
-
Fix user access security vulnerability.
Authenticated users were able to escalate their privileges bypassing the expected capabilities check.
Reported by @kacperszurek on 2015-05-16.
-
Avoid passing server to the controller each time
(props @rmccue, [#543][gh-543])
-
Unify naming of methods across classes
(props @danielbachhuber, [#546][gh-546])
-
Disable unit tests while we move things around
(props @danielbachhuber, [#548][gh-548])
-
Mock code to represent new Resources
(props @danielbachhuber, [#549][gh-549])
-
WP_JSON_Controller POC
(props @danielbachhuber, [#556][gh-556])
-
Add request object
(props @rmccue, [#563][gh-563])
-
Update routes for new-style registration
(props @rmccue, [#564][gh-564])
-
Add compatibility with v1 routing
(props @rmccue, [#565][gh-565])
-
Remove Last-Modified and If-Unmodified-Since
(props @rmccue, [#566][gh-566])
-
Allow multiple route registration
(props @rmccue, [#586][gh-586])
-
Use https in test setup
(props @danielbachhuber, [#588][gh-588])
-
Terms Controller Redux
(props @danielbachhuber, [#579][gh-579])
-
Add hypermedia functionality to the response
(props @rmccue, @rachelbaker, [#570][gh-570])
-
Initial pass at new style Users Controller
(props @rachelbaker, [#603][gh-603])
-
Drop old Users class
(props @danielbachhuber, [#619][gh-619])
-
Fix passing array to 'methods' are in register_json_route()
(props @joehoyle, [#620][gh-620])
-
Allow 'ignore_sticky_posts' filter #415
(props @Shelob9, [#612][gh-612], [#415][gh-415])
-
Initial Extras.php commit
(props @NikV, [#575][gh-575])
-
Allow filtering response before returning
(props @danielbachhuber, [#573][gh-573])
-
Parse JSON data from the request
(props @rmccue, [#626][gh-626])
-
Remove old taxonomies controller
(props @danielbachhuber, [#637][gh-637])
-
Make our code DRY by consolidating use of strtoupper
(props @danielbachhuber, [#589][gh-589])
-
Move WP_Test_JSON_Testcase to a properly named file
(props @danielbachhuber, [#643][gh-643])
-
Speed up builds by only running against MS once
(props @danielbachhuber, [#638][gh-638])
-
->prepare_post()
should be public(props @staylor, [#645][gh-645])
-
Get by and return
term_taxonomy_id
(props @danielbachhuber, [#648][gh-648])
-
Base class with standard test methods for every controller
(props @danielbachhuber, [#649][gh-649])
-
Unused arguments
(props @staylor, [#647][gh-647])
-
JS should be under version control
(props @staylor, [#644][gh-644])
-
Register multiple routes for users correctly
(props @rmccue, [#654][gh-654])
-
Check get_post_type_object() returns an object before using it
(props @NateWr, [#656][gh-656])
-
Run multisite test against PHP 5.2
(props @danielbachhuber, [#659][gh-659])
-
Pass the edit context when returning the create or update response. Fixes #661
(props @rachelbaker, [#664][gh-664], [#661][gh-661])
-
Check for errors when responding to create
(props @rmccue, [#652][gh-652])
-
Fix bug in check_required_parameters where JSON params were missed
(props @rachelbaker, [#673][gh-673])
-
Fix parameter handling and improve Users Controller tests
(props @rachelbaker, [#675][gh-675])
-
Check that param is null
(props @danielbachhuber, [#678][gh-678])
-
Parse URL-encoded body with PUT requests
(props @rmccue, [#681][gh-681])
-
End to end testing for users
(props @rmccue, [#682][gh-682])
-
End to end test coverage of Terms Controller
(props @danielbachhuber, @rmccue, [#676][gh-676])
-
Add ability to wrap response in an envelope
(props @Japh, @rmccue, [#628][gh-628])
-
Wrap up PUT handling in Users Controller
(props @rachelbaker, [#683][gh-683])
-
ID shouldn't be a param on update user endpoint
(props @joehoyle, [#692][gh-692])
-
Clean up Terms controller
(props @danielbachhuber, [#696][gh-696])
-
Remove mis-placed duplicate Users Delete route and id parameter
(props @rachelbaker, [#700][gh-700])
-
Fields cleanup for User controller
(props @danielbachhuber, [#701][gh-701])
-
Throw an error when a user tries to update to an existing user's email
(props @danielbachhuber, [#705][gh-705])
-
PUT User
shouldn't permit using existinguser_login
oruser_nicename
(props @danielbachhuber, [#707][gh-707])
-
Change return value of WP_JSON_Users_Controller::get_item.
(props @rachelbaker, [#712][gh-712])
-
Add the ability to specify default param values in register_json_route
(props @WP-API, [#715][gh-715])
-
Merge JS into main repo
(props @tlovett1, #730)
-
Make the "required" param on args optional
(props @joehoyle, @rachelbaker, [#728][gh-728])
-
Always allow JSON data for POST and PUT requests
(props @rachelbaker, [#731][gh-731])
-
Initial pass at new style Posts Controller
(props @rachelbaker, [#684][gh-684])
-
Drop required argument declaration
(props @danielbachhuber, [#736][gh-736])
-
Update post format after post has been updated
(props @danielbachhuber, [#737][gh-737])
-
Allow the title to be set via title.raw
(props @iseulde, [#741][gh-741])
-
Fix some incompatible interfaces
(props @staylor, [#742][gh-742])
-
Full Test Coverage for Users Controller
(props @rachelbaker, [#744][gh-744])
-
Refer to BaseCollection statically instead of via this.constructor
(props @tlovett1, [#750][gh-750])
-
Adjustments to Users Controller DocBlocks
(props @rachelbaker, [#743][gh-743])
-
Default
args
to an empty array(props @danielbachhuber, [#758][gh-758])
-
Do not require type parameter to be set when updating a Post
(props @rachelbaker, [#761][gh-761])
-
Remove from docs the "post_type" filter parameter for /posts endpoint
(props @NateWr, [#666][gh-666])
-
Resolve regressions in Posts Controller
(props @rachelbaker, [#753][gh-753])
-
WP_Json_Server::dispatch() should always return a WP_JSON_Response
(props @joehoyle, [#714][gh-714])
-
Update Timeline note
(props @tapsboy, [#774][gh-774])
-
Make json_pre_dispatch and json_post_dispatch consistent
(props @joehoyle, [#786][gh-786])
-
Normalize our test classes setUP and tearDown methods
(props @rachelbaker, [#794][gh-794])
-
Comments Endpoints
(props @joehoyle, @rachelbaker, [#693][gh-693])
-
Correct /posts/ endpoint read post permission logic
(props @rachelbaker, [#805][gh-805])
-
Ensure global $post has proper state when the json_prepare_post filter f...
(props @ericandrewlewis, [#823][gh-823])
-
Adds missing description field to the Taxonomy response
(props @rachelbaker, [#826][gh-826])
-
Posts controller abstraction
(props @danielbachhuber, [#820][gh-820])
-
Remove old Pages and CustomPostType classes no longer in use
(props @danielbachhuber, [#831][gh-831])
-
Add
featured_image
attribute for post types that supportthumbnails
(props @danielbachhuber, [#832][gh-832])
-
Specify Capability in Route
(props @joehoyle, [#602][gh-602])
-
Posts Controller Headers and Links Fixes
(props @rachelbaker, [#836][gh-836])
-
Don't noop
future
status. It's confusing(props @danielbachhuber, [#841][gh-841])
-
Remove unused $request parameter from prepare_links method.
(props @rachelbaker, [#842][gh-842])
-
Expose basic author details when user has published posts
(props @danielbachhuber, [#838][gh-838])
-
Make
get_post_type_base()
public so we can DRY(props @danielbachhuber, [#845][gh-845])
-
Remove Duplicate Logic for Post Type Attributes
(props @rachelbaker, [#853][gh-853])
-
Move infrastructure classes to
lib/infrastructure
, part one(props @danielbachhuber, [#872][gh-872])
-
Passing a value for the slug parameter should update the post_name.
(props @rachelbaker, [#883][gh-883])
-
Break Pages tests into a separate class
(props @danielbachhuber, [#870][gh-870])
-
Empty checks in Posts Controller make setting values to Falsy impossible
(props @joehoyle, [#885][gh-885])
-
Change project name to WP REST API in plugin name and Readme title.
(props @rachelbaker, [#876][gh-876])
-
Return 200 and an empty array for valid queries with 0 results.
(props @rachelbaker, [#888][gh-888])
-
Include the taxonomy in the term response
(props @danielbachhuber, [#891][gh-891])
-
JSON Schemas for our Controllers, second attempt
(props @danielbachhuber, [#844][gh-844])
-
From the left with love
(props @MichaelArestad, [#896][gh-896])
-
Add
link
field to Users, Comments and Terms(props @danielbachhuber, [#897][gh-897])
-
Fix flipped assertions
(props @danielbachhuber, [#902][gh-902])
-
Add missing break statement
(props @danielbachhuber, [#905][gh-905])
-
Move all of our endpoint controllers to
lib/endpoints
(props @danielbachhuber, [#906][gh-906])
-
Always include
guid
in Post and Page schemas(props @danielbachhuber, [#907][gh-907])
-
If post type doesn't match controller post type, throw 404
(props @danielbachhuber, [#908][gh-908])
-
Allow post type attributes to be set based on presence in schema
(props @danielbachhuber, [#910][gh-910])
-
Updating another post field shouldn't change sticky status
(props @danielbachhuber, [#911][gh-911])
-
Expose post type data at
/types
(props @danielbachhuber, [#914][gh-914])
-
Always defer to controller for post type
(props @danielbachhuber, [#913][gh-913])
-
Add
template
parameter to Page response(props @danielbachhuber, [#909][gh-909])
-
Convert /media to new controller pattern
(props @danielbachhuber, [#904][gh-904])
-
Remove v1.0 Posts (and Media) controller
(props @WP-API, [#923][gh-923])
-
Clean up taxonomies controller tests by running through dispatch; add schema
(props @danielbachhuber, [#919][gh-919])
-
Separate permissions logic for comments
(props @joehoyle, [#854][gh-854])
-
wp-json.php
isn't needed anymore(props @danielbachhuber, [#931][gh-931])
-
Tweak the post controller
(props @rmccue, [#936][gh-936])
-
Switch CORS headers callback to new action
(props @rmccue, [#935][gh-935])
-
Remove
_id
suffix from field names(props @danielbachhuber, [#941][gh-941])
-
Add
author_ip
,author_user_agent
andkarma
fields to Comment(props @danielbachhuber, [#946][gh-946])
-
Explicitly test that these additional comment fields aren't present
(props @danielbachhuber, [#947][gh-947])
-
Allow
title
to be set to empty string in request(props @danielbachhuber, [#953][gh-953])
-
Use real URLs instead of query_params attribute
(props @rmccue, [#958][gh-958])
-
Use
wp_filter_post_kses()
instead ofwp_kses_post()
on insert(props @danielbachhuber, [#917][gh-917])
-
Add missing core path to post endpoint link hrefs.
(props @rachelbaker, [#966][gh-966])
-
Allow HTTP method to be overwritten by HTTP_X_HTTP_METHOD_OVERRIDE
(props @tlovett1, [#967][gh-967])
-
Fix attachment caption and description fields
(props @danielbachhuber, [#968][gh-968])
-
Move validation to the
WP_JSON_Request
class(props @danielbachhuber, [#971][gh-971])
-
Move the Route Registering to the Controllers
(props @joehoyle, [#970][gh-970])
-
Correct test method spelling of permission.
(props @rachelbaker, [#973][gh-973])
-
Permission abstractions 2
(props @joehoyle, [#987][gh-987])
-
If an invalid date is supplied to create / update post, return an error
(props @joehoyle, [#1000][gh-1000])
-
Update README.md
(props @hubdotcom, [#1006][gh-1006])
-
Add embeddable attachments to Post response _links
(props @rachelbaker, [#1026][gh-1026])
-
Throw error if requesting user doesn't have capability for context
(props @danielbachhuber, [#1033][gh-1033])
-
/wp/statuses
endpoint, modeled after/wp/types
(props @danielbachhuber, [#1039][gh-1039])
-
Turn post types from array to object, with name as key
(props @danielbachhuber, [#1042][gh-1042])
-
Add missing response fields to the user schema.
(props @rachelbaker, [#1034][gh-1034])
-
Setting a post to be sticky AND password protected should fail
(props @joehoyle, [#1044][gh-1044])
-
Use appropriate functions when creating users on multisite
(props @danielbachhuber, [#1043][gh-1043])
-
Define context in which each schema field appears
(props @danielbachhuber, [#1046][gh-1046])
-
Use schema abstraction to limit which user fields are exposed per context
(props @danielbachhuber, [#1049][gh-1049])
-
Run Statuses, Types, and Taxonomies through our context filter
(props @danielbachhuber, [#1050][gh-1050])
-
Run Terms controller through schema context filter
(props @danielbachhuber, [#1051][gh-1051])
-
Don't allow contributors to set sticky on posts
(props @joehoyle, [#1052][gh-1052])
-
Return correct response code from wp_insert_post() error
(props @joehoyle, [#999][gh-999])
-
Move the permissions checks for password and author into the permissions callback
(props @joehoyle, [#1054][gh-1054])
-
Use full Post schema to filter fields based on context
(props @danielbachhuber, [#1053][gh-1053])
-
Allow WP_JSON_Server::send_header()/send_headers() to be accessed publicly
(props @johnbillion, [#1059][gh-1059])
-
Remove unnecessary sticky posts abstraction
(props @danielbachhuber, [#1064][gh-1064])
-
Re-enable the Post endpoint filters
(props @rachelbaker, [#1028][gh-1028])
-
Fix the format of the args when building them from the Schema
(props @joehoyle, [#1066][gh-1066])
-
Add more tests for the server class
(props @rmccue, [#685][gh-685])
-
Fix error with OPTIONS requests
(props @rmccue, [#1091][gh-1091])
-
Ensure the JSON endpoint URL is properly escaped
(props @johnbillion, [#1097][gh-1097])
-
Correct a bunch of filter docs in WP_JSON_Server
(props @johnbillion, [#1098][gh-1098])
-
Require
moderate_comments
capability to context=edit a Comment(props @danielbachhuber, @joehoyle, [#951][gh-951])
-
Add all the permission check functions to the base controller for better consistancy and help to subclasses
(props @joehoyle, [#1104][gh-1104])
-
author
is the Comment attribute with user ID(props @danielbachhuber, [#1106][gh-1106])
-
Fix copy pasta in the schema checks
(props @danielbachhuber, [#1111][gh-1111])
-
When
context=edit
, confirm user canmanage_comments
(props @danielbachhuber, [#1112][gh-1112])
-
Abstract revisions to dedicated controller; only include revisioned fields
(props @danielbachhuber, [#1110][gh-1110])
-
Add Embeddable Taxonomy Term Links to the Post Response
(props @rachelbaker, [#1048][gh-1048])
-
Increase Terms Controller test coverage
(props @rachelbaker, [#1117][gh-1117])
-
Rename the
wp_json_server_before_serve
towp_json_init
(props @joehoyle, [#1105][gh-1105])
-
Drop revision embedding from posts controller; link instead
(props @danielbachhuber, [#1121][gh-1121])
-
Add security section to our README
(props @rmccue, [#1123][gh-1123])
-
Missing @param inline docs in main plugin file.
(props @Shelob9, [#1122][gh-1122])
-
Ensure post deletion is idempotent
(props @rmccue, [#959][gh-959])
-
Support for validation / sanitize callbacks in arguments
(props @joehoyle, [#989][gh-989])
-
Display links in collections
(props @rmccue, @rachelbaker, [#937][gh-937])
-
Sanitize args using new args API
(props @joehoyle, [#1129][gh-1129])
-
Use the user fields from the item schema as the request args in route registration
(props @joehoyle, [#1109][gh-1109])
-
Build the array of args for /wp/posts from the allowed query vars
(props @joehoyle, [#1108][gh-1108])
-
Show all the invalid param errors at once
(props @joehoyle, [#1131][gh-1131])
-
Readonly attribute in schema to exclude from args array
(props @joehoyle, [#1133][gh-1133])
-
Use the
required
flags from the schema for CREATE post(props @joehoyle, [#1132][gh-1132])
-
Only return 201 on Create. Update should be 200
(props @danielbachhuber, [#1142][gh-1142])
-
Convert meta endpoints to new-style
(props @rmccue, @rachelbaker, [#960][gh-960])
-
Specific error codes for permissions failures
(props @joehoyle, [#1148][gh-1148])
View all changes gh-347: WP-API#347 gh-378: WP-API#378 gh-401: WP-API#401 [gh-415]: WP-API#415 [gh-448]: WP-API#448 gh-474: WP-API#474 gh-481: WP-API#481 gh-524: WP-API#524 gh-528: WP-API#528 [gh-543]: WP-API#543 [gh-546]: WP-API#546 [gh-548]: WP-API#548 [gh-549]: WP-API#549 [gh-550]: WP-API#550 [gh-556]: WP-API#556 [gh-563]: WP-API#563 [gh-564]: WP-API#564 [gh-565]: WP-API#565 [gh-566]: WP-API#566 [gh-567]: WP-API#567 [gh-570]: WP-API#570 [gh-573]: WP-API#573 [gh-575]: WP-API#575 [gh-579]: WP-API#579 [gh-586]: WP-API#586 [gh-588]: WP-API#588 [gh-589]: WP-API#589 [gh-591]: WP-API#591 gh-595: WP-API#595 [gh-602]: WP-API#602 [gh-603]: WP-API#603 [gh-612]: WP-API#612 [gh-619]: WP-API#619 [gh-620]: WP-API#620 [gh-626]: WP-API#626 [gh-628]: WP-API#628 [gh-630]: WP-API#630 [gh-637]: WP-API#637 [gh-638]: WP-API#638 [gh-643]: WP-API#643 [gh-644]: WP-API#644 [gh-645]: WP-API#645 [gh-647]: WP-API#647 [gh-648]: WP-API#648 [gh-649]: WP-API#649 [gh-652]: WP-API#652 [gh-654]: WP-API#654 [gh-656]: WP-API#656 [gh-659]: WP-API#659 [gh-661]: WP-API#661 [gh-664]: WP-API#664 [gh-666]: WP-API#666 [gh-673]: WP-API#673 [gh-675]: WP-API#675 [gh-676]: WP-API#676 [gh-678]: WP-API#678 [gh-681]: WP-API#681 [gh-682]: WP-API#682 [gh-683]: WP-API#683 [gh-684]: WP-API#684 [gh-685]: WP-API#685 [gh-692]: WP-API#692 [gh-693]: WP-API#693 [gh-696]: WP-API#696 [gh-700]: WP-API#700 [gh-701]: WP-API#701 [gh-705]: WP-API#705 [gh-707]: WP-API#707 [gh-712]: WP-API#712 [gh-714]: WP-API#714 [gh-715]: WP-API#715 [gh-722]: WP-API#722 [gh-728]: WP-API#728 gh-730: WP-API#730 [gh-731]: WP-API#731 [gh-736]: WP-API#736 [gh-737]: WP-API#737 [gh-741]: WP-API#741 [gh-742]: WP-API#742 [gh-743]: WP-API#743 [gh-744]: WP-API#744 [gh-750]: WP-API#750 [gh-753]: WP-API#753 [gh-758]: WP-API#758 [gh-761]: WP-API#761 [gh-774]: WP-API#774 [gh-786]: WP-API#786 [gh-794]: WP-API#794 [gh-805]: WP-API#805 [gh-807]: WP-API#807 [gh-815]: WP-API#815 [gh-820]: WP-API#820 [gh-823]: WP-API#823 [gh-826]: WP-API#826 [gh-831]: WP-API#831 [gh-832]: WP-API#832 [gh-836]: WP-API#836 [gh-838]: WP-API#838 [gh-841]: WP-API#841 [gh-842]: WP-API#842 [gh-844]: WP-API#844 [gh-845]: WP-API#845 [gh-849]: WP-API#849 [gh-853]: WP-API#853 [gh-854]: WP-API#854 [gh-870]: WP-API#870 [gh-872]: WP-API#872 [gh-874]: WP-API#874 [gh-876]: WP-API#876 [gh-879]: WP-API#879 [gh-883]: WP-API#883 [gh-885]: WP-API#885 [gh-888]: WP-API#888 [gh-891]: WP-API#891 [gh-896]: WP-API#896 [gh-897]: WP-API#897 [gh-902]: WP-API#902 [gh-904]: WP-API#904 [gh-905]: WP-API#905 [gh-906]: WP-API#906 [gh-907]: WP-API#907 [gh-908]: WP-API#908 [gh-909]: WP-API#909 [gh-910]: WP-API#910 [gh-911]: WP-API#911 [gh-913]: WP-API#913 [gh-914]: WP-API#914 [gh-917]: WP-API#917 [gh-919]: WP-API#919 [gh-923]: WP-API#923 [gh-931]: WP-API#931 gh-933: WP-API#933 [gh-935]: WP-API#935 [gh-936]: WP-API#936 [gh-937]: WP-API#937 [gh-941]: WP-API#941 [gh-946]: WP-API#946 [gh-947]: WP-API#947 [gh-951]: WP-API#951 [gh-953]: WP-API#953 [gh-955]: WP-API#955 [gh-958]: WP-API#958 [gh-959]: WP-API#959 [gh-960]: WP-API#960 [gh-966]: WP-API#966 [gh-967]: WP-API#967 [gh-968]: WP-API#968 [gh-970]: WP-API#970 [gh-971]: WP-API#971 [gh-973]: WP-API#973 gh-985: WP-API#985 [gh-987]: WP-API#987 [gh-989]: WP-API#989 [gh-996]: WP-API#996 [gh-999]: WP-API#999 [gh-1000]: WP-API#1000 [gh-1006]: WP-API#1006 [gh-1026]: WP-API#1026 [gh-1028]: WP-API#1028 [gh-1033]: WP-API#1033 [gh-1034]: WP-API#1034 [gh-1039]: WP-API#1039 [gh-1042]: WP-API#1042 [gh-1043]: WP-API#1043 [gh-1044]: WP-API#1044 [gh-1046]: WP-API#1046 [gh-1048]: WP-API#1048 [gh-1049]: WP-API#1049 [gh-1050]: WP-API#1050 [gh-1051]: WP-API#1051 [gh-1052]: WP-API#1052 [gh-1053]: WP-API#1053 [gh-1054]: WP-API#1054 [gh-1059]: WP-API#1059 [gh-1064]: WP-API#1064 [gh-1066]: WP-API#1066 [gh-1091]: WP-API#1091 [gh-1097]: WP-API#1097 [gh-1098]: WP-API#1098 [gh-1103]: WP-API#1103 [gh-1104]: WP-API#1104 [gh-1105]: WP-API#1105 [gh-1106]: WP-API#1106 [gh-1108]: WP-API#1108 [gh-1109]: WP-API#1109 [gh-1110]: WP-API#1110 [gh-1111]: WP-API#1111 [gh-1112]: WP-API#1112 [gh-1115]: WP-API#1115 [gh-1116]: WP-API#1116 [gh-1117]: WP-API#1117 [gh-1121]: WP-API#1121 [gh-1122]: WP-API#1122 [gh-1123]: WP-API#1123 [gh-1129]: WP-API#1129 [gh-1131]: WP-API#1131 [gh-1132]: WP-API#1132 [gh-1133]: WP-API#1133 [gh-1134]: WP-API#1134 [gh-1137]: WP-API#1137 [gh-1142]: WP-API#1142 [gh-1148]: WP-API#1148
-
Fix information disclosure security vulnerability.
Unauthenticated users could access revisions of published and unpublished posts. Revisions are now only accessible to authenticated users with permission to edit the revision's post.
Reported by @chredd on 2015-04-09.
-
Add handling for Cross-Origin Resource Sharing (CORS) OPTIONS requests.
Preflighted requests (using the OPTIONS method) include the headers
Access-Control-Allow-Origin
,Access-Control-Allow-Methods
, andAccess-Control-Allow-Credentials
in the response, if the HTTP origin is set.(props @rmccue, #281)
-
Allow overriding full requests.
The
json_pre_dispatch
filter allows a request to be hijacked before it is dispatched. Hijacked requests can be anything a normal endpoint can return.(props @rmccue, #281)
-
Check for JSON encoding/decoding errors.
Returns the last error (if any) occurred during the last JSON encoding or decoding operation.
(props @joshkadis, @rmccue, #461)
-
Add filtering to the terms collection endpoint.
Available filter arguments are based on the
get_terms()
function. Example:/taxonomies/category/terms?filter[number]=10
would limit the response to 10 category terms. -
Add handling for the
role
parameter when creating or updating a user.Allow users to be created or updated with a provided
role
. -
Add handling for the
post_id
parameter when creating media.Allow passing the
post_id
parameter to associate a new media item with a post.(props @pkevan, #294)
-
Handle route matching for
-
in taxonomy and terms.Previously the regular expression used to match taxonomy and term names did not support names with dashes.
(props @EdHurtig, @evansobkowicz, #410)
-
Handle JSONP callback matching for
.
in the function name.Previously the regular expression used to match JSONP callback functions did not support names with periods.
(props @codonnell822, #455)
-
Fix the Content-Type header for JSONP requests.
Previously JSONP requests sent the incorrect
application/json
Content-Type header with the response. This would result in an error if strict MIME checking was enabled. The Content-Type header was corrected toapplication/javascript
for JSONP responses.(props @simonlampen, #380)
-
Add
$context
parameter tojson_prepare_term
filter.Terms responses can now be modified based on the
context
parameter of the request.(props @traversal, #316)
-
Move the JavaScript client library into the plugin.
Previously, the
wp-api.js
file was a separate repository. The JavaScript client has moved back into the plugin to coordinate code changes.(props @tlovett1, #730)
-
Always return an object for media sizes
The media sizes value should always be an object even when empty. Previously, if a media item did not have any sizes set, an empty array was returned.
Compatibility warning: Clients should be prepared to accept an empty object as a value for media sizes.
(props @maxcutler, #300)
-
Give top-level posts a
null
parent value.For date type consistency, post parent property should be
null
. Previously, parent-less posts returned0
for parent.Compatibility warning: Clients should be prepared to accept
null
as a value for post parent.(props @maxcutler, #391)
-
Move permission checks out of
WP_JSON_Posts
.Introduce
json_check_post_permission()
function to allow post object capability checks to be used outside theWP_JSON_Posts
class.Deprecation warning: Calling
WP_JSON_Posts::check_read_permission
andWP_JSON_Posts::check_edit_permission
is now deprecated. -
Split comment endpoints into separate class.
All comment handling has moved to the
WP_JSON_Comments
class.Deprecation warning: Calling
WP_JSON_Posts::get_comments
,WP_JSON_Posts::get_comment
,WP_JSON_Posts::delete_comment
, andWP_JSON_Posts::prepare_comment
is now deprecated.(props @whyisjake, @rmccue, @rachelbaker, #378)
-
Split meta endpoints into separate class.
All post meta handling has moved to the new
WP_JSON_Meta_Posts
class.Deprecation warning: Calling
WP_JSON_Posts::get_all_meta
,WP_JSON_Posts::get_meta
,WP_JSON_Posts::update_meta
,WP_JSON_Posts::add_meta
,WP_JSON_Posts::delete_meta
,WP_JSON_Posts::prepare_meta
, andWP_JSON_Posts::is_valid_meta_data
is now deprecated. -
Rename internal create methods.
Deprecation warning: Calling
WP_JSON_Posts::new_post
,WP_JSON_CustomPostType::new_post
andWP_JSON_Posts::new_post
is now deprecated. -
Fix discrepancies in edit and create posts documentation examples.
Corrected the edit and create posts code examples in the Getting Started section. The new post example was updated to include the required
content_raw
parameter. The new and edit posts examples were updated to use a correct date parameter.(props @rachelbaker, #305)
-
Update the cookie authentication documentation examples.
With 1.1 the localized JavaScript object for
wp-api.js
changed toWP_API_Settings
. This updates the Authentication section documentation nonce example to use the updated object name.(props @rachelbaker, #321)
-
Add flexibility and multisite support to unit tests.
Tests can be run from any WordPress install, and are not limited to only as a plugin installed within a WordPress.org develop checkout. Unit tests are now run against a multisite installation.
(props @danielbachhuber, #397)
-
Add
taxonomy
slug to the term response.(props @kalenjohnson, #481)
-
Fix error when getting child comment.
Previously an error occurred when a requested comment had a parent.
-
Parse query strings before returning a JSON decode error.
(props @jtsternberg, #499)
-
Typecast the user ID parameter to be an integer for the
/users/{ID}
route.(props @dimadin, #333)
-
Confirm a given JSONP callback is a string.
(props @ircrash, @rmccue, #405)
-
Register the JavaScript client in the admin.
(props @tlovett1, #473)
-
Remove duplicate error checks on post ids.
(props @danielbachhuber, #271)
-
Update documentation link references to wp-api.org.
(props @pollyplummer, #320)
-
Update documentation to note routes needing authentication.
-
Correct Post route documentation filter parameters.
-
Update taxonomy route documentation with correct paths.
-
Remove references to legacy
$fields
parameter.(props @JDGrimes, #326)
-
Alter readme installation steps to use wp-cli for plugin and permalink setup.
(props @kadamwhite, #390)
-
Add steps to readme for executing tests with
vagrant ssh -c
.(props @kadamwhite, #416)
-
Update readme to include provision step for testing suite.
(props @ironpaperweight, #396)
-
Update readme Getting Started link.
(props @NikV, #519)
-
Update readme Chassis repository links.
(props @Japh, #505)
-
Clean-up of
docs
folder.(props @pollyplummer, #441)
-
Documentation audit for plugin.php file.
(props @DrewAPicture, #293)
-
Rename tests to match class file naming.
(props @danielbachhuber, @rmccue, #359)
-
Add license.txt file with license terms.
-
Fix test_root when using WordPress.org developer checkout.
(props @markoheijnen, #437)
-
Mitigate Flash CSRF exploit
Using the API's JSONP support, it's possible to control the first bytes of the response sent to the browser. Combining this with an ASCII-encoded SWF allows arbitrary SWFs to be served from the site, allowing bypassing the same-origin policy built in to browsers.
While the API includes CSRF protection and is not directly vulnerable, this can be used to bypass other browser origin controls.
Reported by @iandunn on 2014-07-10.
(props @iandunn, @rmccue, #356)
-
Add new routes for taxonomies and terms.
Taxonomies and terms have now been moved from the
/posts/types/<type>
namespace to global routes:/taxonomies
,/taxonomies/<tax>
,/taxonomies/<tax>/terms
and/taxonomies/<tax>/terms/<term>
Test coverage for taxonomy endpoints has also been increased to 100%.
Deprecation warning: The
/posts/types/<type>/taxonomies
endpoint (and sub-endpoints with the same prefix) have been deprecated in favour of the new endpoints. These deprecated endpoints will now return aX-WP-DeprecatedFunction
header 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 thejson_url_prefix
filter. Note that rewrites will need to be flushed manually after changing this. -
Give
null
as 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 now returns
null
where a date is not available.Compatibility warning: Clients should be prepared to accept
null
as a 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 content.
The
excerpt_raw
field was added to the edit context on posts. This field contains the raw excerpt data saved for the post, including empty string values. -
Only expose email for edit context.
User email addresses are now only exposed for
context=edit
, which requires theedit_users
permission (not required for the current user).The email address field will now return
false
instead 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
edit
context.(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.
(props @rmccue, #242)
-
Include new client JS from github.io
The WP-API Javascript library is now loaded dynamically from
wp-api.github.io
to 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
json_prepare_${type}
filter.This value was previously not interpolated correctly, due to the use of the single-quoted string type.
(props @danielbachhuber, #266)
-
Return
WP_Error
instead of array of empty objects for a revisions permissions error.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
(props @danielbachhuber, @rachelbaker, @rmccue, #275, #277, #284, #279)
-
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.
(props @rachelbaker, @rmccue, #99)
-
Separate helper functions into global namespace.
WP_JSON_Server::get_timezone()
,WP_JSON_Server::get_date_with_gmt()
,WP_JSON_Server::get_avatar_url()
and ``WP_JSON_Server::parse_date()` have all been moved into the global namespace to decouple them from the server class.Deprecation warning: These methods have been deprecated. The new
json_get_timezone()
,json_get_date_with_gmt()
,json_get_avatar_url()
andjson_parse_date()
methods should now be used instead. -
Re-order Users and Media routes documentation based on CRUD order
(props @rachelbaker, #214)
-
Update Post route documentation to provide more detail for data parameter
(props @rachelbaker, #212)
-
Correct documentation typo ("inforcement" -> "enforcement").
(props @ericandrewlewis, #236)
-
Coding Standards audit
(props @DrewAPicture, #235)
-
Add comparison documentation.
-
json_url
filter call should be passed$scheme
(props @ericandrewlewis, #243)
-
Set
class-jsonserializable.php
file mode to 644.(props @jeremyfelt, #255)
-
Remove unneeded "which" in implementation doc.
(props @JDGrimes, #254)
-
Fix a copy/paste error in schema doc.
(props @JDGrimes, #253)
-
Correct reference link in example schema.
(props @danielbachhuber, #258)
-
Add missing post formats to post schema documentation.
(props @danielbachhuber, #260)
-
Ensure we always use "public" on public methods.
(props @danielbachhuber, #268)
-
Ensure we don't cause a PHP error if a post does not have revisions.
(props @rmccue, #227)
-
Add note to where upload_files cap comes from
(props @pkevan, #282)
-
Add handling of
sticky
property when creating or editing posts.(props @rachelbaker, #218)
-
Update post route endpoint docs to include details on
post_meta
handling.(props @rachelbaker, #213)
-
Update main readme file to better describe the project.
(props @rmccue, #303)
-
Fix
--data-binary
cURL option in documentation
-
Add user endpoints.
Creating, reading, updating and deleting users and their data is now possible by using the
/users
endpoints./users/me
can be used to determine the current user, and returns a 401 status for non-logged in users.Note that the format of post authors has changed, as it is now an embedded User entity. This should not break backwards compatibility.
Custom post types gain this ability automatically.
-
Add post meta endpoints.
Creating, reading, updating and deleting post meta is now possible by using the
/posts/<id>/meta
endpoints. Post meta is now correctly embedded into Post entities.Meta can be updated via the Post entity (e.g.
PUT
to/posts/<id>
) or via the entity itself at/posts/<id>/meta/<mid>
. Meta deletion must be done via aDELETE
request to the latter.Only non-protected and non-serialized meta can be accessed or manipulated via the API. This is not predicted to change in the future; clients wishing to access this data should consider alternative approaches.
Custom post types do not currently gain this ability automatically.
(props @attitude, @alisspers, @rachelbaker, @rmccue, @tlovett1, @tobych, @zedejose, #68, #168, #189, #207)
-
Add endpoint for deleting a single comment.
Clients can now send a
DELETE
request to comment routes to delete the comment.Custom post types supporting comments will gain this ability automatically.
-
Add endpoint for post revisions.
Post revisions are now available at
/posts/<id>/revisions
, and are linked in themeta.links.version-history
key of post entities.Custom post types supporting revisions will gain this ability automatically.
(props @tlovett1, #193)
-
Respond to requests without depending on pretty permalink settings.
For sites without pretty permalinks enabled, the API is now available from
?json_route=/
. Clients should check for this via the autodiscovery methods (Link header or RSD). -
Add register post type argument.
Post types can now indicate their availability via the API using the
show_in_json
argument passed toregister_post_type
. This value defaults to thepublicly_queryable
argument (which itself defaults to thepublic
argument).(props @iandunn, @rmccue, #145)
-
Remove basic authentication handler.
This breaks backwards compatibility for clients using Basic authentication. Clients are encouraged to switch to using OAuth authentication. The Basic Authentication plugin can be installed for backwards compatibility and local development, however should not be used in production.
-
Require nonces for cookie-based authentication.
This breaks backwards compatibility and requires any clients using cookie authentication to also send a nonce with the request. The built-in Javascript API automatically handles this.
-
Clean up deprecated methods/functions.
Functions and methods previously deprecated in 0.8/0.9 have now been removed. Future deprecations will take place in the same manner as WordPress core.
This breaks backwards compatibility, however these were marked as deprecated in previous releases.
(props @rmccue, #187)
-
Only expose meta on 'edit' context as a temporary workaround.
Privacy concerns around exposing meta to all users necessitate this change.
This breaks backwards compatibility as post meta data is no longer available to all users. Clients wishing to access this data should authenticate and use the
edit
context.(props @iandunn, @rmccue, #135)
-
Add
json_ensure_response
function to ensure either aWP_JSON_ResponseInterface
or aWP_Error
object is returned.When extending the API, the
json_ensure_response
function can be used to ensure that any raw data returned is wrapped with aWP_JSON_Response
object. This allows usingget_status
/get_data
easily, howeverWP_Error
must still be checked viais_wp_error
. -
Use version option to check on init if rewrite rules should be flushed.
Rewrite rules on multisite are now flushed via an init hook, rather than switching to each site on activation.
(props @rachelbaker, #149)
-
Fix typo in schema docs
(props @codebykat, #132)
-
Add check for valid JSON data before using to avoid parameter overwrite.
When passing data to an endpoint that accepts JSON data, the data will now be validated before passing to the endpoint.
(props @rachelbaker, @rmccue, #133)
-
Add authentication property to site index.
(props @rmccue, #131)
-
Move the test helper to a subdirectory.
The plugin will now no longer prompt for updates due to the helper.
(props @rmccue, #127)
-
Include post ID with
json_prepare_meta
filter.(props @rmccue, #137)
-
Corrected parameter names in x-form examples in docs.
(props @rachelbaker, #134)
-
Pass
WP_JSON_Server
instance tojson_serve_request
. -
Don't use deprecated function in
WP_JSON_Posts::edit_post()
(props @rachelbaker, #150)
-
Pass post ID to
json_insert_post
action during both insert and update.(props @cmmarslender, #148)
-
Add descriptions to taxonomy term data.
(props @pushred, #111)
-
Ensure we handle raw data passed to the API.
-
Remove unused
prepare_author
method fromWP_JSON_Posts
class.(props @rachelbaker, #165)
-
Add multiple post type support to get_posts method.
-
Return
WP_Error
inWP_JSON_Posts::get_comment
for invalid comments. -
Update getting started documentation.
(props @rmccue, #176)
-
Improve and clarify "array" input syntax documentation.
-
Update post routes documentation.
-
Add documentation for user endpoints.
(props @rachelbaker, @rmccue, #158)
-
Add permalink settings step to Quick Setup instructions.
(props @kadamwhite, #183)
-
Update taxonomy collection to return indexed array.
(props @mattheu, #184)
-
Remove placeholder endpoints.
-
Fix issues with embedded attachments.
Checks that the post supports attachment data before adding it, and ensures we don't embed entities many layers deep.
(props @rmccue, #194)
-
Change post parent preparation context to embed.
(props @rmccue, #195)
-
Change server meta links to reference the WP-API organization GitHub repo.
(props @rachelbaker, #208)
-
Fix plugin tests
(props @rmccue, #215)
-
Check for errors with invalid dates and remove duplicate date parsing methods.
-
Move from
wp-json.php/
towp-json/
This breaks backwards compatibility and requires any clients to now use
wp-json/
, or preferably the new RSD/Link headers. -
Move filter registration out of CPT constructor. CPT subclasses now require you to call
$myobject->register_filters()
, in order to move global state out of the constructor.This breaks backwards compatibility and requires any subclassing to now call
$myobject->register_filters()
-
Introduce Response/ResponseInterface
Endpoints that need to set headers or response codes should now return a
WP_JSON_Response
rather than using the server methods.WP_JSON_ResponseInterface
may also be used for more flexible use of the response methods.Deprecation warning: Calling
WP_JSON_Server::header
,WP_JSON_Server::link_header
andWP_JSON_Server::query_navigation_headers
is now deprecated. This will be removed in 1.0.(props @rmccue, #33)
-
Change all semiCamelCase names to underscore_case.
Deprecation warning: Any calls to semiCamelCase methods require any subclassing to update method references. This will be removed in 1.0.
-
Add multisite compatibility. If the plugin is network activated, the plugin is now activated once-per-site, so
wp-json/
is always site-local. -
Add RSD and Link headers for discovery
(props @rmccue, #40)
-
WP_JSON_Posts->prepare_author() now verifies the
$user
object is set. -
Added unit testing framework. Currently only a smaller number of tests, but we plan to increase this significantly as soon as possible.
-
Link collection filtering docs to URL formatting guide.
(props @kadamwhite, #74)
-
Remove hardcoded
/pages
references fromWP_JSON_Pages
-
Fix compatibility with
DateTime::createFromFormat
on PHP 5.2 -
Document that
WP_JSON_CustomPostType::__construct()
requires a param of typeWP_JSON_ResponseHandler
.(props @tlovett1, #88)
-
Add timezone parameter to WP_JSON_DateTime::createFromFormat()
-
Remove IXR references.
IXR_Error
is no longer accepted as a return value.This breaks backwards compatibility and requires anyone returning
IXR_Error
objects to now returnWP_Error
orWP_JSON_ResponseInterface
objects. -
Fix bugs with attaching featured images to posts:
WP_JSON_Media::attachThumbnail()
should do nothing if$update
is false without a post ID- The post ID must be fetched from the
$post
array.
(props @Webbgaraget, #55)
-
Don't declare
jsonSerialize
on ResponseInterface(props @rmccue, #97)
-
Allow JSON post creation/update for
WP_JSON_CustomPostType
-
Return null if post doesn't have an excerpt
(props @rachelbacker, #72)
-
Fix link to issue tracker in README
(props @rmccue, @tobych, #125)
-
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 ofplugins_loaded
in the Extending documentation for plugins(props @phh, #43)
-
Parse the avatar URL from the
get_avatar()
function in core, allowing custom avatar implementations -
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
-
Remove redundant
get_avatar
method inWP_JSON_Posts
(props @rachelbaker, #35)
-
Rename
WP_JSON_Server::get_avatar()
toWP_JSON_Server::get_avatar_url()
(props @rachelbaker, #35)
-
The response handler object is now passed into the endpoint objects via the constructor, allowing you to avoid excess global state where possible. It's recommended to use this where possible rather than the global object.
(props @rmccue, #2)
-
Fix undefined variables and indices (props @pippinsplugins, #5)
-
Correct call to deactivation hook (props @ericpedia, #9)
-
Check metadata access correctly rather than always hiding for users without the
edit_post_meta
capability (props @kokarn, #10) -
Return all term metadata, rather than just the last one (props @afurculita, #13)
-
Access post metadata from cache where possible - Note, this is a backwards compatibility break, as the format of the metadata has changed. This may change again in the near future, so don't rely on it until 1.0. (props @afurculita, #14)
-
Add term_link to prepare_term (props @afurculita, #15)
-
Fix hardcoded
/pages
references inWP_JSON_CustomPostType
(props @thenbrent, #26) -
Sanitize headers for newlines (props @kokarn, #7)
-
Register rewrite rules during plugin activation (props @pippinsplugins, #17)
- Huge documentation update - Guides on getting started and extending the API are now available for your perusal
- Add generic CPT class - Plugins are now encouraged to extend
WP_JSON_CustomPostType
and get free hooking for common actions. This removes most of the boilerplate that you needed to write for new CPT-based routes and endpoints (#380) - Use defined filter priorities for endpoint registration - It's now easier to inject your own endpoints at a defined point
- Update the schema - Now includes documentation on the Media entity, plus more (#264)
- Add better taxonomy support - You can now query for taxonomies and terms
directly. The routes here might seem strange
(
/posts/types/post/taxonomies/category
for example), but the intention is to future-proof them as much as possible(#275) - Ensure the JSON URL is relative to the home URL (#375)
- Check all date formats for If-Unmodified-Since (#378)
- Register the correct URL for the JS library (#376)
- Correct the usage of meta links (#379)
- Add filters for post type and post status data (#380)
- Separate parent post and parent comment relation (#330()
-
Add support for media - This has been a long time coming, and it's finally at a point where I'm happy to push it out. Good luck. (#272)
-
Separate the post-related endpoints - Post-related endpoints are now located in the
WP_JSON_Posts
class. When implementing custom post type support, it's recommended to subclass this.The various types are now also only registered via hooks, rather than directly in the server class, which should make it easier to override them as well (#348)
-
Add page support - This is a good base if you're looking to create your own custom post type support (#271)
-
Switch from fields to context - Rather than passing in a list of fields that you want, you can now pass in a context (usually
view
oredit
) (#328). -
Always send headers via the server handler - Endpoints are now completely separate from the request, so the server class can now be used for non-HTTP/JSON handlers if needed (#293)
-
Use better error codes for disabled features (#338)
-
Send
X-WP-Total
andX-WP-TotalPages
headers for information on post/pagination counts (#266)
- Add Backbone-based models and collections - These are available to your code
by declaring a dependency on
wp-api
(#270) - Check
json_route
before using it (#336) - Conditionally load classes (#337)
- Add additional test helper plugin - Provides code coverage as needed to the API client tests. Currently unused. (#269)
- Move
json_url()
andget_json_url()
toplugin.php
- This allows using both outside of the API itself (#343) getPost(0)
now returns an error rather than the latest post (#344)
- Add initial comment endpoints to get comments for a post, and get a single comment (#320)
- Return a Post entity when updating a post, rather than wrapping it with useless text (#329)
- Allow filtering the output as well as input. You can now use the
json_dispatch_args
filter for input as well as thejson_serve_request
filter for output to serve up alternative formats (e.g. MsgPack, XML (if you're insane)) - Include a
profile
link in the index, to indicate the JSON Schema that the API conforms to. In the future, this will be versioned.
- Allow all public query vars to be passed to WP Query - Some private query vars
can also be passed in, and all can if the user has
edit_posts
permissions (#311) - Pagination can now be handled by using the
page
argument without messing with WP Query syntax (#266) - The index now generates links for non-variable routes (#268)
- Editing a post now supports the
If-Unmodified-Since
header. Pass this in to avoid conflicting edits (#294) - Post types and post statuses now have endpoints to access their data (#268)
- Disable media handling to avoid fatal error (#298)
- No changes, process error
- Enable the code to be used via the plugin architecture (now uses rewrite rules if running in this mode)
- Design documents are now functionally complete for the current codebase (#264)
- Add basic writing support (#265)
- Filter fields by default - Unfiltered results are available via their
corresponding
*_raw
key, which is only available to users withedit_posts
(#290) - Use correct timezones for manual offsets (GMT+10, e.g.) (#279)
- Allow permanently deleting posts (#292)
- Hyperlinks now available in most constructs under the 'meta' key. At the moment, the only thing under this key is 'links', but more will come eventually. (Try browsing with a browser tool like JSONView; you should be able to view all content just by clicking the links.)
- Accessing / now gives an index which briefly describes the API and gives links to more (also added the HIDDEN_ENDPOINT constant to hide from this).
- Post collections now contain a summary of the post, with the full post available via the single post call. (prepare_post() has fields split into post and post-extended)
- Post entities have dropped post_ prefixes, and custom_fields has changed to post_meta.
- Now supports JSONP callback via the _jsonp argument. This can be disabled separately to the API itself, as it's only needed for cross-origin requests.
- Internal: No longer extends the XMLRPC class. All relevant pieces have been copied over. Further work still needs to be done on this, but it's a start.
- Now accepts JSON bodies if an endpoint is marked with ACCEPT_JSON