[wp-trac] [WordPress Trac] #4529: "Trash" status for comments and posts

WordPress Trac wp-trac at lists.automattic.com
Sat Jul 11 16:47:41 UTC 2009


#4529: "Trash" status for comments and posts
----------------------------+-----------------------------------------------
 Reporter:  markjaquith     |       Owner:  caesarsgrunt
     Type:  task (blessed)  |      Status:  accepted    
 Priority:  normal          |   Milestone:  2.9         
Component:  Administration  |     Version:              
 Severity:  normal          |    Keywords:  has-patch   
----------------------------+-----------------------------------------------

Comment(by caesarsgrunt):

 Ok, I've got a problem.

 I've basically completed the system for scheduled deletions, and comments
 are scheduled and unscheduled for deletion correctly. It will be very
 simple to extend the system to work with posts, pages, etc.

 But... I can't work out what file to put the actual function which is
 called by the wp-cron into. The code in need of a home is the following :

 {{{
 /**
  * Destroys comments which have previously been scheduled for destruction.
  *
  * @access private
  * @since 2.9.0
  *
  * @return void
  */
 function _scheduled_comment_destruction() {
         $to_destroy = get_option('to_destroy');
         if (!is_array($to_destroy))
                 return;

         foreach ($to_destroy['comments'] as $comment_id => $timestamp) {
                 if ($timestamp < time()) {
                         wp_delete_comment($comment_id);
                         unset($to_destroy['comments'][$comment_id]);
                 }
         }

         update_option('to_destroy', $to_destroy);
 }
 add_action( '_scheduled_comment_destruction',
 '_scheduled_comment_destruction' );
 if ( !wp_next_scheduled('_scheduled_comment_destruction') &&
 !defined('WP_INSTALLING') )
         wp_schedule_event(time(), 'daily',
 '_scheduled_comment_destruction');

 }}}

 And I can't find a file in which the function is actually called by wp-
 cron (ie the file must be loaded whenever wp-cron runs) ''and'' has the
 ability to run the functions wp_next_scheduled() and wp_schedule_event()
 (ie wp-includes/cron.php must be loaded whenever the file in question is
 loaded).

 Can anyone help me? Thanks...

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/4529#comment:39>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list