From d6e311ddb0583e3508ca3478fd211c69ad9b7b0a Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Wed, 15 Nov 2017 19:20:12 +0300 Subject: [PATCH] added batch removal feature Now each attachment has checkbox to select multiple attachments. if any of them are checked 'Remove selected' button appears at a bottom of metabox near Add button. Clicking on it will remove selected items. --- classes/class.attachments.php | 28 ++++++++++++++++++++++++++++ css/attachments.css | 16 ++++++++++++++++ index.php | 2 +- js/attachments.js | 9 +++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/classes/class.attachments.php b/classes/class.attachments.php index 2aff952..16eb281 100644 --- a/classes/class.attachments.php +++ b/classes/class.attachments.php @@ -736,6 +736,7 @@ function meta_box_markup( $post, $metabox ) { append == true ) : ?>
button_text ), 'attachments' ); ?> +
@@ -975,6 +976,31 @@ function(){ } ); + $element.on('click', '.attachments-batch-remove', function removeSelectedAttachments(event){ + + if(confirm('')){ + + var $btn = $(this), + $attachmentsToRemove = $('.select-attachment:checked', $element).parents('.attachments-attachment'); + + $btn.hide(); + $attachmentsToRemove.find('.attachment-meta').fadeOut(125); + $attachmentsToRemove.css('min-height',0).animate( + { + padding: 0, + margin: 0, + height: 0 + }, + 600, + function(){ + $attachmentsToRemove.remove(); + } + ); + + } + }); + + }); "> uid ) ) ? $attachment->uid : '{{ attachments.attachment_uid }}'; ?> + +