Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js
File: wp-api.js
if ( _.isFunction( model.nonce ) && ! _.isEmpty( model.nonce() ) ) {
[1000] Fix | Delete
beforeSend = options.beforeSend;
[1001] Fix | Delete
[1002] Fix | Delete
// Include the nonce with requests.
[1003] Fix | Delete
options.beforeSend = function( xhr ) {
[1004] Fix | Delete
xhr.setRequestHeader( 'X-WP-Nonce', model.nonce() );
[1005] Fix | Delete
[1006] Fix | Delete
if ( beforeSend ) {
[1007] Fix | Delete
return beforeSend.apply( self, arguments );
[1008] Fix | Delete
}
[1009] Fix | Delete
};
[1010] Fix | Delete
[1011] Fix | Delete
// Update the nonce when a new nonce is returned with the response.
[1012] Fix | Delete
options.complete = function( xhr ) {
[1013] Fix | Delete
var returnedNonce = xhr.getResponseHeader( 'X-WP-Nonce' );
[1014] Fix | Delete
[1015] Fix | Delete
if ( returnedNonce && _.isFunction( model.nonce ) && model.nonce() !== returnedNonce ) {
[1016] Fix | Delete
model.endpointModel.set( 'nonce', returnedNonce );
[1017] Fix | Delete
}
[1018] Fix | Delete
};
[1019] Fix | Delete
}
[1020] Fix | Delete
[1021] Fix | Delete
// When reading, add pagination data.
[1022] Fix | Delete
if ( 'read' === method ) {
[1023] Fix | Delete
if ( options.data ) {
[1024] Fix | Delete
self.state.data = _.clone( options.data );
[1025] Fix | Delete
[1026] Fix | Delete
delete self.state.data.page;
[1027] Fix | Delete
} else {
[1028] Fix | Delete
self.state.data = options.data = {};
[1029] Fix | Delete
}
[1030] Fix | Delete
[1031] Fix | Delete
if ( 'undefined' === typeof options.data.page ) {
[1032] Fix | Delete
self.state.currentPage = null;
[1033] Fix | Delete
self.state.totalPages = null;
[1034] Fix | Delete
self.state.totalObjects = null;
[1035] Fix | Delete
} else {
[1036] Fix | Delete
self.state.currentPage = options.data.page - 1;
[1037] Fix | Delete
}
[1038] Fix | Delete
[1039] Fix | Delete
success = options.success;
[1040] Fix | Delete
options.success = function( data, textStatus, request ) {
[1041] Fix | Delete
if ( ! _.isUndefined( request ) ) {
[1042] Fix | Delete
self.state.totalPages = parseInt( request.getResponseHeader( 'x-wp-totalpages' ), 10 );
[1043] Fix | Delete
self.state.totalObjects = parseInt( request.getResponseHeader( 'x-wp-total' ), 10 );
[1044] Fix | Delete
}
[1045] Fix | Delete
[1046] Fix | Delete
if ( null === self.state.currentPage ) {
[1047] Fix | Delete
self.state.currentPage = 1;
[1048] Fix | Delete
} else {
[1049] Fix | Delete
self.state.currentPage++;
[1050] Fix | Delete
}
[1051] Fix | Delete
[1052] Fix | Delete
if ( success ) {
[1053] Fix | Delete
return success.apply( this, arguments );
[1054] Fix | Delete
}
[1055] Fix | Delete
};
[1056] Fix | Delete
}
[1057] Fix | Delete
[1058] Fix | Delete
// Continue by calling Backbone's sync.
[1059] Fix | Delete
return Backbone.sync( method, model, options );
[1060] Fix | Delete
},
[1061] Fix | Delete
[1062] Fix | Delete
/**
[1063] Fix | Delete
* Fetches the next page of objects if a new page exists.
[1064] Fix | Delete
*
[1065] Fix | Delete
* @param {data: {page}} options.
[1066] Fix | Delete
* @return {*}.
[1067] Fix | Delete
*/
[1068] Fix | Delete
more: function( options ) {
[1069] Fix | Delete
options = options || {};
[1070] Fix | Delete
options.data = options.data || {};
[1071] Fix | Delete
[1072] Fix | Delete
_.extend( options.data, this.state.data );
[1073] Fix | Delete
[1074] Fix | Delete
if ( 'undefined' === typeof options.data.page ) {
[1075] Fix | Delete
if ( ! this.hasMore() ) {
[1076] Fix | Delete
return false;
[1077] Fix | Delete
}
[1078] Fix | Delete
[1079] Fix | Delete
if ( null === this.state.currentPage || this.state.currentPage <= 1 ) {
[1080] Fix | Delete
options.data.page = 2;
[1081] Fix | Delete
} else {
[1082] Fix | Delete
options.data.page = this.state.currentPage + 1;
[1083] Fix | Delete
}
[1084] Fix | Delete
}
[1085] Fix | Delete
[1086] Fix | Delete
return this.fetch( options );
[1087] Fix | Delete
},
[1088] Fix | Delete
[1089] Fix | Delete
/**
[1090] Fix | Delete
* Returns true if there are more pages of objects available.
[1091] Fix | Delete
*
[1092] Fix | Delete
* @return {null|boolean}
[1093] Fix | Delete
*/
[1094] Fix | Delete
hasMore: function() {
[1095] Fix | Delete
if ( null === this.state.totalPages ||
[1096] Fix | Delete
null === this.state.totalObjects ||
[1097] Fix | Delete
null === this.state.currentPage ) {
[1098] Fix | Delete
return null;
[1099] Fix | Delete
} else {
[1100] Fix | Delete
return ( this.state.currentPage < this.state.totalPages );
[1101] Fix | Delete
}
[1102] Fix | Delete
}
[1103] Fix | Delete
}
[1104] Fix | Delete
);
[1105] Fix | Delete
[1106] Fix | Delete
} )();
[1107] Fix | Delete
[1108] Fix | Delete
( function() {
[1109] Fix | Delete
[1110] Fix | Delete
'use strict';
[1111] Fix | Delete
[1112] Fix | Delete
var Endpoint, initializedDeferreds = {},
[1113] Fix | Delete
wpApiSettings = window.wpApiSettings || {};
[1114] Fix | Delete
[1115] Fix | Delete
/** @namespace wp */
[1116] Fix | Delete
window.wp = window.wp || {};
[1117] Fix | Delete
[1118] Fix | Delete
/** @namespace wp.api */
[1119] Fix | Delete
wp.api = wp.api || {};
[1120] Fix | Delete
[1121] Fix | Delete
// If wpApiSettings is unavailable, try the default.
[1122] Fix | Delete
if ( _.isEmpty( wpApiSettings ) ) {
[1123] Fix | Delete
wpApiSettings.root = window.location.origin + '/wp-json/';
[1124] Fix | Delete
}
[1125] Fix | Delete
[1126] Fix | Delete
Endpoint = Backbone.Model.extend(/** @lends Endpoint.prototype */{
[1127] Fix | Delete
defaults: {
[1128] Fix | Delete
apiRoot: wpApiSettings.root,
[1129] Fix | Delete
versionString: wp.api.versionString,
[1130] Fix | Delete
nonce: null,
[1131] Fix | Delete
schema: null,
[1132] Fix | Delete
models: {},
[1133] Fix | Delete
collections: {}
[1134] Fix | Delete
},
[1135] Fix | Delete
[1136] Fix | Delete
/**
[1137] Fix | Delete
* Initialize the Endpoint model.
[1138] Fix | Delete
*/
[1139] Fix | Delete
initialize: function() {
[1140] Fix | Delete
var model = this, deferred;
[1141] Fix | Delete
[1142] Fix | Delete
Backbone.Model.prototype.initialize.apply( model, arguments );
[1143] Fix | Delete
[1144] Fix | Delete
deferred = jQuery.Deferred();
[1145] Fix | Delete
model.schemaConstructed = deferred.promise();
[1146] Fix | Delete
[1147] Fix | Delete
model.schemaModel = new wp.api.models.Schema( null, {
[1148] Fix | Delete
apiRoot: model.get( 'apiRoot' ),
[1149] Fix | Delete
versionString: model.get( 'versionString' ),
[1150] Fix | Delete
nonce: model.get( 'nonce' )
[1151] Fix | Delete
} );
[1152] Fix | Delete
[1153] Fix | Delete
// When the model loads, resolve the promise.
[1154] Fix | Delete
model.schemaModel.once( 'change', function() {
[1155] Fix | Delete
model.constructFromSchema();
[1156] Fix | Delete
deferred.resolve( model );
[1157] Fix | Delete
} );
[1158] Fix | Delete
[1159] Fix | Delete
if ( model.get( 'schema' ) ) {
[1160] Fix | Delete
[1161] Fix | Delete
// Use schema supplied as model attribute.
[1162] Fix | Delete
model.schemaModel.set( model.schemaModel.parse( model.get( 'schema' ) ) );
[1163] Fix | Delete
} else if (
[1164] Fix | Delete
! _.isUndefined( sessionStorage ) &&
[1165] Fix | Delete
( _.isUndefined( wpApiSettings.cacheSchema ) || wpApiSettings.cacheSchema ) &&
[1166] Fix | Delete
sessionStorage.getItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ) )
[1167] Fix | Delete
) {
[1168] Fix | Delete
[1169] Fix | Delete
// Used a cached copy of the schema model if available.
[1170] Fix | Delete
model.schemaModel.set( model.schemaModel.parse( JSON.parse( sessionStorage.getItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ) ) ) ) );
[1171] Fix | Delete
} else {
[1172] Fix | Delete
model.schemaModel.fetch( {
[1173] Fix | Delete
/**
[1174] Fix | Delete
* When the server returns the schema model data, store the data in a sessionCache so we don't
[1175] Fix | Delete
* have to retrieve it again for this session. Then, construct the models and collections based
[1176] Fix | Delete
* on the schema model data.
[1177] Fix | Delete
*
[1178] Fix | Delete
* @ignore
[1179] Fix | Delete
*/
[1180] Fix | Delete
success: function( newSchemaModel ) {
[1181] Fix | Delete
[1182] Fix | Delete
// Store a copy of the schema model in the session cache if available.
[1183] Fix | Delete
if ( ! _.isUndefined( sessionStorage ) && ( _.isUndefined( wpApiSettings.cacheSchema ) || wpApiSettings.cacheSchema ) ) {
[1184] Fix | Delete
try {
[1185] Fix | Delete
sessionStorage.setItem( 'wp-api-schema-model' + model.get( 'apiRoot' ) + model.get( 'versionString' ), JSON.stringify( newSchemaModel ) );
[1186] Fix | Delete
} catch ( error ) {
[1187] Fix | Delete
[1188] Fix | Delete
// Fail silently, fixes errors in safari private mode.
[1189] Fix | Delete
}
[1190] Fix | Delete
}
[1191] Fix | Delete
},
[1192] Fix | Delete
[1193] Fix | Delete
// Log the error condition.
[1194] Fix | Delete
error: function( err ) {
[1195] Fix | Delete
window.console.log( err );
[1196] Fix | Delete
}
[1197] Fix | Delete
} );
[1198] Fix | Delete
}
[1199] Fix | Delete
},
[1200] Fix | Delete
[1201] Fix | Delete
constructFromSchema: function() {
[1202] Fix | Delete
var routeModel = this, modelRoutes, collectionRoutes, schemaRoot, loadingObjects,
[1203] Fix | Delete
[1204] Fix | Delete
/**
[1205] Fix | Delete
* Set up the model and collection name mapping options. As the schema is built, the
[1206] Fix | Delete
* model and collection names will be adjusted if they are found in the mapping object.
[1207] Fix | Delete
*
[1208] Fix | Delete
* Localizing a variable wpApiSettings.mapping will over-ride the default mapping options.
[1209] Fix | Delete
*
[1210] Fix | Delete
*/
[1211] Fix | Delete
mapping = wpApiSettings.mapping || {
[1212] Fix | Delete
models: {
[1213] Fix | Delete
'Categories': 'Category',
[1214] Fix | Delete
'Comments': 'Comment',
[1215] Fix | Delete
'Pages': 'Page',
[1216] Fix | Delete
'PagesMeta': 'PageMeta',
[1217] Fix | Delete
'PagesRevisions': 'PageRevision',
[1218] Fix | Delete
'Posts': 'Post',
[1219] Fix | Delete
'PostsCategories': 'PostCategory',
[1220] Fix | Delete
'PostsRevisions': 'PostRevision',
[1221] Fix | Delete
'PostsTags': 'PostTag',
[1222] Fix | Delete
'Schema': 'Schema',
[1223] Fix | Delete
'Statuses': 'Status',
[1224] Fix | Delete
'Tags': 'Tag',
[1225] Fix | Delete
'Taxonomies': 'Taxonomy',
[1226] Fix | Delete
'Types': 'Type',
[1227] Fix | Delete
'Users': 'User'
[1228] Fix | Delete
},
[1229] Fix | Delete
collections: {
[1230] Fix | Delete
'PagesMeta': 'PageMeta',
[1231] Fix | Delete
'PagesRevisions': 'PageRevisions',
[1232] Fix | Delete
'PostsCategories': 'PostCategories',
[1233] Fix | Delete
'PostsMeta': 'PostMeta',
[1234] Fix | Delete
'PostsRevisions': 'PostRevisions',
[1235] Fix | Delete
'PostsTags': 'PostTags'
[1236] Fix | Delete
}
[1237] Fix | Delete
},
[1238] Fix | Delete
[1239] Fix | Delete
modelEndpoints = routeModel.get( 'modelEndpoints' ),
[1240] Fix | Delete
modelRegex = new RegExp( '(?:.*[+)]|\/(' + modelEndpoints.join( '|' ) + '))$' );
[1241] Fix | Delete
[1242] Fix | Delete
/**
[1243] Fix | Delete
* Iterate thru the routes, picking up models and collections to build. Builds two arrays,
[1244] Fix | Delete
* one for models and one for collections.
[1245] Fix | Delete
*/
[1246] Fix | Delete
modelRoutes = [];
[1247] Fix | Delete
collectionRoutes = [];
[1248] Fix | Delete
schemaRoot = routeModel.get( 'apiRoot' ).replace( wp.api.utils.getRootUrl(), '' );
[1249] Fix | Delete
loadingObjects = {};
[1250] Fix | Delete
[1251] Fix | Delete
/**
[1252] Fix | Delete
* Tracking objects for models and collections.
[1253] Fix | Delete
*/
[1254] Fix | Delete
loadingObjects.models = {};
[1255] Fix | Delete
loadingObjects.collections = {};
[1256] Fix | Delete
[1257] Fix | Delete
_.each( routeModel.schemaModel.get( 'routes' ), function( route, index ) {
[1258] Fix | Delete
[1259] Fix | Delete
// Skip the schema root if included in the schema.
[1260] Fix | Delete
if ( index !== routeModel.get( ' versionString' ) &&
[1261] Fix | Delete
index !== schemaRoot &&
[1262] Fix | Delete
index !== ( '/' + routeModel.get( 'versionString' ).slice( 0, -1 ) )
[1263] Fix | Delete
) {
[1264] Fix | Delete
[1265] Fix | Delete
// Single items end with a regex, or a special case word.
[1266] Fix | Delete
if ( modelRegex.test( index ) ) {
[1267] Fix | Delete
modelRoutes.push( { index: index, route: route } );
[1268] Fix | Delete
} else {
[1269] Fix | Delete
[1270] Fix | Delete
// Collections end in a name.
[1271] Fix | Delete
collectionRoutes.push( { index: index, route: route } );
[1272] Fix | Delete
}
[1273] Fix | Delete
}
[1274] Fix | Delete
} );
[1275] Fix | Delete
[1276] Fix | Delete
/**
[1277] Fix | Delete
* Construct the models.
[1278] Fix | Delete
*
[1279] Fix | Delete
* Base the class name on the route endpoint.
[1280] Fix | Delete
*/
[1281] Fix | Delete
_.each( modelRoutes, function( modelRoute ) {
[1282] Fix | Delete
[1283] Fix | Delete
// Extract the name and any parent from the route.
[1284] Fix | Delete
var modelClassName,
[1285] Fix | Delete
routeName = wp.api.utils.extractRoutePart( modelRoute.index, 2, routeModel.get( 'versionString' ), true ),
[1286] Fix | Delete
parentName = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), false ),
[1287] Fix | Delete
routeEnd = wp.api.utils.extractRoutePart( modelRoute.index, 1, routeModel.get( 'versionString' ), true );
[1288] Fix | Delete
[1289] Fix | Delete
// Clear the parent part of the rouite if its actually the version string.
[1290] Fix | Delete
if ( parentName === routeModel.get( 'versionString' ) ) {
[1291] Fix | Delete
parentName = '';
[1292] Fix | Delete
}
[1293] Fix | Delete
[1294] Fix | Delete
// Handle the special case of the 'me' route.
[1295] Fix | Delete
if ( 'me' === routeEnd ) {
[1296] Fix | Delete
routeName = 'me';
[1297] Fix | Delete
}
[1298] Fix | Delete
[1299] Fix | Delete
// If the model has a parent in its route, add that to its class name.
[1300] Fix | Delete
if ( '' !== parentName && parentName !== routeName ) {
[1301] Fix | Delete
modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( parentName ) + wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
[1302] Fix | Delete
modelClassName = mapping.models[ modelClassName ] || modelClassName;
[1303] Fix | Delete
loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( {
[1304] Fix | Delete
[1305] Fix | Delete
// Return a constructed url based on the parent and id.
[1306] Fix | Delete
url: function() {
[1307] Fix | Delete
var url =
[1308] Fix | Delete
routeModel.get( 'apiRoot' ) +
[1309] Fix | Delete
routeModel.get( 'versionString' ) +
[1310] Fix | Delete
parentName + '/' +
[1311] Fix | Delete
( ( _.isUndefined( this.get( 'parent' ) ) || 0 === this.get( 'parent' ) ) ?
[1312] Fix | Delete
( _.isUndefined( this.get( 'parent_post' ) ) ? '' : this.get( 'parent_post' ) + '/' ) :
[1313] Fix | Delete
this.get( 'parent' ) + '/' ) +
[1314] Fix | Delete
routeName;
[1315] Fix | Delete
[1316] Fix | Delete
if ( ! _.isUndefined( this.get( 'id' ) ) ) {
[1317] Fix | Delete
url += '/' + this.get( 'id' );
[1318] Fix | Delete
}
[1319] Fix | Delete
return url;
[1320] Fix | Delete
},
[1321] Fix | Delete
[1322] Fix | Delete
// Track nonces on the Endpoint 'routeModel'.
[1323] Fix | Delete
nonce: function() {
[1324] Fix | Delete
return routeModel.get( 'nonce' );
[1325] Fix | Delete
},
[1326] Fix | Delete
[1327] Fix | Delete
endpointModel: routeModel,
[1328] Fix | Delete
[1329] Fix | Delete
// Include a reference to the original route object.
[1330] Fix | Delete
route: modelRoute,
[1331] Fix | Delete
[1332] Fix | Delete
// Include a reference to the original class name.
[1333] Fix | Delete
name: modelClassName,
[1334] Fix | Delete
[1335] Fix | Delete
// Include the array of route methods for easy reference.
[1336] Fix | Delete
methods: modelRoute.route.methods,
[1337] Fix | Delete
[1338] Fix | Delete
// Include the array of route endpoints for easy reference.
[1339] Fix | Delete
endpoints: modelRoute.route.endpoints
[1340] Fix | Delete
} );
[1341] Fix | Delete
} else {
[1342] Fix | Delete
[1343] Fix | Delete
// This is a model without a parent in its route.
[1344] Fix | Delete
modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
[1345] Fix | Delete
modelClassName = mapping.models[ modelClassName ] || modelClassName;
[1346] Fix | Delete
loadingObjects.models[ modelClassName ] = wp.api.WPApiBaseModel.extend( {
[1347] Fix | Delete
[1348] Fix | Delete
// Function that returns a constructed url based on the ID.
[1349] Fix | Delete
url: function() {
[1350] Fix | Delete
var url = routeModel.get( 'apiRoot' ) +
[1351] Fix | Delete
routeModel.get( 'versionString' ) +
[1352] Fix | Delete
( ( 'me' === routeName ) ? 'users/me' : routeName );
[1353] Fix | Delete
[1354] Fix | Delete
if ( ! _.isUndefined( this.get( 'id' ) ) ) {
[1355] Fix | Delete
url += '/' + this.get( 'id' );
[1356] Fix | Delete
}
[1357] Fix | Delete
return url;
[1358] Fix | Delete
},
[1359] Fix | Delete
[1360] Fix | Delete
// Track nonces at the Endpoint level.
[1361] Fix | Delete
nonce: function() {
[1362] Fix | Delete
return routeModel.get( 'nonce' );
[1363] Fix | Delete
},
[1364] Fix | Delete
[1365] Fix | Delete
endpointModel: routeModel,
[1366] Fix | Delete
[1367] Fix | Delete
// Include a reference to the original route object.
[1368] Fix | Delete
route: modelRoute,
[1369] Fix | Delete
[1370] Fix | Delete
// Include a reference to the original class name.
[1371] Fix | Delete
name: modelClassName,
[1372] Fix | Delete
[1373] Fix | Delete
// Include the array of route methods for easy reference.
[1374] Fix | Delete
methods: modelRoute.route.methods,
[1375] Fix | Delete
[1376] Fix | Delete
// Include the array of route endpoints for easy reference.
[1377] Fix | Delete
endpoints: modelRoute.route.endpoints
[1378] Fix | Delete
} );
[1379] Fix | Delete
}
[1380] Fix | Delete
[1381] Fix | Delete
// Add defaults to the new model, pulled form the endpoint.
[1382] Fix | Delete
wp.api.utils.decorateFromRoute(
[1383] Fix | Delete
modelRoute.route.endpoints,
[1384] Fix | Delete
loadingObjects.models[ modelClassName ],
[1385] Fix | Delete
routeModel.get( 'versionString' )
[1386] Fix | Delete
);
[1387] Fix | Delete
[1388] Fix | Delete
} );
[1389] Fix | Delete
[1390] Fix | Delete
/**
[1391] Fix | Delete
* Construct the collections.
[1392] Fix | Delete
*
[1393] Fix | Delete
* Base the class name on the route endpoint.
[1394] Fix | Delete
*/
[1395] Fix | Delete
_.each( collectionRoutes, function( collectionRoute ) {
[1396] Fix | Delete
[1397] Fix | Delete
// Extract the name and any parent from the route.
[1398] Fix | Delete
var collectionClassName, modelClassName,
[1399] Fix | Delete
routeName = collectionRoute.index.slice( collectionRoute.index.lastIndexOf( '/' ) + 1 ),
[1400] Fix | Delete
parentName = wp.api.utils.extractRoutePart( collectionRoute.index, 1, routeModel.get( 'versionString' ), false );
[1401] Fix | Delete
[1402] Fix | Delete
// If the collection has a parent in its route, add that to its class name.
[1403] Fix | Delete
if ( '' !== parentName && parentName !== routeName && routeModel.get( 'versionString' ) !== parentName ) {
[1404] Fix | Delete
[1405] Fix | Delete
collectionClassName = wp.api.utils.capitalizeAndCamelCaseDashes( parentName ) + wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
[1406] Fix | Delete
modelClassName = mapping.models[ collectionClassName ] || collectionClassName;
[1407] Fix | Delete
collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName;
[1408] Fix | Delete
loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( {
[1409] Fix | Delete
[1410] Fix | Delete
// Function that returns a constructed url passed on the parent.
[1411] Fix | Delete
url: function() {
[1412] Fix | Delete
return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) +
[1413] Fix | Delete
parentName + '/' +
[1414] Fix | Delete
( ( _.isUndefined( this.parent ) || '' === this.parent ) ?
[1415] Fix | Delete
( _.isUndefined( this.get( 'parent_post' ) ) ? '' : this.get( 'parent_post' ) + '/' ) :
[1416] Fix | Delete
this.parent + '/' ) +
[1417] Fix | Delete
routeName;
[1418] Fix | Delete
},
[1419] Fix | Delete
[1420] Fix | Delete
// Specify the model that this collection contains.
[1421] Fix | Delete
model: function( attrs, options ) {
[1422] Fix | Delete
return new loadingObjects.models[ modelClassName ]( attrs, options );
[1423] Fix | Delete
},
[1424] Fix | Delete
[1425] Fix | Delete
// Track nonces at the Endpoint level.
[1426] Fix | Delete
nonce: function() {
[1427] Fix | Delete
return routeModel.get( 'nonce' );
[1428] Fix | Delete
},
[1429] Fix | Delete
[1430] Fix | Delete
endpointModel: routeModel,
[1431] Fix | Delete
[1432] Fix | Delete
// Include a reference to the original class name.
[1433] Fix | Delete
name: collectionClassName,
[1434] Fix | Delete
[1435] Fix | Delete
// Include a reference to the original route object.
[1436] Fix | Delete
route: collectionRoute,
[1437] Fix | Delete
[1438] Fix | Delete
// Include the array of route methods for easy reference.
[1439] Fix | Delete
methods: collectionRoute.route.methods
[1440] Fix | Delete
} );
[1441] Fix | Delete
} else {
[1442] Fix | Delete
[1443] Fix | Delete
// This is a collection without a parent in its route.
[1444] Fix | Delete
collectionClassName = wp.api.utils.capitalizeAndCamelCaseDashes( routeName );
[1445] Fix | Delete
modelClassName = mapping.models[ collectionClassName ] || collectionClassName;
[1446] Fix | Delete
collectionClassName = mapping.collections[ collectionClassName ] || collectionClassName;
[1447] Fix | Delete
loadingObjects.collections[ collectionClassName ] = wp.api.WPApiBaseCollection.extend( {
[1448] Fix | Delete
[1449] Fix | Delete
// For the url of a root level collection, use a string.
[1450] Fix | Delete
url: function() {
[1451] Fix | Delete
return routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + routeName;
[1452] Fix | Delete
},
[1453] Fix | Delete
[1454] Fix | Delete
// Specify the model that this collection contains.
[1455] Fix | Delete
model: function( attrs, options ) {
[1456] Fix | Delete
return new loadingObjects.models[ modelClassName ]( attrs, options );
[1457] Fix | Delete
},
[1458] Fix | Delete
[1459] Fix | Delete
// Track nonces at the Endpoint level.
[1460] Fix | Delete
nonce: function() {
[1461] Fix | Delete
return routeModel.get( 'nonce' );
[1462] Fix | Delete
},
[1463] Fix | Delete
[1464] Fix | Delete
endpointModel: routeModel,
[1465] Fix | Delete
[1466] Fix | Delete
// Include a reference to the original class name.
[1467] Fix | Delete
name: collectionClassName,
[1468] Fix | Delete
[1469] Fix | Delete
// Include a reference to the original route object.
[1470] Fix | Delete
route: collectionRoute,
[1471] Fix | Delete
[1472] Fix | Delete
// Include the array of route methods for easy reference.
[1473] Fix | Delete
methods: collectionRoute.route.methods
[1474] Fix | Delete
} );
[1475] Fix | Delete
}
[1476] Fix | Delete
[1477] Fix | Delete
// Add defaults to the new model, pulled form the endpoint.
[1478] Fix | Delete
wp.api.utils.decorateFromRoute( collectionRoute.route.endpoints, loadingObjects.collections[ collectionClassName ] );
[1479] Fix | Delete
} );
[1480] Fix | Delete
[1481] Fix | Delete
// Add mixins and helpers for each of the models.
[1482] Fix | Delete
_.each( loadingObjects.models, function( model, index ) {
[1483] Fix | Delete
loadingObjects.models[ index ] = wp.api.utils.addMixinsAndHelpers( model, index, loadingObjects );
[1484] Fix | Delete
} );
[1485] Fix | Delete
[1486] Fix | Delete
// Set the routeModel models and collections.
[1487] Fix | Delete
routeModel.set( 'models', loadingObjects.models );
[1488] Fix | Delete
routeModel.set( 'collections', loadingObjects.collections );
[1489] Fix | Delete
[1490] Fix | Delete
}
[1491] Fix | Delete
[1492] Fix | Delete
} );
[1493] Fix | Delete
[1494] Fix | Delete
wp.api.endpoints = new Backbone.Collection();
[1495] Fix | Delete
[1496] Fix | Delete
/**
[1497] Fix | Delete
* Initialize the wp-api, optionally passing the API root.
[1498] Fix | Delete
*
[1499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function