From 8b6b45c96b61329dd87a340a0d6c9cccf9b7c7c5 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sun, 13 Aug 2017 06:10:11 +0000 Subject: [PATCH] Customize: Prevent attachment deletions from silently failing in media modals opened for Media widgets. Amends [40640]. See #32417. Fixes #41609. git-svn-id: https://develop.svn.wordpress.org/trunk@41248 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/widgets/media-widgets.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/js/widgets/media-widgets.js b/src/wp-admin/js/widgets/media-widgets.js index c4f23e1cda..452a9e38eb 100644 --- a/src/wp-admin/js/widgets/media-widgets.js +++ b/src/wp-admin/js/widgets/media-widgets.js @@ -708,10 +708,14 @@ wp.mediaWidgets = ( function( $ ) { control.model.set( control.getModelPropsFromMediaFrame( mediaFrame ) ); }); - // Disable syncing of attachment changes back to server. See . + // Disable syncing of attachment changes back to server (except for deletions). See . defaultSync = wp.media.model.Attachment.prototype.sync; - wp.media.model.Attachment.prototype.sync = function rejectedSync() { - return $.Deferred().rejectWith( this ).promise(); + wp.media.model.Attachment.prototype.sync = function( method ) { + if ( 'delete' === method ) { + return defaultSync.apply( this, arguments ); + } else { + return $.Deferred().rejectWith( this ).promise(); + } }; mediaFrame.on( 'close', function onClose() { wp.media.model.Attachment.prototype.sync = defaultSync;