"Trash" status for comments updates, props caesarsgrunt, see #4529
git-svn-id: http://svn.automattic.com/wordpress/trunk@11741 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
174f05ad82
commit
2040971211
|
@ -250,16 +250,19 @@ $page_links = paginate_links( array(
|
|||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Unapprove'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'approved' != $comment_status ): ?>
|
||||
<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
|
||||
<option value="approve"><?php _e('Approve'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'spam' != $comment_status ): ?>
|
||||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
|
||||
<option value="markspam"><?php _e('Mark as Spam'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'deleted' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Return to Pending'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
|
||||
<option value="destroy"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
<option value="delete"><?php _e('Move to Trash'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<input type="submit" name="doaction" id="doaction" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
|
||||
|
@ -286,10 +289,12 @@ $page_links = paginate_links( array(
|
|||
<input type="hidden" name="apage" value="<?php echo esc_attr( absint( $_GET['apage'] ) ); ?>" />
|
||||
<?php }
|
||||
|
||||
if ( 'spam' == $comment_status || 'deleted' == $comment_status ) {
|
||||
if ( ( 'spam' == $comment_status || 'deleted' == $comment_status) && current_user_can ('moderate_comments') ) {
|
||||
wp_nonce_field('bulk-destroy', '_destroy_nonce');
|
||||
if ( current_user_can ('moderate_comments')) { ?>
|
||||
if ( 'spam' == $comment_status ) { ?>
|
||||
<input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
|
||||
<?php } elseif ( 'deleted' == $comment_status ) { ?>
|
||||
<input type="submit" name="destroy_all" id="destroy_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-primary apply" />
|
||||
<?php }
|
||||
} ?>
|
||||
<?php do_action('manage_comments_nav', $comment_status); ?>
|
||||
|
@ -341,22 +346,27 @@ if ( $page_links )
|
|||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Unapprove'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'approved' != $comment_status ): ?>
|
||||
<?php if ( 'all' == $comment_status || 'moderated' == $comment_status || 'spam' == $comment_status ): ?>
|
||||
<option value="approve"><?php _e('Approve'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'spam' != $comment_status ): ?>
|
||||
<?php if ( 'all' == $comment_status || 'approved' == $comment_status || 'moderated' == $comment_status ): ?>
|
||||
<option value="markspam"><?php _e('Mark as Spam'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'deleted' == $comment_status ): ?>
|
||||
<option value="unapprove"><?php _e('Return to Pending'); ?></option>
|
||||
<?php endif; ?>
|
||||
<?php if ( 'deleted' == $comment_status || 'spam' == $comment_status ): ?>
|
||||
<option value="destroy"><?php _e('Delete Permanently'); ?></option>
|
||||
<?php else: ?>
|
||||
<option value="delete"><?php _e('Delete'); ?></option>
|
||||
<option value="delete"><?php _e('Move to Trash'); ?></option>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
<input type="submit" name="doaction2" id="doaction2" value="<?php esc_attr_e('Apply'); ?>" class="button-secondary apply" />
|
||||
|
||||
<?php if ( 'spam' == $comment_status || 'deleted' == $comment_status ) { ?>
|
||||
<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Permanently Delete All'); ?>" class="button-secondary apply" />
|
||||
<?php if ( 'spam' == $comment_status ) { ?>
|
||||
<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Quarantine'); ?>" class="button-secondary apply" />
|
||||
<?php } elseif ( 'deleted' == $comment_status ) { ?>
|
||||
<input type="submit" name="destroy_all2" id="destroy_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
<?php do_action('manage_comments_nav', $comment_status); ?>
|
||||
</div>
|
||||
|
|
|
@ -539,10 +539,9 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {
|
|||
$actions['approve'] = "<a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved vim-a' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>';
|
||||
$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>';
|
||||
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
|
||||
//$actions['quickedit'] = '<a onclick="commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\',\'edit\');return false;" class="vim-q" title="'.__('Quick Edit').'" href="#">' . __('Quick Edit') . '</a>';
|
||||
$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>';
|
||||
$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>';
|
||||
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
|
||||
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';
|
||||
|
||||
$actions = apply_filters( 'comment_row_actions', $actions, $comment );
|
||||
|
||||
|
|
|
@ -2159,7 +2159,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
|
|||
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID::deleted=1 delete vim-d vim-destructive'>" . __('Delete Permanently') . '</a>';
|
||||
} else {
|
||||
$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>';
|
||||
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Delete') . '</a>';
|
||||
$actions['delete'] = "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete vim-d vim-destructive'>" . __('Move to Trash') . '</a>';
|
||||
}
|
||||
|
||||
$actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' title='" . __('Edit comment') . "'>". __('Edit') . '</a>';
|
||||
|
|
|
@ -743,7 +743,7 @@ function wp_delete_comment($comment_id) {
|
|||
global $wpdb;
|
||||
do_action('delete_comment', $comment_id);
|
||||
|
||||
wp_unschedule_comment_destruction($comment_id);
|
||||
wp_unschedule_comment_delete($comment_id);
|
||||
|
||||
$comment = get_comment($comment_id);
|
||||
|
||||
|
@ -1037,7 +1037,7 @@ function wp_new_comment( $commentdata ) {
|
|||
*/
|
||||
function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) {
|
||||
global $wpdb;
|
||||
wp_unschedule_comment_destruction($comment_id);
|
||||
wp_unschedule_comment_delete($comment_id);
|
||||
|
||||
$status = '0';
|
||||
switch ( $comment_status ) {
|
||||
|
@ -1058,7 +1058,7 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
|
|||
if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam')
|
||||
return wp_delete_comment($comment_id);
|
||||
$status = 'deleted';
|
||||
wp_schedule_comment_destruction($comment_id);
|
||||
wp_schedule_comment_delete($comment_id);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
@ -1091,14 +1091,14 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
|
|||
* @param int $comment_id Comment ID.
|
||||
* @return void
|
||||
*/
|
||||
function wp_schedule_comment_destruction($comment_id) {
|
||||
$to_destroy = get_option('to_destroy');
|
||||
if (!is_array($to_destroy))
|
||||
$to_destroy = array();
|
||||
function wp_schedule_comment_delete($comment_id) {
|
||||
$to_delete = get_option('wp_scheduled_delete');
|
||||
if ( !is_array($to_delete) )
|
||||
$to_delete = array();
|
||||
|
||||
$to_destroy['comments'][$comment_id] = time();
|
||||
$to_delete['comments'][$comment_id] = time();
|
||||
|
||||
update_option('to_destroy', $to_destroy);
|
||||
update_option('wp_scheduled_delete', $to_delete);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1109,14 +1109,14 @@ function wp_schedule_comment_destruction($comment_id) {
|
|||
* @param int $comment_id Comment ID.
|
||||
* @return void
|
||||
*/
|
||||
function wp_unschedule_comment_destruction($comment_id) {
|
||||
$to_destroy = get_option('to_destroy');
|
||||
if (!is_array($to_destroy))
|
||||
function wp_unschedule_comment_delete($comment_id) {
|
||||
$to_delete = get_option('wp_scheduled_delete');
|
||||
if ( !is_array($to_delete) )
|
||||
return;
|
||||
|
||||
unset($to_destroy['comments'][$comment_id]);
|
||||
unset($to_delete['comments'][$comment_id]);
|
||||
|
||||
update_option('to_destroy', $to_destroy);
|
||||
update_option('wp_scheduled_delete', $to_delete);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -394,4 +394,6 @@ function check_server_timer( $local_time ) {
|
|||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
add_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
|
||||
if ( !wp_next_scheduled('wp_scheduled_delete') && !defined('WP_INSTALLING') )
|
||||
wp_schedule_event(time(), 'daily', 'wp_scheduled_delete');
|
||||
|
|
|
@ -3328,8 +3328,6 @@ function wp_timezone_choice( $selected_zone ) {
|
|||
return join( "\n", $structure );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Strip close comment and close php tags from file headers used by WP
|
||||
* See http://core.trac.wordpress.org/ticket/8497
|
||||
|
@ -3339,4 +3337,32 @@ function wp_timezone_choice( $selected_zone ) {
|
|||
function _cleanup_header_comment($str) {
|
||||
return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
|
||||
}
|
||||
?>
|
||||
|
||||
/**
|
||||
* Permanently deletes comments that have been scheduled for deleting.
|
||||
* Will do the same for posts, pages, etc in the future.
|
||||
*
|
||||
* @access private
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function wp_scheduled_delete() {
|
||||
$to_delete = get_option('wp_scheduled_delete');
|
||||
if (!is_array($to_delete))
|
||||
return;
|
||||
|
||||
if ( !isset($to_delete['comments']) || !is_array($to_delete['comments']) )
|
||||
$to_delete['comments'] = array();
|
||||
|
||||
$delete_delay = defined('EMPTY_TRASH_TIMEOUT') ? (int) EMPTY_TRASH_TIMEOUT : (60*60*24*30);
|
||||
$deletetimestamp = time() - $delete_delay;
|
||||
foreach ($to_delete['comments'] as $comment_id => $timestamp) {
|
||||
if ($timestamp < $deletetimestamp) {
|
||||
wp_delete_comment($comment_id);
|
||||
unset($to_delete['comments'][$comment_id]);
|
||||
}
|
||||
}
|
||||
|
||||
update_option('wp_scheduled_delete', $to_delete);
|
||||
}
|
||||
|
|
|
@ -1767,32 +1767,3 @@ function wp_text_diff( $left_string, $right_string, $args = null ) {
|
|||
}
|
||||
endif;
|
||||
|
||||
/**
|
||||
* Destroys comments which have previously been scheduled for destruction.
|
||||
* Will do the same for posts, pages, etc in the future.
|
||||
*
|
||||
* @access private
|
||||
* @since 2.9.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _scheduled_destruction() {
|
||||
$to_destroy = get_option('to_destroy');
|
||||
if (!is_array($to_destroy))
|
||||
return;
|
||||
|
||||
$deletetimestamp = time()-(60*60*24*30);
|
||||
foreach ($to_destroy['comments'] as $comment_id => $timestamp) {
|
||||
if ($timestamp < $deletetimestamp) {
|
||||
wp_delete_comment($comment_id);
|
||||
unset($to_destroy['comments'][$comment_id]);
|
||||
}
|
||||
}
|
||||
|
||||
update_option('to_destroy', $to_destroy);
|
||||
}
|
||||
add_action( '_scheduled_destruction', '_scheduled_destruction' );
|
||||
if ( !wp_next_scheduled('_scheduled_destruction') && !defined('WP_INSTALLING') )
|
||||
wp_schedule_event(time(), 'daily', '_scheduled_destruction');
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue