Ticket #13502: 13502.2.patch
| File 13502.2.patch, 7.9 KB (added by ocean90, 3 years ago) |
|---|
-
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.delete-attachment', 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.trash-attachment', 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 trashed. Has it been trashed 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
234 234 'upload_stopped' => __('Upload stopped.'), 235 235 'dismiss' => __('Dismiss'), 236 236 'crunching' => __('Crunching…'), 237 'deleted' => __('moved to the trash.'), 237 'trashed' => __('moved to the trash.'), 238 'deleted' => __('deleted.'), 238 239 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};', 239 240 'error_uploading' => __('“%s” has failed to upload due to an error') 240 241 ) ); -
wp-admin/admin-ajax.php
389 389 die('1'); 390 390 die('0'); 391 391 break; 392 case 'delete-attachment' : 392 393 case 'delete-post' : 393 394 check_ajax_referer( "{$action}_$id" ); 394 395 if ( !current_user_can( 'delete_post', $id ) ) … … 402 403 else 403 404 die('0'); 404 405 break; 406 case 'trash-attachment' : 407 case 'untrash-attachment' : 405 408 case 'trash-post' : 406 409 case 'untrash-post' : 407 410 check_ajax_referer( "{$action}_$id" ); … … 411 414 if ( !get_post( $id ) ) 412 415 die('1'); 413 416 414 if ( 'trash-post' == $action )417 if ( 'trash-post' == $action || 'trash-attachment' == $action ) 415 418 $done = wp_trash_post( $id ); 416 419 else 417 420 $done = wp_untrash_post( $id ); -
wp-admin/includes/media.php
1225 1225 $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); 1226 1226 if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { 1227 1227 if ( !EMPTY_TRASH_DAYS ) { 1228 $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete '>" . __( 'Delete Permanently' ) . '</a>';1228 $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete delete-attachment'>" . __( 'Delete Permanently' ) . '</a>'; 1229 1229 } elseif ( !MEDIA_TRASH ) { 1230 1230 $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 1231 1231 <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . " 1232 < a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a>1233 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> 1232 <p><a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='button delete-attachment'>" . __( 'Continue' ) . "</a> 1233 <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a></p> 1234 1234 </div>"; 1235 1235 } else { 1236 $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class=' delete'>" . __( 'Move to Trash' ) . "</a>1236 $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='trash-attachment'>" . __( 'Move to Trash' ) . "</a> 1237 1237 <a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-attachment_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; 1238 1238 } 1239 1239 } else {
