[wp-trac] [WordPress Trac] #40748: Use REST API for Community Events
WordPress Trac
noreply at wordpress.org
Wed May 17 06:26:41 UTC 2017
#40748: Use REST API for Community Events
-------------------------------------------------+-------------------------
Reporter: iandunn | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future
Component: REST API | Release
Severity: normal | Version: trunk
Keywords: has-patch dev-feedback needs-unit- | Resolution:
tests | Focuses: javascript
-------------------------------------------------+-------------------------
Comment (by rmccue):
[attachment:40748.2.diff] switches from admin-ajax to the REST API, under
the new `dashboard/v1` namespace. (The specific naming of this namespace
is [https://github.com/WP-API/proposals/pull/1 under discussion], but not
relevant to this discussion.) The diffstat for record is +71 -36.
As part of this, it switches from `wp.ajax` to `$.ajax` directly. Since
there's no global variables that contain the REST API URL or nonce, we
have to keep passing these in. We could enqueue `wp-api`, but we don't
need anything else from the Backbone library, so just passing the
variables is simpler.
Because there's no other dashboard-only endpoints added yet, this includes
the minimal infrastructure work to get that happening. In particular, it
adds the new `wp-admin/includes/rest-endpoints.php` file, which is loaded
in `wp-settings.php`. We might want to move this to
`create_initial_rest_routes` to avoid loading an admin file on every page
load.
This isn't particularly RESTful or anything, and the response format isn't
what I'd really like, ''but'' since it's just a proxied response from
w.org it doesn't matter. (I previously recommended changing the format,
but hadn't realised it was just a proxied response, so apologies for
misleading there.)
This also doesn't use the controller pattern, or schema, or...
intentionally. The API was designed so that all you really need is a
single callback, because not everything needs the kitchen sink suite of
REST tools. Sometimes you just want to send some data from the server to
the client.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40748#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list