Make WordPress Core


Ignore:
Timestamp:
07/21/2009 03:11:12 AM (17 years ago)
Author:
azaozz
Message:

"Trash" status for comments, first run, props caesarsgrunt, see #4529

File:
1 edited

Legend:

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

    r11615 r11731  
    17681768endif;
    17691769
    1770 ?>
     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 */
     1779function _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}
     1794add_action( '_scheduled_destruction', '_scheduled_destruction' );
     1795if ( !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.