Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions classes/class.attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ function meta_box_markup( $post, $metabox ) {
<?php if( $instance->append == true ) : ?>
<div class="attachments-invoke-wrapper">
<a class="button attachments-invoke"><?php _e( esc_attr( $instance->button_text ), 'attachments' ); ?></a>
<a class="button attachments-batch-remove" style="display: none;"><?php _e( 'Remove selected', 'attachments' ); ?></a>
</div>
<?php endif; ?>
</div>
Expand Down Expand Up @@ -975,6 +976,31 @@ function(){

} );

$element.on('click', '.attachments-batch-remove', function removeSelectedAttachments(event){

if(confirm('<?php _e('Are you sure want to remove selected items?','attachments'); ?>')){

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();
}
);

}
});


});
</script>
<?php }
Expand Down Expand Up @@ -1316,6 +1342,8 @@ function create_attachment( $instance, $attachment = null ) {
<div class="attachments-attachment attachments-attachment-<?php echo esc_attr( $instance ); ?>">
<?php $array_flag = ( isset( $attachment->uid ) ) ? $attachment->uid : '{{ attachments.attachment_uid }}'; ?>

<input type="checkbox" class="select-attachment" title="<?php _e('Check for batch operations', 'attachments'); ?>">

<input type="hidden" class="attachments-track-id" name="attachments[<?php echo esc_attr( $instance ); ?>][<?php echo esc_attr( $array_flag ); ?>][id]" value="<?php echo isset( $attachment->id ) ? esc_attr( $attachment->id ) : '{{ attachments.id }}' ; ?>" />

<?php
Expand Down
16 changes: 16 additions & 0 deletions css/attachments.css
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,19 @@ a.attachments-invoke {
.attachments-toggler:only-child {
display: none;
}

.attachments-attachment .select-attachment {
display: inline-block;
position: absolute;
top: 48px;
left: 2px;
}

a.button.attachments-batch-remove {
color: #a00;
border-color: #a00;
}
a.button.attachments-batch-remove:hover{
color: #a00;
border-color: #ff0000;
}
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Attachments gives the ability to append any number of Media Library items to Pages, Posts, and Custom Post Types
* Author: Jonathan Christopher
* Author URI: http://mondaybynoon.com/
* Version: 3.5.9
* Version: 3.5.9.1
* Text Domain: attachments
* Domain Path: /languages/
* License: GPLv2 or later
Expand Down
9 changes: 9 additions & 0 deletions js/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,13 @@ jQuery(document).ready(function($){
}
return false;
});

$('body').on('click','.select-attachment', function showBatchRemoveBtnIfNeeded(e){
//select all selected attachment checkboxes
if( $('.select-attachment:checked').length ){
$('.attachments-batch-remove').show();
}else{
$('.attachments-batch-remove').hide();
}
});
});