Make WordPress Core


Ignore:
Timestamp:
07/30/2009 01:39:34 PM (15 years ago)
Author:
azaozz
Message:

Trash status updates for posts, pages, comments and attachments, props caesarsgrunt, see #4529

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions.php

    r11741 r11749  
    33403340
    33413341/**
    3342  * Permanently deletes comments that have been scheduled for deleting.
    3343  * Will do the same for posts, pages, etc in the future.
     3342 * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
    33443343 *
    3345  * @access private
    33463344 * @since 2.9.0
    33473345 *
     
    33493347 */
    33503348function wp_scheduled_delete() {
    3351     $to_delete = get_option('wp_scheduled_delete');
    3352     if (!is_array($to_delete))
     3349    $trash_meta = get_option('wp_trash_meta');
     3350    if ( !is_array($trash_meta) )
    33533351        return;
    33543352
    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]);
     3353    $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
     3354
     3355    foreach ( $trash_meta['comments'] as $id => $meta ) {
     3356        if ( $meta['time'] < $delete_timestamp ) {
     3357            wp_delete_comment($id);
     3358            unset($trash_meta['comments'][$id]);
    33643359        }
    33653360    }
     3361    foreach ( $trash_meta['posts'] as $id => $meta ) {
     3362        if ( $meta['time'] < $delete_timestamp ) {
     3363            wp_delete_post($id);
     3364            unset($to_delete['posts'][$id]);
     3365        }
     3366    }
    33663367
    33673368    update_option('wp_scheduled_delete', $to_delete);
Note: See TracChangeset for help on using the changeset viewer.