Changeset 11731 for trunk/wp-includes/comment.php
- Timestamp:
- 07/21/2009 03:11:12 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/comment.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment.php
r11713 r11731 209 209 elseif ( 'spam' == $status ) 210 210 $approved = "comment_approved = 'spam'"; 211 elseif ( 'deleted' == $status ) 212 $approved = "comment_approved = 'deleted'"; 211 213 else 212 214 $approved = "( comment_approved = '0' OR comment_approved = '1' )"; … … 700 702 701 703 $total = 0; 702 $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam' );704 $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'deleted' => 'deleted'); 703 705 $known_types = array_keys( $approved ); 704 706 foreach( (array) $count as $row_num => $row ) { … … 736 738 */ 737 739 function wp_delete_comment($comment_id) { 740 if (wp_get_comment_status($comment_id) != 'deleted' && wp_get_comment_status($comment_id) != 'spam') 741 return wp_set_comment_status($comment_id, 'delete'); 742 738 743 global $wpdb; 739 744 do_action('delete_comment', $comment_id); 745 746 wp_unschedule_comment_destruction($comment_id); 740 747 741 748 $comment = get_comment($comment_id); … … 785 792 elseif ( $approved == 'spam' ) 786 793 return 'spam'; 794 elseif ( $approved == 'deleted' ) 795 return 'deleted'; 787 796 else 788 797 return false; … … 1029 1038 function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { 1030 1039 global $wpdb; 1031 1040 wp_unschedule_comment_destruction($comment_id); 1041 1032 1042 $status = '0'; 1033 1043 switch ( $comment_status ) { … … 1046 1056 break; 1047 1057 case 'delete': 1048 return wp_delete_comment($comment_id); 1058 if (wp_get_comment_status($comment_id) == 'deleted' || wp_get_comment_status($comment_id) == 'spam') 1059 return wp_delete_comment($comment_id); 1060 $status = 'deleted'; 1061 wp_schedule_comment_destruction($comment_id); 1049 1062 break; 1050 1063 default: … … 1069 1082 1070 1083 return true; 1084 } 1085 1086 /** 1087 * Schedules a comment for destruction in 30 days. 1088 * 1089 * @since 2.9.0 1090 * 1091 * @param int $comment_id Comment ID. 1092 * @return void 1093 */ 1094 function wp_schedule_comment_destruction($comment_id) { 1095 $to_destroy = get_option('to_destroy'); 1096 if (!is_array($to_destroy)) 1097 $to_destroy = array(); 1098 1099 $to_destroy['comments'][$comment_id] = time(); 1100 1101 update_option('to_destroy', $to_destroy); 1102 } 1103 1104 /** 1105 * Unschedules a comment for destruction. 1106 * 1107 * @since 2.9.0 1108 * 1109 * @param int $comment_id Comment ID. 1110 * @return void 1111 */ 1112 function wp_unschedule_comment_destruction($comment_id) { 1113 $to_destroy = get_option('to_destroy'); 1114 if (!is_array($to_destroy)) 1115 return; 1116 1117 unset($to_destroy['comments'][$comment_id]); 1118 1119 update_option('to_destroy', $to_destroy); 1071 1120 } 1072 1121
Note: See TracChangeset
for help on using the changeset viewer.