Make WordPress Core

Ticket #48981: util.js.patch

File util.js.patch, 1.2 KB (added by rimadoshi, 4 years ago)
  • src/js/_enqueues/wp/util.js

     
    105105                                // Use with PHP's wp_send_json_success() and wp_send_json_error()
    106106                                deferred.jqXHR = $.ajax( options ).done( function( response ) {
    107107                                        // Treat a response of 1 as successful for backward compatibility with existing handlers.
    108                                         if ( response === '1' || response === 1 )
    109                                                 response = { success: true };
     108                                        if ( response === '1' || response === 1 ) {
     109                                                response = {success: true};
     110                                        }
    110111
    111                                         if ( _.isObject( response ) && ! _.isUndefined( response.success ) )
    112                                                 deferred[ response.success ? 'resolveWith' : 'rejectWith' ]( this, [response.data] );
    113                                         else
    114                                                 deferred.rejectWith( this, [response] );
     112                                        if ( _.isObject( response ) && ! _.isUndefined( response.success ) ) {
     113                                                deferred[response.success ? 'resolveWith' : 'rejectWith'](this, [response.data]);
     114                                        } else {
     115                                                deferred.rejectWith(this, [response]);
     116                                        }
    115117                                }).fail( function() {
    116118                                        deferred.rejectWith( this, arguments );
    117119                                });