[wp-trac] [WordPress Trac] #40919: REST API: Allow overriding `jQuery.ajax` calls from within wp-admin

WordPress Trac noreply at wordpress.org
Fri Jul 14 13:42:36 UTC 2017


#40919: REST API: Allow overriding `jQuery.ajax` calls from within wp-admin
-------------------------+-------------------------------------------------
 Reporter:  jnylen0      |       Owner:  jnylen0
     Type:  enhancement  |      Status:  assigned
 Priority:  normal       |   Milestone:  4.8.1
Component:  REST API     |     Version:  4.8
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |     Focuses:  javascript, administration, rest-
  dev-feedback           |  api
-------------------------+-------------------------------------------------

Comment (by jnylen0):

 In [attachment:40919.3.diff]:

 - Rename to `wp.apiRequest` to match the existing `wp.api`.
 - Use the main `window.wpApiSettings` variable to get the nonce and the
 root URL.
 - Pass the nonce as a header instead of a query string argument.
 - Allow sending requests via `path` parameter (or `namespace` and
 `endpoint` parameters) instead of requiring full URLs.  This eliminates
 the need for plugins and themes to call `rest_url` themselves.
 - Add QUnit tests.

 I would still like to get this into 4.8.1 if possible.  @westonruter
 @adamsilverstein are either of you available to take a look?

 Future follow-up steps:

 - Use this helper for AJAX requests in the `wp-api.js` client so that
 there is only one code path for providing nonces, sending requests, etc.
 This ticket sets up the appropriate script dependencies.
 - Implement nonce refreshing here.  See #37569 and #40422.

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


More information about the wp-trac mailing list