Ticket #4529: upload-trash-undo.diff
| File upload-trash-undo.diff, 6.6 KB (added by caesarsgrunt, 4 years ago) |
|---|
-
wp-includes/post.php
1250 1250 1251 1251 if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) 1252 1252 return $post; 1253 elseif ($post['post_status'] == 'trash') 1254 return false; 1253 1255 1254 1256 do_action('trash_post', $post_id); 1255 1257 … … 1277 1279 function wp_untrash_post($post_id = 0) { 1278 1280 if ( !$post = wp_get_single_post($post_id, ARRAY_A) ) 1279 1281 return $post; 1282 elseif ($post['post_status'] != 'trash') 1283 return false; 1280 1284 1281 1285 do_action('untrash_post', $post_id); 1282 1286 -
wp-includes/js/swfupload/handlers.dev.js
83 83 }); 84 84 return false; 85 85 }); 86 // Bind AJAX to the new Undo button 87 jQuery('#media-item-' + fileObj.id + ' a.undo').click(function(){ 88 // Tell the server to untrash it. TODO: handle exceptions 89 jQuery.ajax({url:'admin-ajax.php',type:'post',id:fileObj.id,data:{ 90 id : this.id.replace(/[^0-9]/g,''), 91 action : 'untrash-post', 92 _ajax_nonce : this.href.replace(/^.*wpnonce=/,'')}, 93 success:function(data, textStatus){ 94 if ( type = jQuery('#type-of-' + fileObj.id).val() ) 95 jQuery('#' + type + '-counter').text(jQuery('#' + type + '-counter').text()-0+1); 96 if ( jQuery('#media-item-' + fileObj.id).hasClass('child-of-'+post_id) ) 97 jQuery('#attachments-count').text(jQuery('#attachments-count').text()-0+1); 98 99 jQuery('#media-item-' + fileObj.id + ' .filename .trashnotice').remove(); 100 jQuery('#media-item-' + fileObj.id + ' a.undo').addClass('hidden'); 101 jQuery('#media-item-' + fileObj.id + ' .filename').siblings('a.toggle.describe-toggle-on').show(); 102 jQuery('#media-item-' + fileObj.id).animate({backgroundColor:'#fff'}, {queue:false,duration:200,complete:function(){jQuery(this).css({backgroundColor:''})}}); 103 jQuery('#media-item-' + this.id + ' .menu_order_input').show(); 104 } 105 }); 106 return false; 107 }); 86 108 87 109 // Open this item if it says to start open (e.g. to display an error) 88 110 jQuery('#media-item-' + fileObj.id + '.startopen').removeClass('startopen').slideToggle(500).parent().children('.toggle').toggle(); … … 101 123 if ( data == '0' ) 102 124 return itemAjaxError(this.id, 'Could not be deleted. Has it been deleted already?'); 103 125 126 var id = this.id; 104 127 var item = jQuery('#media-item-' + this.id); 105 128 106 129 // Decrement the counters. … … 109 132 if ( item.hasClass('child-of-'+post_id) ) 110 133 jQuery('#attachments-count').text(jQuery('#attachments-count').text()-1); 111 134 112 if ( jQuery('.type-form #media-items>*').length == 1 && jQuery('#media-items .hidden').length > 0 ) { 113 jQuery('.toggle').toggle(); 114 jQuery('.slidetoggle').slideUp(200).siblings().removeClass('hidden'); 115 } 116 117 // Vanish it. 135 jQuery('#media-item-' + this.id + ' .toggle').toggle(); 136 jQuery('#media-item-' + this.id + ' .slidetoggle').slideUp(200).siblings().removeClass('hidden'); 137 jQuery('#media-item-' + this.id).css({backgroundColor:'#fff'}).animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:500}); 118 138 jQuery('#media-item-' + this.id + ' .filename:empty').remove(); 119 jQuery('#media-item-' + this.id + ' .filename').append(' <span class="file-error">'+swfuploadL10n.deleted+'</span>').siblings('a.toggle').remove(); 120 jQuery('#media-item-' + this.id).children('.describe').css({backgroundColor:'#fff'}).end() 121 .animate({backgroundColor:'#ffc0c0'}, {queue:false,duration:50}) 122 .animate({minHeight:0,height:36}, 400, null, function(){jQuery(this).children('.describe').remove()}) 123 .animate({backgroundColor:'#fff'}, 400) 124 .animate({height:0}, 800, null, function(){jQuery(this).remove();updateMediaForm();}); 139 jQuery('#media-item-' + this.id + ' .filename').append('<span class="trashnotice"> '+swfuploadL10n.deleted+' </span>').siblings('a.toggle').hide(); 140 jQuery('#media-item-' + this.id + ' .filename').append(jQuery('#media-item-' + this.id + ' a.undo').removeClass('hidden')); 141 jQuery('#media-item-' + this.id + ' .menu_order_input').hide(); 125 142 126 143 return; 127 144 } -
wp-includes/script-loader.php
204 204 'upload_stopped' => __('Upload stopped.'), 205 205 'dismiss' => __('Dismiss'), 206 206 'crunching' => __('Crunching…'), 207 'deleted' => __(' Moved to Trash'),207 'deleted' => __('moved to the trash.'), 208 208 'l10n_print_after' => 'try{convertEntities(swfuploadL10n);}catch(e){};' 209 209 ) ); 210 210 -
wp-admin/admin-ajax.php
346 346 else 347 347 die('0'); 348 348 break; 349 case 'untrash-post' : 350 check_ajax_referer( "{$action}_$id" ); 351 if ( !current_user_can( 'delete_post', $id ) ) 352 die('-1'); 353 354 if ( !get_post( $id ) ) 355 die('1'); 356 357 if ( wp_untrash_post( $id ) ) 358 die('1'); 359 else 360 die('0'); 361 break; 349 362 case 'delete-page' : 350 363 check_ajax_referer( "{$action}_$id" ); 351 364 if ( !current_user_can( 'delete_page', $id ) ) -
wp-admin/includes/media.php
1203 1203 'extra_rows' => array(), 1204 1204 ); 1205 1205 1206 $delete_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id); 1206 $trash_href = wp_nonce_url("post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id); 1207 $untrash_href = wp_nonce_url("post.php?action=untrash&post=$attachment_id", 'untrash-post_' . $attachment_id); 1207 1208 if ( $send ) 1208 1209 $send = "<input type='submit' class='button' name='send[$attachment_id]' value='" . esc_attr__( 'Insert into Post' ) . "' />"; 1209 1210 if ( $delete ) 1210 $delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$ delete_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a>" : "";1211 $delete = current_user_can('delete_post', $attachment_id) ? "<a href=\"$trash_href\" id=\"del[$attachment_id]\" class=\"delete\">" . __('Move to Trash') . "</a> <a href=\"$untrash_href\" id=\"undo[$attachment_id]\" class=\"undo hidden\">" . __('Undo?') . "</a>" : ""; 1211 1212 if ( 'image' == $type && get_post_image_id($_GET['post_id']) != $attachment_id ) 1212 1213 $thumbnail = "<a class='wp-post-thumbnail' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\");return false;'>" . esc_html__( "Use as thumbnail" ) . "</a>"; 1213 1214
