Ticket #4529: comment-trash-undo.diff
| File comment-trash-undo.diff, 12.7 KB (added by caesarsgrunt, 3 years ago) |
|---|
-
wp-includes/js/wp-lists.dev.js
1 1 (function($) { 2 var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, wpList ;2 var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, wpList, noticetimer; 3 3 4 4 wpList = { 5 5 settings: { … … 121 121 122 122 s.element = cls[2] || s.element || null; 123 123 if ( cls[3] ) { s.delColor = '#' + cls[3]; } 124 else if ($(s.target).parents('span.undo').size() || $(s.target).parents('span.untrash').size()) { s.delColor = '#339900'; } 124 125 else { s.delColor = s.delColor || '#FF3333'; } 125 126 126 127 if ( !s || !s.element ) { return false; } … … 146 147 anim = 'slideUp'; 147 148 if ( element.css( 'display' ).match(/table/) ) 148 149 anim = 'fadeOut'; // Can't slideup table rows and other table elements. Known jQuery bug 149 element 150 .animate( { backgroundColor: s.delColor }, 'fast' )[anim]( 'fast' ) 151 .queue( function() { list.wpList.recolor(); $(this).dequeue(); } ); 150 element.animate( { backgroundColor: s.delColor }, 'fast' ); 151 152 if ($(s.target).parents('span.trash').size() && s.data.untrash_nonce) { 153 $('#trashnoticerow').hide().insertAfter(element); 154 element.queue(function() { 155 $('#trashnoticerow').show(); 156 $(this).hide(); 157 list.wpList.recolor(); 158 $(this).dequeue(); 159 }); 160 $('#trashnoticerow').css({backgroundColor:s.delColor}).animate({backgroundColor:'#ffffff'}, 'slow'); 161 $('#trashnoticerow a:first').attr('href','comment.php?action=untrashcomment&c='+s.data.id+'&_wpnonce='+s.data.untrash_nonce); 162 $('#trashnoticerow a:first').attr('class','delete:the-comment-list:comment-'+s.data.id+'::undo=1&untrash=1 vim-t vim-destructive'); 163 $('#trashnoticerow a:first').click(function() { $(this).unbind('click'); return list.wpList.del(this); }); 164 if (element.is('.unapproved')) $('#trashnoticerow span:first').addClass('unapprove').removeClass('approve'); 165 else $('#trashnoticerow span:first').addClass('approve').removeClass('unapprove'); 166 clearTimeout(noticetimer); 167 noticetimer = setTimeout(function() {$('#trashnoticerow')[anim]('slow')}, 30000); 168 } 169 else if ($(s.target).parents('span.undo').size() && s.data.undo) { 170 $('#trashnoticerow').animate({backgroundColor:s.delColor}, 'fast'); 171 $('#trashnoticerow').prev().css({backgroundColor:s.delColor}) 172 $('#trashnoticerow').queue(function() { 173 var bg = $(this).prev().is('.unapproved') ? '#ffffe0' : $(this).prev().is('.alt') ? '#f9f9f9' : '#ffffff'; 174 $(this).prev().show().animate({backgroundColor:bg}, 'slow'); 175 $(this).hide(); 176 list.wpList.recolor(); 177 $(this).dequeue(); 178 }); 179 clearTimeout(noticetimer); 180 } 181 else element[anim]('fast').queue(function() { list.wpList.recolor(); $(this).dequeue(); }); 152 182 } else { 153 183 list.wpList.recolor(); 154 184 } -
wp-includes/comment.php
889 889 890 890 //Either set comment_approved to the value in comment_meta or worse case to false which will mean moderation 891 891 $comment['comment_approved'] = get_comment_meta($comment_id, '_wp_trash_meta_status', true); 892 if ($comment['comment_approved'] == false) $comment['comment_approved'] = 0; 892 893 893 894 wp_update_comment($comment); 895 896 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 897 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 894 898 895 899 do_action('untrashed_comment', $comment_id); 896 900 -
wp-admin/edit-comments.php
28 28 } elseif (($_REQUEST['action'] != -1 || $_REQUEST['action2'] != -1) && isset($_REQUEST['delete_comments'])) { 29 29 $comment_ids = $_REQUEST['delete_comments']; 30 30 $doaction = ($_REQUEST['action'] != -1) ? $_REQUEST['action'] : $_REQUEST['action2']; 31 } elseif ($_REQUEST['action'] == 'untrash' && isset($_REQUEST['ids'])) { 32 $comment_ids = explode(',', $_REQUEST['ids']); 33 $doaction = 'untrash'; 31 34 } else wp_redirect($_SERVER['HTTP_REFERER']); 32 35 33 36 $approved = $unapproved = $spammed = $trashed = $untrashed = $deleted = 0; … … 66 69 } 67 70 } 68 71 69 $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&trashed=' . $trashed . '&untrashed=' . $untrashed . '&deleted=' . $deleted ;72 $redirect_to = 'edit-comments.php?approved=' . $approved . '&unapproved=' . $unapproved . '&spam=' . $spammed . '&trashed=' . $trashed . '&untrashed=' . $untrashed . '&deleted=' . $deleted . '&ids=' . join(',', $comment_ids); 70 73 if ( $post_id ) 71 74 $redirect_to = add_query_arg( 'p', absint( $post_id ), $redirect_to ); 72 75 if ( isset($_REQUEST['apage']) ) … … 128 131 echo '<br />'; 129 132 } 130 133 if ( $trashed > 0 ) { 131 printf( _n( '%s comment moved to the trash', '%s comments moved to the trash', $trashed ), $trashed ); 132 echo ' <a href="' . admin_url('edit-comments.php?comment_status=trash') . '">' . __('View trash') . '</a><br />'; 134 printf( _n( '%s comment moved to the trash.', '%s comments moved to the trash.', $trashed ), $trashed ); 135 $ids = isset($_GET['ids']) ? $_GET['ids'] : 0; 136 echo ' <a href="' . esc_url( wp_nonce_url( "edit-comments.php?doaction=undo&action=untrash&ids=$ids", "bulk-comments" ) ) . '">' . __('Undo?') . '</a><br />'; 133 137 } 134 138 if ( $untrashed > 0 ) { 135 139 printf( _n( '%s comment restored from the trash', '%s comments restored from the trash', $untrashed ), $untrashed ); … … 414 418 415 419 <?php 416 420 wp_comment_reply('-1', true, 'detail'); 421 wp_comment_trashnotice('-1', true, 'detail'); 417 422 include('admin-footer.php'); ?> -
wp-admin/includes/dashboard.php
509 509 <?php } 510 510 511 511 wp_comment_reply( -1, false, 'dashboard', false ); 512 wp_comment_trashnotice( -1, false, 'dashboard', false ); 512 513 513 514 else : 514 515 ?> … … 527 528 $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>"; 528 529 $comment_link = '<a class="comment-link" href="' . esc_url(get_comment_link()) . '">#</a>'; 529 530 530 $delete_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) );531 531 $approve_url = esc_url( wp_nonce_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "approve-comment_$comment->comment_ID" ) ); 532 532 $unapprove_url = esc_url( wp_nonce_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "unapprove-comment_$comment->comment_ID" ) ); 533 533 $spam_url = esc_url( wp_nonce_url( "comment.php?action=deletecomment&dt=spam&p=$comment->comment_post_ID&c=$comment->comment_ID", "delete-comment_$comment->comment_ID" ) ); 534 $trash_url = esc_url( wp_nonce_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID", "trash-comment_$comment->comment_ID" ) ); 534 535 535 536 $actions = array(); 536 537 … … 541 542 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; 542 543 $actions['reply'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" title="'.__('Reply to this comment').'" href="#">' . __('Reply') . '</a>'; 543 544 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; 544 $actions[' delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';545 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1&untrash_nonce=".wp_create_nonce("untrash-comment_$comment->comment_ID")." delete vim-t vim-destructive' title='" . __( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; 545 546 546 547 $actions = apply_filters( 'comment_row_actions', $actions, $comment ); 547 548 -
wp-admin/includes/template.php
2173 2173 $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>'; 2174 2174 } else { 2175 2175 $actions['spam'] = "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1 vim-s vim-destructive' title='" . __( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; 2176 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1 delete vim-t vim-destructive'>" . __('Trash') . '</a>';2176 $actions['trash'] = "<a href='$trash_url' class='delete:the-comment-list:comment-$comment->comment_ID::trash=1&untrash_nonce=".wp_create_nonce("untrash-comment_$comment->comment_ID")." delete vim-t vim-destructive' title='" . __( 'Move this comment to the trash' ) . "'>" . _x('Trash', 'verb') . '</a>'; 2177 2177 } 2178 2178 2179 2179 $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>'; … … 2357 2357 /** 2358 2358 * {@internal Missing Short Description}} 2359 2359 * 2360 * @since 2.9.0 2361 * 2362 * @param unknown_type $position 2363 * @param unknown_type $checkbox 2364 * @param unknown_type $mode 2365 */ 2366 function wp_comment_trashnotice($position = '1', $checkbox = false, $mode = 'single', $table_row = true) { 2367 global $current_user; 2368 2369 $columns = get_column_headers('edit-comments'); 2370 $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns('edit-comments') ) ); 2371 $col_count = count($columns) - count($hidden); 2372 2373 if ( $table_row ) : ?> 2374 <table style="display:none;"><tbody id="com-trashnotice"><tr id="trashnoticerow" class="trash"><td colspan="<?php echo $col_count; ?>"> 2375 <?php else : ?> 2376 <div id="com-trashnotice" style="display:none;"><div id="trashnoticerow" class="comment-item trash"><p> 2377 <?php endif; ?> 2378 <?php _e('Comment moved to the trash.') ?> <span class="undo untrash"><a href="/" class=""><?php _e( 'Undo?' ) ?></a></span> 2379 <?php if ( $table_row ) : ?> 2380 </td></tr></tbody></table> 2381 <?php else : ?> 2382 </p></div></div> 2383 <?php endif; 2384 } 2385 2386 /** 2387 * {@internal Missing Short Description}} 2388 * 2360 2389 * @since unknown 2361 2390 * 2362 2391 * @param unknown_type $currentcat -
wp-admin/js/edit-comments.dev.js
68 68 n = a.html().replace(/[ ,.]+/g, ''); 69 69 n = parseInt(n,10); 70 70 if ( isNaN(n) ) return; 71 if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment 71 if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove" 72 n = n + 1; 73 } else if ( $('#' + settings.element).is('.unapproved') ) { // we deleted a formerly unapproved comment 72 74 n = n - 1; 73 } else if ( $(settings.target).parents( 'span.unapprove' ).size() ) { // we "deleted" an approved comment from the approved list by clicking "Unapprove"74 n = n + 1;75 75 } 76 76 if ( n < 0 ) { n = 0; } 77 77 a.parents('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); … … 105 105 if ( isNaN(n) ) return; 106 106 if ( $(settings.target).parents( 'span.trash' ).size() ) { // we trashed a comment 107 107 n = n + 1; 108 } else if ( $(settings.target).parents( 'span.untrash' ).size() ) { // we undid the trashing of a comment 109 n = n - 1; 108 110 } else if ( $('#' + settings.element).is('.trash') ) { // we deleted or untrashed a trash comment 109 111 n = n - 1; 110 112 } -
wp-admin/css/dashboard.dev.css
202 202 border-top: 1px solid; 203 203 } 204 204 205 #the-comment-list #trashnoticerow { 206 padding: 0.25em 10px 0.25em 70px; 207 } 208 205 209 #the-comment-list .pingback { 206 210 padding-left: 9px !important; 207 211 }
