diff --git src/wp-includes/js/wp-api.js src/wp-includes/js/wp-api.js
index d25a9a7b81..1f19fd4062 100644
|
|
|
|
| 811 | 811 | wp.api.WPApiBaseModel = Backbone.Model.extend( |
| 812 | 812 | /** @lends WPApiBaseModel.prototype */ |
| 813 | 813 | { |
| 814 | | initialize: function( attributes, options ) { |
| 815 | | |
| 816 | | /** |
| 817 | | * Determine if a model requires ?force=true to actually delete them. |
| 818 | | */ |
| 819 | | if ( |
| 820 | | ! _.isEmpty( |
| 821 | | _.filter( |
| 822 | | this.endpoints, |
| 823 | | function( endpoint ) { |
| 824 | | return ( |
| 825 | | |
| 826 | | // Does the method support DELETE? |
| 827 | | 'DELETE' === endpoint.methods[0] && |
| 828 | | |
| 829 | | // Exclude models that support trash (Post, Page). |
| 830 | | ( |
| 831 | | ! _.isUndefined( endpoint.args.force ) && |
| 832 | | ! _.isUndefined( endpoint.args.force.description ) && |
| 833 | | 'Whether to bypass trash and force deletion.' !== endpoint.args.force.description |
| 834 | | ) |
| 835 | | ); |
| 836 | | } |
| 837 | | ) |
| 838 | | ) |
| 839 | | ) { |
| 840 | | this.requireForceForDelete = true; |
| 841 | | } |
| 842 | | }, |
| 843 | 814 | |
| 844 | 815 | /** |
| 845 | 816 | * Set nonce header before every Backbone sync. |
| … |
… |
|
| 1238 | 1209 | } |
| 1239 | 1210 | }, |
| 1240 | 1211 | |
| 1241 | | modelEndpoints = routeModel.get( 'modelEndpoints' ), |
| 1242 | | modelRegex = new RegExp( '(?:.*[+)]|\/(' + modelEndpoints.join( '|' ) + '))$' ); |
| | 1212 | modelEndpoints = routeModel.get( 'modelEndpoints' ), |
| | 1213 | modelRegex = new RegExp( '(?:.*[+)]|\/(' + modelEndpoints.join( '|' ) + '))$' ), |
| | 1214 | trashableTypes = [ 'Comment', 'Media', 'Comment', 'Post', 'Page', 'Status', 'Taxonomy', 'Type' ], |
| | 1215 | modelInitialize = function() { |
| | 1216 | |
| | 1217 | /** |
| | 1218 | * Types that don't support trashing require passing ?force=true to delete. |
| | 1219 | * |
| | 1220 | */ |
| | 1221 | if ( -1 === _.indexOf( trashableTypes, this.name ) ) { |
| | 1222 | this.requireForceForDelete = true; |
| | 1223 | } |
| | 1224 | }; |
| 1243 | 1225 | |
| 1244 | 1226 | /** |
| 1245 | 1227 | * Iterate thru the routes, picking up models and collections to build. Builds two arrays, |
| … |
… |
|
| 1337 | 1319 | // Include the array of route methods for easy reference. |
| 1338 | 1320 | methods: modelRoute.route.methods, |
| 1339 | 1321 | |
| | 1322 | // Initialize the model. |
| | 1323 | initialize: modelInitialize, |
| | 1324 | |
| 1340 | 1325 | // Include the array of route endpoints for easy reference. |
| 1341 | 1326 | endpoints: modelRoute.route.endpoints |
| 1342 | 1327 | } ); |
| … |
… |
|
| 1375 | 1360 | // Include the array of route methods for easy reference. |
| 1376 | 1361 | methods: modelRoute.route.methods, |
| 1377 | 1362 | |
| | 1363 | // Initialize the model. |
| | 1364 | initialize: modelInitialize, |
| | 1365 | |
| 1378 | 1366 | // Include the array of route endpoints for easy reference. |
| 1379 | 1367 | endpoints: modelRoute.route.endpoints |
| 1380 | 1368 | } ); |