mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
REST API: Allow overriding jQuery.ajax calls from within wp-admin
There are now 3 places where we call out to the REST API from within wp-admin. This commit introduces a small library to allow overriding these calls, centralize nonce-passing logic, and eliminate the need to pass a full REST URL down to client code (this last feature is not yet used and will be explored in a separate ticket). Fixes #40919. git-svn-id: https://develop.svn.wordpress.org/trunk@41206 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -110,13 +110,12 @@
|
||||
control.fetchEmbedDfd.abort();
|
||||
}
|
||||
|
||||
control.fetchEmbedDfd = jQuery.ajax({
|
||||
control.fetchEmbedDfd = wp.apiRequest({
|
||||
url: wp.media.view.settings.oEmbedProxyUrl,
|
||||
data: {
|
||||
url: control.model.get( 'url' ),
|
||||
maxwidth: control.model.get( 'width' ),
|
||||
maxheight: control.model.get( 'height' ),
|
||||
_wpnonce: wp.media.view.settings.nonce.wpRestApi,
|
||||
discover: false
|
||||
},
|
||||
type: 'GET',
|
||||
|
||||
@@ -200,13 +200,12 @@ wp.mediaWidgets = ( function( $ ) {
|
||||
embedLinkView.model.attributes.url = url;
|
||||
}
|
||||
|
||||
embedLinkView.dfd = $.ajax({
|
||||
embedLinkView.dfd = wp.apiRequest({
|
||||
url: wp.media.view.settings.oEmbedProxyUrl,
|
||||
data: {
|
||||
url: url,
|
||||
maxwidth: embedLinkView.model.get( 'width' ),
|
||||
maxheight: embedLinkView.model.get( 'height' ),
|
||||
_wpnonce: wp.media.view.settings.nonce.wpRestApi,
|
||||
discover: false
|
||||
},
|
||||
type: 'GET',
|
||||
|
||||
Reference in New Issue
Block a user