[wp-trac] [WordPress Trac] #38490: Add settings to the `/wp/v2/settings` endpoint that are in the WordPress.com api

WordPress Trac noreply at wordpress.org
Fri Nov 4 03:09:26 UTC 2016


#38490: Add settings to the `/wp/v2/settings` endpoint that are in the
WordPress.com api
-----------------------------------------+-----------------------
 Reporter:  joehoyle                     |       Owner:  joehoyle
     Type:  task (blessed)               |      Status:  assigned
 Priority:  normal                       |   Milestone:  4.7
Component:  REST API                     |     Version:
 Severity:  normal                       |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:
-----------------------------------------+-----------------------

Comment (by jnylen0):

 Thanks for the tip about `register_setting_args` and `readonly` @joehoyle.
 Needs a patch in order to work correctly - in `38490.3.diff`:

 - Show arguments list for `GET /wp/v2/settings` (they are already present
 for the update endpoint)
 - Allow passing `readonly` settings through the schema code
 (`get_endpoint_args_for_item_schema( WP_REST_Server::READABLE )` and
 `get_data_for_route`); otherwise settings marked as read-only are excluded
 from the argument list.  There are no other changes to the
 `/wp/v2?context=help` response as a result of this, because elsewhere,
 `get_endpoint_args_for_item_schema` is always called with a method other
 than `READABLE`.
 - Test case for the new behavior

 In general your comment makes sense to me: "an unsettable setting is a
 misnomer IMO [and] it shouldn't be in the settings endpoint".

 There's already a way to enforce read-only behavior (the
 `rest_pre_update_setting` filter introduced in https://github.com/WP-API
 /WP-API/pull/2864).  Since this is such a special use case, I don't think
 we need to make the `readonly` flag control this.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38490#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list