From 31322f220a217b2617df8d69cba2f43144ff8939 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 11 Jul 2013 00:20:36 +0000 Subject: [PATCH] Rename wp.xhr to wp.ajax to match admin-ajax.php (which it uses), jQuery.ajax (which it wraps), etc. see #24424. git-svn-id: https://develop.svn.wordpress.org/trunk@24652 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/js/revisions.js | 2 +- wp-includes/js/media-models.js | 8 ++++---- wp-includes/js/wp-util.js | 14 +++++++------- wp-includes/script-loader.php | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/wp-admin/js/revisions.js b/wp-admin/js/revisions.js index e989f72ad2..5c2e4869d7 100644 --- a/wp-admin/js/revisions.js +++ b/wp-admin/js/revisions.js @@ -207,7 +207,7 @@ window.wp = window.wp || {}; post_id: revisions.settings.postId }); - var deferred = wp.xhr.send( options ); + var deferred = wp.ajax.send( options ); var requests = this.requests; // Record that we're requesting each diff. diff --git a/wp-includes/js/media-models.js b/wp-includes/js/media-models.js index 602f850cd3..9e4be55d04 100644 --- a/wp-includes/js/media-models.js +++ b/wp-includes/js/media-models.js @@ -101,17 +101,17 @@ window.wp = window.wp || {}; * media.post( [action], [data] ) * * Sends a POST request to WordPress. - * See wp.xhr.post() in `wp-includes/js/wp-util.js`. + * See wp.ajax.post() in `wp-includes/js/wp-util.js`. */ - post: wp.xhr.post, + post: wp.ajax.post, /** * media.ajax( [action], [options] ) * * Sends an XHR request to WordPress. - * See wp.xhr.send() in `wp-includes/js/wp-util.js`. + * See wp.ajax.send() in `wp-includes/js/wp-util.js`. */ - ajax: wp.xhr.send, + ajax: wp.ajax.send, // Scales a set of dimensions to fit within bounding dimensions. fit: function( dimensions ) { diff --git a/wp-includes/js/wp-util.js b/wp-includes/js/wp-util.js index b809d6169b..701ec3ea43 100644 --- a/wp-includes/js/wp-util.js +++ b/wp-includes/js/wp-util.js @@ -28,16 +28,16 @@ window.wp = window.wp || {}; }; }); - // wp.xhr + // wp.ajax // ------ // // Tools for sending ajax requests with JSON responses and built in error handling. // Mirrors and wraps jQuery's ajax APIs. - wp.xhr = { - settings: settings.xhr || {}, + wp.ajax = { + settings: settings.ajax || {}, /** - * wp.xhr.post( [action], [data] ) + * wp.ajax.post( [action], [data] ) * * Sends a POST request to WordPress. * @@ -46,13 +46,13 @@ window.wp = window.wp || {}; * @return {$.promise} A jQuery promise that represents the request. */ post: function( action, data ) { - return wp.xhr.send({ + return wp.ajax.send({ data: _.isObject( action ) ? action : _.extend( data || {}, { action: action }) }); }, /** - * wp.xhr.send( [action], [options] ) + * wp.ajax.send( [action], [options] ) * * Sends a POST request to WordPress. * @@ -70,7 +70,7 @@ window.wp = window.wp || {}; options = _.defaults( options || {}, { type: 'POST', - url: wp.xhr.settings.url, + url: wp.ajax.settings.url, context: this }); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index cb67d1ef53..6e44c8d90e 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -269,7 +269,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'wp-util', "/wp-includes/js/wp-util$suffix.js", array('underscore', 'jquery'), false, 1 ); did_action( 'init' ) && $scripts->localize( 'wp-util', '_wpUtilSettings', array( - 'xhr' => array( + 'ajax' => array( 'url' => admin_url( 'admin-ajax.php', 'relative' ), ), ) );