Make WordPress Core

Ticket #40672: 40672.4.diff

File 40672.4.diff, 2.5 KB (added by adamsilverstein, 8 years ago)
  • src/wp-includes/js/wp-api.js

    diff --git src/wp-includes/js/wp-api.js src/wp-includes/js/wp-api.js
    index d25a9a7b81..1f19fd4062 100644
     
    811811        wp.api.WPApiBaseModel = Backbone.Model.extend(
    812812                /** @lends WPApiBaseModel.prototype  */
    813813                {
    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                         },
    843814
    844815                        /**
    845816                         * Set nonce header before every Backbone sync.
     
    12381209                                }
    12391210                        },
    12401211
    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                        };
    12431225
    12441226                        /**
    12451227                         * Iterate thru the routes, picking up models and collections to build. Builds two arrays,
     
    13371319                                                // Include the array of route methods for easy reference.
    13381320                                                methods: modelRoute.route.methods,
    13391321
     1322                                                // Initialize the model.
     1323                                                initialize: modelInitialize,
     1324
    13401325                                                // Include the array of route endpoints for easy reference.
    13411326                                                endpoints: modelRoute.route.endpoints
    13421327                                        } );
     
    13751360                                                // Include the array of route methods for easy reference.
    13761361                                                methods: modelRoute.route.methods,
    13771362
     1363                                                // Initialize the model.
     1364                                                initialize: modelInitialize,
     1365
    13781366                                                // Include the array of route endpoints for easy reference.
    13791367                                                endpoints: modelRoute.route.endpoints
    13801368                                        } );