WordPress.org

Make WordPress Core

Changeset 11741


Ignore:
Timestamp:
07/24/2009 07:23:11 AM (9 years ago)
Author:
azaozz
Message:

"Trash" status for comments updates, props caesarsgrunt, see #4529

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/edit-comments.php

    r11731 r11741  
    251251<option value="unapprove"><?php _e('Unapprove'); ?></option>
    252252<?php endif; ?>
    253 <?php if ( 'approved' != $comment_status ): ?>
     253<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
    254254<option value="approve"><?php _e('Approve'); ?></option>
    255255<?php endif; ?>
    256 <?php if ( 'spam' != $comment_status ): ?>
     256<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
    257257<option value="markspam"><?php _e('Mark as Spam'); ?></option>
     258<?php endif; ?>
     259<?php if ( 'deleted' == $comment_status ): ?>
     260<option value="unapprove"><?php _e('Return to Pending'); ?></option>
    258261<?php endif; ?>
    259262<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
    260263<option value="destroy"><?php _e('Delete Permanently'); ?></option>
    261264<?php else: ?>
    262 <option value="delete"><?php _e('Delete'); ?></option>
     265<option value="delete"><?php _e('Move to Trash'); ?></option>
    263266<?php endif; ?>
    264267</select>
     
    287290<?php }
    288291
    289 if ( 'spam' == $comment_status || 'deleted' == $comment_status ) {
     292if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) {
    290293    wp_nonce_field('bulk-destroy', '_destroy_nonce');
    291         if ( current_user_can ('moderate_comments')) { ?>
     294    if ( 'spam' == $comment_status ) { ?>
    292295        <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
     296<?php } elseif ( 'deleted' == $comment_status ) { ?>
     297        <input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-primary apply" />
    293298<?php }
    294299} ?>
     
    342347<option value="unapprove"><?php _e('Unapprove'); ?></option>
    343348<?php endif; ?>
    344 <?php if ( 'approved' != $comment_status ): ?>
     349<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
    345350<option value="approve"><?php _e('Approve'); ?></option>
    346351<?php endif; ?>
    347 <?php if ( 'spam' != $comment_status ): ?>
     352<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
    348353<option value="markspam"><?php _e('Mark as Spam'); ?></option>
     354<?php endif; ?>
     355<?php if ( 'deleted' == $comment_status ): ?>
     356<option value="unapprove"><?php _e('Return to Pending'); ?></option>
    349357<?php endif; ?>
    350358<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
    351359<option value="destroy"><?php _e('Delete Permanently'); ?></option>
    352360<?php else: ?>
    353 <option value="delete"><?php _e('Delete'); ?></option>
     361<option value="delete"><?php _e('Move to Trash'); ?></option>
    354362<?php endif; ?>
    355363</select>
    356364<input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
    357365
    358 <?php if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { ?>
    359 <input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
     366<?php if ( 'spam' == $comment_status ) { ?>
     367<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Quarantine'); ?>" class="button-secondary apply" />
     368<?php } elseif ( 'deleted' == $comment_status ) { ?>
     369<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
    360370<?php } ?>
    361371<?php do_action('manage_comments_nav', $comment_status); ?>
  • trunk/wp-admin/includes/dashboard.php

    r11708 r11741  
    540540        $actions['unapprove'] = "<a href='$unapprove_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved vim-u' title='" . __( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>';
    541541        $actions['edit'] = "<a href='comment.php?action=editcomment&amp;c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
    542         //$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick&nbsp;Edit') . '</a>';
    543542        $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>';
    544543        $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>';
    545         $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</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>';
    546545
    547546        $actions = apply_filters( 'comment_row_actions', $actions, $comment );
  • trunk/wp-admin/includes/template.php

    r11731 r11741  
    21602160                        } else {
    21612161                            $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>';
    2162                             $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
     2162                            $actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';
    21632163                        }
    21642164
  • trunk/wp-includes/comment.php

    r11734 r11741  
    744744    do_action('delete_comment', $comment_id);
    745745   
    746     wp_unschedule_comment_destruction($comment_id);
     746    wp_unschedule_comment_delete($comment_id);
    747747
    748748    $comment = get_comment($comment_id);
     
    10381038function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
    10391039    global $wpdb;
    1040     wp_unschedule_comment_destruction($comment_id);
     1040    wp_unschedule_comment_delete($comment_id);
    10411041   
    10421042    $status = '0';
     
    10591059                return wp_delete_comment($comment_id);
    10601060            $status = 'deleted';
    1061             wp_schedule_comment_destruction($comment_id);
     1061            wp_schedule_comment_delete($comment_id);
    10621062            break;
    10631063        default:
     
    10921092 * @return void
    10931093 */
    1094 function wp_schedule_comment_destruction($comment_id) {
    1095     $to_destroy = get_option('to_destroy');
    1096     if (!is_array($to_destroy))
    1097         $to_destroy = array();
     1094function wp_schedule_comment_delete($comment_id) {
     1095    $to_delete = get_option('wp_scheduled_delete');
     1096    if ( !is_array($to_delete) )
     1097        $to_delete = array();
    10981098   
    1099     $to_destroy['comments'][$comment_id] = time();
     1099    $to_delete['comments'][$comment_id] = time();
    11001100   
    1101     update_option('to_destroy', $to_destroy);
     1101    update_option('wp_scheduled_delete', $to_delete);
    11021102}
    11031103
     
    11101110 * @return void
    11111111 */
    1112 function wp_unschedule_comment_destruction($comment_id) {
    1113     $to_destroy = get_option('to_destroy');
    1114     if (!is_array($to_destroy))
     1112function wp_unschedule_comment_delete($comment_id) {
     1113    $to_delete = get_option('wp_scheduled_delete');
     1114    if ( !is_array($to_delete) )
    11151115        return;
    11161116   
    1117     unset($to_destroy['comments'][$comment_id]);
     1117    unset($to_delete['comments'][$comment_id]);
    11181118   
    1119     update_option('to_destroy', $to_destroy);
     1119    update_option('wp_scheduled_delete', $to_delete);
    11201120}
    11211121
  • trunk/wp-includes/cron.php

    r10969 r11741  
    395395}
    396396
    397 ?>
     397add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
     398if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )
     399    wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
  • trunk/wp-includes/functions.php

    r11736 r11741  
    33293329}
    33303330
    3331 
    3332 
    33333331/**
    33343332 * Strip close comment and close php tags from file headers used by WP
     
    33403338    return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
    33413339}
    3342 ?>
     3340
     3341/**
     3342 * Permanently deletes comments that have been scheduled for deleting.
     3343 * Will do the same for posts, pages, etc in the future.
     3344 *
     3345 * @access private
     3346 * @since 2.9.0
     3347 *
     3348 * @return void
     3349 */
     3350function wp_scheduled_delete() {
     3351    $to_delete = get_option('wp_scheduled_delete');
     3352    if (!is_array($to_delete))
     3353        return;
     3354
     3355    if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) )
     3356        $to_delete['comments'] = array();
     3357
     3358    $delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30);
     3359    $deletetimestamp = time() - $delete_delay;
     3360    foreach ($to_delete['comments'] as $comment_id => $timestamp) {
     3361        if ($timestamp < $deletetimestamp) {
     3362            wp_delete_comment($comment_id);
     3363            unset($to_delete['comments'][$comment_id]);
     3364        }
     3365    }
     3366
     3367    update_option('wp_scheduled_delete', $to_delete);
     3368}
  • trunk/wp-includes/pluggable.php

    r11731 r11741  
    17681768endif;
    17691769
    1770 /**
    1771  * Destroys comments which have previously been scheduled for destruction.
    1772  * Will do the same for posts, pages, etc in the future.
    1773  *
    1774  * @access private
    1775  * @since 2.9.0
    1776  *
    1777  * @return void
    1778  */
    1779 function _scheduled_destruction() {
    1780     $to_destroy = get_option('to_destroy');
    1781     if (!is_array($to_destroy))
    1782         return;
    1783 
    1784     $deletetimestamp = time()-(60*60*24*30);
    1785     foreach ($to_destroy['comments'] as $comment_id => $timestamp) {
    1786         if ($timestamp < $deletetimestamp) {
    1787             wp_delete_comment($comment_id);
    1788             unset($to_destroy['comments'][$comment_id]);
    1789         }
    1790     }
    1791 
    1792     update_option('to_destroy', $to_destroy);
    1793 }
    1794 add_action( '_scheduled_destruction', '_scheduled_destruction' );
    1795 if ( !wp_next_scheduled('_scheduled_destruction') && !defined('WP_INSTALLING') )
    1796     wp_schedule_event(time(), 'daily', '_scheduled_destruction');
    1797 
    1798 
Note: See TracChangeset for help on using the changeset viewer.