Make WordPress Core


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.