[wp-trac] [WordPress Trac] #40919: REST API: Allow overriding `jQuery.ajax` calls from within wp-admin
WordPress Trac
noreply at wordpress.org
Sun Jun 4 07:44:12 UTC 2017
#40919: REST API: Allow overriding `jQuery.ajax` calls from within wp-admin
--------------------------------------------------+-----------------------
Reporter: jnylen0 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.8.1
Component: REST API | Version: trunk
Severity: normal | Keywords: has-patch
Focuses: javascript, administration, rest-api |
--------------------------------------------------+-----------------------
In WP 4.8, there are now 3 places where we call out to the REST API from
within wp-admin (see attached patch for details):
- When viewing the settings for the video widget, to load a video preview.
- When editing the settings for a video widget in the media modal, to load
a video preview.
- When embedding from a URL in the post editor, to load an oEmbed preview.
These all call `jQuery.ajax` directly. We need to avoid this going
forward because it is impossible to override. I am aware of one large,
customized WordPress installation ''cough'' where we will need to put this
change in place as a core hack. (jQuery has
[http://api.jquery.com/jquery.ajaxprefilter/ functionality to override
AJAX request options] but this is not sufficient due to the way cross-
domain API requests work on WP.com.)
There are other benefits as well, such as testability (this wrapper will
provide a cleaner way to mock these API responses) and extensibility (this
will be a natural place to add a filter when #21170 lands).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40919>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list