diff --git src/wp-includes/js/wp-api.js src/wp-includes/js/wp-api.js
index 3f950a4..1fa5cdc 100644
|
|
|
1171 | 1171 | routeName = 'me'; |
1172 | 1172 | } |
1173 | 1173 | |
| 1174 | var initializeModel = function( attributes, options ) { |
| 1175 | wp.api.WPApiBaseModel.prototype.initialize.call( this, attributes, options ); |
| 1176 | |
| 1177 | /** |
| 1178 | * Determine if a model requires ?force=true to actually delete them. |
| 1179 | */ |
| 1180 | if ( |
| 1181 | ! _.isEmpty( |
| 1182 | _.filter( |
| 1183 | this.endpoints, |
| 1184 | function( endpoint ) { |
| 1185 | return ( |
| 1186 | |
| 1187 | // Does the method support DELETE? |
| 1188 | 'DELETE' === endpoint.methods[0] && |
| 1189 | |
| 1190 | // Exclude models that support trash (Post, Page). |
| 1191 | ( |
| 1192 | ! _.isUndefined( endpoint.args.force.description ) && |
| 1193 | 'Whether to bypass trash and force deletion.' !== endpoint.args.force.description |
| 1194 | ) |
| 1195 | ); |
| 1196 | } |
| 1197 | ) |
| 1198 | ) |
| 1199 | ) { |
| 1200 | this.requireForceForDelete = true; |
| 1201 | } |
| 1202 | }; |
| 1203 | |
1174 | 1204 | // If the model has a parent in its route, add that to its class name. |
1175 | 1205 | if ( '' !== parentName && parentName !== routeName ) { |
1176 | 1206 | modelClassName = wp.api.utils.capitalizeAndCamelCaseDashes( parentName ) + wp.api.utils.capitalizeAndCamelCaseDashes( routeName ); |
… |
… |
|
1203 | 1233 | // Include the array of route methods for easy reference. |
1204 | 1234 | methods: modelRoute.route.methods, |
1205 | 1235 | |
1206 | | initialize: function( attributes, options ) { |
1207 | | wp.api.WPApiBaseModel.prototype.initialize.call( this, attributes, options ); |
1208 | | |
1209 | | /** |
1210 | | * Posts and pages support trashing, other types don't support a trash |
1211 | | * and require that you pass ?force=true to actually delete them. |
1212 | | * |
1213 | | * @todo we should be getting trashability from the Schema, not hard coding types here. |
1214 | | */ |
1215 | | if ( |
1216 | | 'Posts' !== this.name && |
1217 | | 'Pages' !== this.name && |
1218 | | _.includes( this.methods, 'DELETE' ) |
1219 | | ) { |
1220 | | this.requireForceForDelete = true; |
1221 | | } |
1222 | | } |
| 1236 | // Include the array of route endpoints for easy reference. |
| 1237 | endpoints: modelRoute.route.endpoints, |
| 1238 | |
| 1239 | initialize: initializeModel |
1223 | 1240 | } ); |
1224 | 1241 | } else { |
1225 | 1242 | |
… |
… |
|
1247 | 1264 | name: modelClassName, |
1248 | 1265 | |
1249 | 1266 | // Include the array of route methods for easy reference. |
1250 | | methods: modelRoute.route.methods |
| 1267 | methods: modelRoute.route.methods, |
| 1268 | |
| 1269 | // Include the array of route endpoints for easy reference. |
| 1270 | endpoints: modelRoute.route.endpoints, |
| 1271 | |
| 1272 | initialize: initializeModel |
1251 | 1273 | } ); |
1252 | 1274 | } |
1253 | 1275 | |