Select Git revision
disable-core-update.php
wp-api.js 45.61 KiB
(function( window, undefined ) {
'use strict';
/**
* Initialise the WP_API.
*/
function WP_API() {
/** @namespace wp.api.models */
this.models = {};
/** @namespace wp.api.collections */
this.collections = {};
/** @namespace wp.api.views */
this.views = {};
}
/** @namespace wp */
window.wp = window.wp || {};
/** @namespace wp.api */
wp.api = wp.api || new WP_API();
wp.api.versionString = wp.api.versionString || 'wp/v2/';
// Alias _includes to _.contains, ensuring it is available if lodash is used.
if ( ! _.isFunction( _.includes ) && _.isFunction( _.contains ) ) {
_.includes = _.contains;
}
})( window );
(function( window, undefined ) {
'use strict';
var pad, r;
/** @namespace wp */
window.wp = window.wp || {};
/** @namespace wp.api */
wp.api = wp.api || {};
/** @namespace wp.api.utils */
wp.api.utils = wp.api.utils || {};
/**
* Determine model based on API route.
*
* @param {string} route The API route.
*
* @return {Backbone Model} The model found at given route. Undefined if not found.
*/
wp.api.getModelByRoute = function( route ) {
return _.find( wp.api.models, function( model ) {
return model.prototype.route && route === model.prototype.route.index;
} );
};
/**
* Determine collection based on API route.
*
* @param {string} route The API route.
*
* @return {Backbone Model} The collection found at given route. Undefined if not found.
*/
wp.api.getCollectionByRoute = function( route ) {
return _.find( wp.api.collections, function( collection ) {
return collection.prototype.route && route === collection.prototype.route.index;
} );
};
/**