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
This commit is contained in:
parent
a29068cb00
commit
8b6b45c96b
@ -708,10 +708,14 @@ wp.mediaWidgets = ( function( $ ) {
|
|||||||
control.model.set( control.getModelPropsFromMediaFrame( mediaFrame ) );
|
control.model.set( control.getModelPropsFromMediaFrame( mediaFrame ) );
|
||||||
});
|
});
|
||||||
|
|
||||||
// Disable syncing of attachment changes back to server. See <https://core.trac.wordpress.org/ticket/40403>.
|
// Disable syncing of attachment changes back to server (except for deletions). See <https://core.trac.wordpress.org/ticket/40403>.
|
||||||
defaultSync = wp.media.model.Attachment.prototype.sync;
|
defaultSync = wp.media.model.Attachment.prototype.sync;
|
||||||
wp.media.model.Attachment.prototype.sync = function rejectedSync() {
|
wp.media.model.Attachment.prototype.sync = function( method ) {
|
||||||
return $.Deferred().rejectWith( this ).promise();
|
if ( 'delete' === method ) {
|
||||||
|
return defaultSync.apply( this, arguments );
|
||||||
|
} else {
|
||||||
|
return $.Deferred().rejectWith( this ).promise();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
mediaFrame.on( 'close', function onClose() {
|
mediaFrame.on( 'close', function onClose() {
|
||||||
wp.media.model.Attachment.prototype.sync = defaultSync;
|
wp.media.model.Attachment.prototype.sync = defaultSync;
|
||||||
|
Loading…
Reference in New Issue
Block a user