Changeset 34129
- Timestamp:
- 09/14/2015 09:39:46 PM (9 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/comment.php
r34042 r34129 279 279 break; 280 280 case 'approvecomment' : 281 wp_set_comment_status( $comment _id, 'approve' );281 wp_set_comment_status( $comment, 'approve' ); 282 282 $redir = add_query_arg( array( 'approved' => 1 ), $redir ); 283 283 break; 284 284 case 'unapprovecomment' : 285 wp_set_comment_status( $comment _id, 'hold' );285 wp_set_comment_status( $comment, 'hold' ); 286 286 $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); 287 287 break; -
trunk/src/wp-admin/includes/ajax-actions.php
r34074 r34129 521 521 522 522 check_ajax_referer( "delete-comment_$id" ); 523 $status = wp_get_comment_status( $comment ->comment_ID);523 $status = wp_get_comment_status( $comment ); 524 524 525 525 $delta = -1; … … 731 731 wp_die( -1 ); 732 732 733 $current = wp_get_comment_status( $comment ->comment_ID);733 $current = wp_get_comment_status( $comment ); 734 734 if ( isset( $_POST['new'] ) && $_POST['new'] == $current ) 735 735 wp_die( time() ); 736 736 737 737 check_ajax_referer( "approve-comment_$id" ); 738 if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) 739 $result = wp_set_comment_status( $comment->comment_ID, 'approve', true ); 740 else 741 $result = wp_set_comment_status( $comment->comment_ID, 'hold', true ); 738 if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { 739 $result = wp_set_comment_status( $comment, 'approve', true ); 740 } else { 741 $result = wp_set_comment_status( $comment, 'hold', true ); 742 } 742 743 743 744 if ( is_wp_error($result) ) { … … 1016 1017 } 1017 1018 1018 if ( wp_set_comment_status( $parent ->comment_ID, 'approve' ) )1019 if ( wp_set_comment_status( $parent, 'approve' ) ) 1019 1020 $comment_auto_approved = true; 1020 1021 } -
trunk/src/wp-includes/comment-functions.php
r34106 r34129 970 970 * @global wpdb $wpdb WordPress database abstraction object. 971 971 * 972 * @param int $comment_id Comment ID973 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false.972 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. 973 * @param bool $force_delete Whether to bypass trash and force deletion. Default is false. 974 974 * @return bool True on success, false on failure. 975 975 */ … … 979 979 return false; 980 980 981 if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment_id), array( 'trash', 'spam' ) ) )981 if ( !$force_delete && EMPTY_TRASH_DAYS && !in_array( wp_get_comment_status( $comment ), array( 'trash', 'spam' ) ) ) 982 982 return wp_trash_comment($comment_id); 983 983 … … 989 989 * @param int $comment_id The comment ID. 990 990 */ 991 do_action( 'delete_comment', $comment _id);991 do_action( 'delete_comment', $comment->comment_ID ); 992 992 993 993 // Move children up a level. 994 $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment _id) );994 $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment->comment_ID) ); 995 995 if ( !empty($children) ) { 996 $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment _id));996 $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment->comment_ID)); 997 997 clean_comment_cache($children); 998 998 } 999 999 1000 1000 // Delete metadata 1001 $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment _id) );1001 $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d", $comment->comment_ID ) ); 1002 1002 foreach ( $meta_ids as $mid ) 1003 1003 delete_metadata_by_mid( 'comment', $mid ); 1004 1004 1005 if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment _id) ) )1005 if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) ) 1006 1006 return false; 1007 1007 … … 1013 1013 * @param int $comment_id The comment ID. 1014 1014 */ 1015 do_action( 'deleted_comment', $comment _id);1015 do_action( 'deleted_comment', $comment->comment_ID ); 1016 1016 1017 1017 $post_id = $comment->comment_post_ID; … … 1019 1019 wp_update_comment_count($post_id); 1020 1020 1021 clean_comment_cache( $comment_id);1021 clean_comment_cache( $comment->comment_ID ); 1022 1022 1023 1023 /** This action is documented in wp-includes/comment-functions.php */ 1024 do_action( 'wp_set_comment_status', $comment _id, 'delete' );1024 do_action( 'wp_set_comment_status', $comment->comment_ID, 'delete' ); 1025 1025 1026 1026 wp_transition_comment_status('delete', $comment->comment_approved, $comment); … … 1035 1035 * @since 2.9.0 1036 1036 * 1037 * @param int $comment_id Comment ID.1037 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. 1038 1038 * @return bool True on success, false on failure. 1039 1039 */ … … 1052 1052 * @param int $comment_id The comment ID. 1053 1053 */ 1054 do_action( 'trash_comment', $comment _id);1055 1056 if ( wp_set_comment_status( $comment_id, 'trash') ) {1057 delete_comment_meta( $comment _id, '_wp_trash_meta_status' );1058 delete_comment_meta( $comment _id, '_wp_trash_meta_time' );1059 add_comment_meta( $comment _id, '_wp_trash_meta_status', $comment->comment_approved );1060 add_comment_meta( $comment _id, '_wp_trash_meta_time', time() );1054 do_action( 'trash_comment', $comment->comment_ID ); 1055 1056 if ( wp_set_comment_status( $comment, 'trash' ) ) { 1057 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); 1058 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); 1059 add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved ); 1060 add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() ); 1061 1061 1062 1062 /** … … 1067 1067 * @param int $comment_id The comment ID. 1068 1068 */ 1069 do_action( 'trashed_comment', $comment _id);1069 do_action( 'trashed_comment', $comment->comment_ID ); 1070 1070 return true; 1071 1071 } … … 1076 1076 /** 1077 1077 * Removes a comment from the Trash 1078 * 1079 * @since 2.9.0 1080 * 1081 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. 1082 * @return bool True on success, false on failure. 1083 */ 1084 function wp_untrash_comment($comment_id) { 1085 $comment = get_comment( $comment_id ); 1086 if ( ! $comment ) { 1087 return false; 1088 } 1089 1090 /** 1091 * Fires immediately before a comment is restored from the Trash. 1092 * 1093 * @since 2.9.0 1094 * 1095 * @param int $comment_id The comment ID. 1096 */ 1097 do_action( 'untrash_comment', $comment->comment_ID ); 1098 1099 $status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true ); 1100 if ( empty($status) ) 1101 $status = '0'; 1102 1103 if ( wp_set_comment_status( $comment, $status ) ) { 1104 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); 1105 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); 1106 /** 1107 * Fires immediately after a comment is restored from the Trash. 1108 * 1109 * @since 2.9.0 1110 * 1111 * @param int $comment_id The comment ID. 1112 */ 1113 do_action( 'untrashed_comment', $comment->comment_ID ); 1114 return true; 1115 } 1116 1117 return false; 1118 } 1119 1120 /** 1121 * Marks a comment as Spam 1122 * 1123 * @since 2.9.0 1124 * 1125 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. 1126 * @return bool True on success, false on failure. 1127 */ 1128 function wp_spam_comment( $comment_id ) { 1129 $comment = get_comment( $comment_id ); 1130 if ( ! $comment ) { 1131 return false; 1132 } 1133 1134 /** 1135 * Fires immediately before a comment is marked as Spam. 1136 * 1137 * @since 2.9.0 1138 * 1139 * @param int $comment_id The comment ID. 1140 */ 1141 do_action( 'spam_comment', $comment->comment_ID ); 1142 1143 if ( wp_set_comment_status( $comment, 'spam' ) ) { 1144 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' ); 1145 delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' ); 1146 add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved ); 1147 add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() ); 1148 /** 1149 * Fires immediately after a comment is marked as Spam. 1150 * 1151 * @since 2.9.0 1152 * 1153 * @param int $comment_id The comment ID. 1154 */ 1155 do_action( 'spammed_comment', $comment->comment_ID ); 1156 return true; 1157 } 1158 1159 return false; 1160 } 1161 1162 /** 1163 * Removes a comment from the Spam 1078 1164 * 1079 1165 * @since 2.9.0 … … 1082 1168 * @return bool True on success, false on failure. 1083 1169 */ 1084 function wp_un trash_comment($comment_id) {1170 function wp_unspam_comment($comment_id) { 1085 1171 if ( ! (int)$comment_id ) 1086 1172 return false; 1087 1173 1088 /** 1089 * Fires immediately before a comment is restored from the Trash. 1174 $comment = get_comment( $comment_id ); 1175 if ( ! $comment ) { 1176 return false; 1177 } 1178 1179 /** 1180 * Fires immediately before a comment is unmarked as Spam. 1090 1181 * 1091 1182 * @since 2.9.0 … … 1093 1184 * @param int $comment_id The comment ID. 1094 1185 */ 1095 do_action( 'un trash_comment', $comment_id );1186 do_action( 'unspam_comment', $comment_id ); 1096 1187 1097 1188 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); … … 1099 1190 $status = '0'; 1100 1191 1101 if ( wp_set_comment_status($comment_id, $status) ) { 1102 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 1103 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1104 /** 1105 * Fires immediately after a comment is restored from the Trash. 1106 * 1107 * @since 2.9.0 1108 * 1109 * @param int $comment_id The comment ID. 1110 */ 1111 do_action( 'untrashed_comment', $comment_id ); 1112 return true; 1113 } 1114 1115 return false; 1116 } 1117 1118 /** 1119 * Marks a comment as Spam 1120 * 1121 * @since 2.9.0 1122 * 1123 * @param int $comment_id Comment ID. 1124 * @return bool True on success, false on failure. 1125 */ 1126 function wp_spam_comment($comment_id) { 1127 if ( !$comment = get_comment($comment_id) ) 1128 return false; 1129 1130 /** 1131 * Fires immediately before a comment is marked as Spam. 1132 * 1133 * @since 2.9.0 1134 * 1135 * @param int $comment_id The comment ID. 1136 */ 1137 do_action( 'spam_comment', $comment_id ); 1138 1139 if ( wp_set_comment_status($comment_id, 'spam') ) { 1140 delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); 1141 delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); 1142 add_comment_meta( $comment_id, '_wp_trash_meta_status', $comment->comment_approved ); 1143 add_comment_meta( $comment_id, '_wp_trash_meta_time', time() ); 1144 /** 1145 * Fires immediately after a comment is marked as Spam. 1146 * 1147 * @since 2.9.0 1148 * 1149 * @param int $comment_id The comment ID. 1150 */ 1151 do_action( 'spammed_comment', $comment_id ); 1152 return true; 1153 } 1154 1155 return false; 1156 } 1157 1158 /** 1159 * Removes a comment from the Spam 1160 * 1161 * @since 2.9.0 1162 * 1163 * @param int $comment_id Comment ID. 1164 * @return bool True on success, false on failure. 1165 */ 1166 function wp_unspam_comment($comment_id) { 1167 if ( ! (int)$comment_id ) 1168 return false; 1169 1170 /** 1171 * Fires immediately before a comment is unmarked as Spam. 1172 * 1173 * @since 2.9.0 1174 * 1175 * @param int $comment_id The comment ID. 1176 */ 1177 do_action( 'unspam_comment', $comment_id ); 1178 1179 $status = (string) get_comment_meta($comment_id, '_wp_trash_meta_status', true); 1180 if ( empty($status) ) 1181 $status = '0'; 1182 1183 if ( wp_set_comment_status($comment_id, $status) ) { 1192 if ( wp_set_comment_status( $comment, $status ) ) { 1184 1193 delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); 1185 1194 delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); … … 1676 1685 * global wpdb $wpdb 1677 1686 * 1678 * @param int $comment_id Comment ID.1679 * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'.1680 * @param bool $wp_errorWhether to return a WP_Error object if there is a failure. Default is false.1687 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. 1688 * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'trash'. 1689 * @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false. 1681 1690 * @return bool|WP_Error True on success, false or WP_Error on failure. 1682 1691 */ … … 1708 1717 $comment_old = clone get_comment($comment_id); 1709 1718 1710 if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_id) ) ) {1719 if ( !$wpdb->update( $wpdb->comments, array('comment_approved' => $status), array( 'comment_ID' => $comment_old->comment_ID ) ) ) { 1711 1720 if ( $wp_error ) 1712 1721 return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); … … 1715 1724 } 1716 1725 1717 clean_comment_cache( $comment_id);1718 1719 $comment = get_comment( $comment_id);1726 clean_comment_cache( $comment_old->comment_ID ); 1727 1728 $comment = get_comment( $comment_old->comment_ID ); 1720 1729 1721 1730 /** … … 1729 1738 * 'hold', 'approve', 'spam', 'trash', or false. 1730 1739 */ 1731 do_action( 'wp_set_comment_status', $comment _id, $comment_status );1740 do_action( 'wp_set_comment_status', $comment->comment_ID, $comment_status ); 1732 1741 1733 1742 wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment); … … 2317 2326 */ 2318 2327 function clean_comment_cache($ids) { 2319 foreach ( (array) $ids as $id ) 2320 wp_cache_delete($id, 'comment'); 2328 foreach ( (array) $ids as $id ) { 2329 wp_cache_delete( $id, 'comment' ); 2330 wp_cache_delete( "comment-{$id}", 'counts' ); 2331 } 2321 2332 2322 2333 wp_cache_set( 'last_changed', microtime(), 'comment' ); -
trunk/src/wp-includes/functions.php
r34104 r34129 4266 4266 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 4267 4267 } else { 4268 wp_delete_comment( $comment_id);4268 wp_delete_comment( $del_comment ); 4269 4269 } 4270 4270 } -
trunk/src/wp-includes/pluggable.php
r34125 r34129 1354 1354 * @since 1.0.0 1355 1355 * 1356 * @param int $comment_id Comment ID1357 * @param string $deprecated Not used1356 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. 1357 * @param string $deprecated Not used 1358 1358 * @return bool True on completion. False if no email addresses were specified. 1359 1359 */ … … 1387 1387 * @param int $comment_id The comment ID. 1388 1388 */ 1389 $emails = apply_filters( 'comment_notification_recipients', $emails, $comment _id);1389 $emails = apply_filters( 'comment_notification_recipients', $emails, $comment->comment_ID ); 1390 1390 $emails = array_filter( $emails ); 1391 1391 … … 1410 1410 * @param int $comment_id The comment ID. 1411 1411 */ 1412 $notify_author = apply_filters( 'comment_notification_notify_author', false, $comment _id);1412 $notify_author = apply_filters( 'comment_notification_notify_author', false, $comment->comment_ID ); 1413 1413 1414 1414 // The comment was left by the author … … 1476 1476 $notify_message .= sprintf( __('Permalink: %s'), get_comment_link( $comment ) ) . "\r\n"; 1477 1477 1478 if ( user_can( $post->post_author, 'edit_comment', $comment_id ) ) { 1479 if ( EMPTY_TRASH_DAYS ) 1480 $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c=$comment_id") ) . "\r\n"; 1481 else 1482 $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c=$comment_id") ) . "\r\n"; 1483 $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c=$comment_id") ) . "\r\n"; 1478 if ( user_can( $post->post_author, 'edit_comment', $comment->comment_ID ) ) { 1479 if ( EMPTY_TRASH_DAYS ) { 1480 $notify_message .= sprintf( __('Trash it: %s'), admin_url("comment.php?action=trash&c={$comment->comment_ID}") ) . "\r\n"; 1481 } else { 1482 $notify_message .= sprintf( __('Delete it: %s'), admin_url("comment.php?action=delete&c={$comment->comment_ID}") ) . "\r\n"; 1483 } 1484 $notify_message .= sprintf( __('Spam it: %s'), admin_url("comment.php?action=spam&c={$comment->comment_ID}") ) . "\r\n"; 1484 1485 } 1485 1486 … … 1510 1511 * @param int $comment_id Comment ID. 1511 1512 */ 1512 $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment _id);1513 $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment->comment_ID ); 1513 1514 1514 1515 /** … … 1520 1521 * @param int $comment_id Comment ID. 1521 1522 */ 1522 $subject = apply_filters( 'comment_notification_subject', $subject, $comment _id);1523 $subject = apply_filters( 'comment_notification_subject', $subject, $comment->comment_ID ); 1523 1524 1524 1525 /** … … 1530 1531 * @param int $comment_id Comment ID. 1531 1532 */ 1532 $message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment _id);1533 $message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment->comment_ID ); 1533 1534 1534 1535 foreach ( $emails as $email ) {
Note: See TracChangeset
for help on using the changeset viewer.