Ticket #13502: 13502-ajaxdelete.patch
| File 13502-ajaxdelete.patch, 6.3 KB (added by ocean90, 3 years ago) |
|---|
-
wp-admin/admin-ajax.php
421 421 die('1'); 422 422 die('0'); 423 423 break; 424 case 'delete-attachment' : 424 425 case 'delete-post' : 425 426 check_ajax_referer( "{$action}_$id" ); 426 427 if ( !current_user_can( 'delete_post', $id ) ) … … 434 435 else 435 436 die('0'); 436 437 break; 438 case 'trash-attachment' : 439 case 'untrash-attachment' : 437 440 case 'trash-post' : 438 441 case 'untrash-post' : 439 442 check_ajax_referer( "{$action}_$id" ); -
wp-admin/includes/media.php
1272 1272 } elseif ( !MEDIA_TRASH ) { 1273 1273 $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 1274 1274 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . " 1275 <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button '>" . __( 'Continue' ) . "</a>1275 <a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button continue'>" . __( 'Continue' ) . "</a> 1276 1276 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> 1277 1277 </div>"; 1278 1278 } else { -
wp-includes/js/swfupload/handlers.dev.js
93 93 }); 94 94 95 95 // Bind AJAX to the new Delete button 96 jQuery('a. delete', item).click(function(){96 jQuery('a.continue', item).click(function(){ 97 97 // Tell the server to delete it. TODO: handle exceptions 98 98 jQuery.ajax({ 99 99 url: 'admin-ajax.php', … … 101 101 success: deleteSuccess, 102 102 error: deleteError, 103 103 id: fileObj.id, 104 data:{ 105 id : this.id.replace(/[^0-9]/g,''), 106 action : 'delete-attachment', 107 _ajax_nonce : this.href.replace(/^.*wpnonce=/,'') 108 } 109 }); 110 111 return false; 112 }); 113 114 // Bind AJAX to the new Trash button 115 jQuery('a.delete', item).click(function(){ 116 117 // Tell the server to trash it. TODO: handle exceptions 118 jQuery.ajax({ 119 url: 'admin-ajax.php', 120 type: 'post', 121 success: trashSuccess, 122 error: trashError, 123 id: fileObj.id, 104 124 data: { 105 125 id : this.id.replace(/[^0-9]/g, ''), 106 action : 'trash- post',126 action : 'trash-attachment', 107 127 _ajax_nonce : this.href.replace(/^.*wpnonce=/,'') 108 128 } 109 129 }); … … 119 139 id: fileObj.id, 120 140 data: { 121 141 id : this.id.replace(/[^0-9]/g,''), 122 action: 'untrash- post',142 action: 'untrash-attachment', 123 143 _ajax_nonce: this.href.replace(/^.*wpnonce=/,'') 124 144 }, 125 145 success: function(data, textStatus){ … … 176 196 } 177 197 178 198 // Vanish it. 199 jQuery('.filename:empty', item).remove(); 200 jQuery('.filename .title', item).css('font-weight','bold'); 201 jQuery('.filename', item).append(' <span class="deletednotice">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove(); 202 jQuery('#media-item-' + this.id).children('.describe').css({backgroundColor:'#fff'}).end() 203 .animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:50}) 204 .animate({minHeight:0,height:36}, 400, null, function(){jQuery(this).children('.describe').remove()}) 205 .animate({backgroundColor:'#fff'}, 400) 206 .animate({height:0}, 800, null, function(){ 207 jQuery(this).remove(); 208 updateMediaForm(); 209 }); 210 211 return; 212 } 213 214 function trashSuccess(data, textStatus) { 215 if ( data == '-1' ) 216 return itemAjaxError(this.id, 'You do not have permission. Has your session expired?'); 217 if ( data == '0' ) 218 return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?'); 219 220 var id = this.id, item = jQuery('#media-item-' + id); 221 222 // Decrement the counters. 223 if ( type = jQuery('#type-of-' + id).val() ) 224 jQuery('#' + type + '-counter').text( jQuery('#' + type + '-counter').text() - 1 ); 225 if ( item.hasClass('child-of-'+post_id) ) 226 jQuery('#attachments-count').text( jQuery('#attachments-count').text() - 1 ); 227 228 if ( jQuery('form.type-form #media-items').children().length == 1 && jQuery('.hidden', '#media-items').length > 0 ) { 229 jQuery('.toggle').toggle(); 230 jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden'); 231 } 232 233 // Vanish it. 179 234 jQuery('.toggle', item).toggle(); 180 235 jQuery('.slidetoggle', item).slideUp(200).siblings().removeClass('hidden'); 181 236 item.css( {backgroundColor:'#faa'} ).animate( {backgroundColor:'#f4f4f4'}, {queue:false, duration:500} ).addClass('undo'); 182 237 183 238 jQuery('.filename:empty', item).remove(); 184 239 jQuery('.filename .title', item).css('font-weight','bold'); 185 jQuery('.filename', item).append('<span class="trashnotice"> ' + swfuploadL10n. deleted + ' </span>').siblings('a.toggle').hide();240 jQuery('.filename', item).append('<span class="trashnotice"> ' + swfuploadL10n.trashed + ' </span>').siblings('a.toggle').hide(); 186 241 jQuery('.filename', item).append( jQuery('a.undo', item).removeClass('hidden') ); 187 242 jQuery('.menu_order_input', item).hide(); 188 243 … … 193 248 // TODO 194 249 } 195 250 251 function trashError(X, textStatus, errorThrown) { 252 // TODO 253 } 254 196 255 function updateMediaForm() { 197 256 var one = jQuery('form.type-form #media-items').children(), items = jQuery('#media-items').children(); 198 257 -
wp-includes/script-loader.php
211 211 'upload_stopped' => __('Upload stopped.'), 212 212 'dismiss' => __('Dismiss'), 213 213 'crunching' => __('Crunching…'), 214 'deleted' => __('moved to the trash.'), 214 'deleted' => __('deleted.'), 215 'trashed' => __('moved to the trash.'), 215 216 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};', 216 217 'error_uploading' => __('“%s” has failed to upload due to an error') 217 218 ) );
