Changeset 11945
- Timestamp:
- 09/17/2009 08:51:12 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/template.php
r11930 r11945 2194 2194 $action .= ' hide-if-no-js'; 2195 2195 elseif ($action == 'untrash' && $the_comment_status == 'trash') { 2196 $trash_meta = get_option('wp_trash_meta'); 2197 if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id]['status'])) { 2198 if ($trash_meta['comments'][$comment_id]['status'] == '1') 2199 $action .= ' approve'; 2200 else 2201 $action .= ' unapprove'; 2202 } 2196 if ('1' == get_comment_meta($comment_id, '_wp_trash_meta_status', true)) 2197 $action .= ' approve'; 2198 else 2199 $action .= ' unapprove'; 2203 2200 } 2204 2201 -
trunk/wp-includes/comment.php
r11943 r11945 820 820 do_action('delete_comment', $comment_id); 821 821 822 $trash_meta = get_option('wp_trash_meta'); 823 if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) { 824 unset($trash_meta['comments'][$comment_id]); 825 update_option('wp_trash_meta', $trash_meta); 826 } 822 delete_comment_meta($comment_id,'_wp_trash_meta_status'); 823 delete_comment_meta($comment_id,'_wp_trash_meta_time'); 827 824 828 825 if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) ) … … 866 863 do_action('trash_comment', $comment_id); 867 864 868 $trash_meta = get_option('wp_trash_meta', array()); 869 $trash_meta['comments'][$comment_id]['status'] = $comment->comment_approved; 870 $trash_meta['comments'][$comment_id]['time'] = time(); 871 update_option('wp_trash_meta', $trash_meta); 872 865 add_comment_meta($comment_id,'_wp_trash_meta_status', $comment->comment_approved); 866 add_comment_meta($comment_id,'_wp_trash_meta_time', time() ); 867 873 868 wp_set_comment_status($comment_id, 'trash'); 874 869 … … 892 887 893 888 $comment = array('comment_ID'=>$comment_id, 'comment_approved'=>'0'); 894 895 $trash_meta = get_option('wp_trash_meta'); 896 if (is_array($trash_meta) && isset($trash_meta['comments'][$comment_id])) { 897 $comment['comment_approved'] = $trash_meta['comments'][$comment_id]['status']; 898 unset($trash_meta['comments'][$comment_id]); 899 update_option('wp_trash_meta', $trash_meta); 900 } 889 890 //Either set comment_approved to the value in comment_meta or worse case to false which will mean moderation 891 $comment['comment_approved'] = get_comment_meta($comment_id, '_wp_trash_meta_status', true); 901 892 902 893 wp_update_comment($comment); -
trunk/wp-includes/functions.php
r11930 r11945 3381 3381 } 3382 3382 3383 //Trashed Comments 3384 //TODO Come up with a better store for the comment trash meta. 3385 $trash_meta = get_option('wp_trash_meta'); 3386 if ( !is_array($trash_meta) ) 3387 return; 3388 3389 foreach ( (array) $trash_meta['comments'] as $id => $meta ) { 3390 if ( $meta['time'] < $delete_timestamp ) { 3391 wp_delete_comment($id); 3392 unset($trash_meta['comments'][$id]); 3393 } 3394 } 3395 3396 update_option('wp_trash_meta', $trash_meta); 3383 $comments_to_delete = $wpdb->get_results($wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A); 3384 3385 foreach ( (array) $comments_to_delete as $comment ) { 3386 wp_delete_comment($comment['comment_id']); 3387 } 3397 3388 } 3398 3389 ?>
Note: See TracChangeset
for help on using the changeset viewer.