Changeset 10681
- Timestamp:
- 03/02/2009 09:48:37 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r10641 r10681 315 315 break; 316 316 case 'dim-comment' : // On success, die with time() instead of 1 317 if ( !$comment = get_comment( $id ) ) 318 die('0'); 317 318 if ( !$comment = get_comment( $id ) ) { 319 $x = new WP_Ajax_Response( array( 320 'what' => 'comment', 321 'id' => new WP_Error('invalid_comment', sprintf(__('Comment %d does not exist'), $id)) 322 ) ); 323 $x->send(); 324 } 319 325 320 326 if ( !current_user_can( 'edit_post', $comment->comment_post_ID ) ) … … 330 336 if ( in_array( $current, array( 'unapproved', 'spam' ) ) ) { 331 337 check_ajax_referer( "approve-comment_$id" ); 332 if ( wp_set_comment_status( $comment->comment_ID, 'approve' ) ) 333 $r = 1; 338 $result = wp_set_comment_status( $comment->comment_ID, 'approve', true ); 334 339 } else { 335 340 check_ajax_referer( "unapprove-comment_$id" ); 336 if ( wp_set_comment_status( $comment->comment_ID, 'hold' ) ) 337 $r = 1; 338 } 339 if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts 340 _wp_ajax_delete_comment_response( $comment->comment_ID ); 341 $result = wp_set_comment_status( $comment->comment_ID, 'hold', true ); 342 } 343 if ( is_wp_error($result) ) { 344 $x = new WP_Ajax_Response( array( 345 'what' => 'comment', 346 'id' => $result 347 ) ); 348 $x->send(); 349 } 350 351 // Decide if we need to send back '1' or a more complicated response including page links and comment counts 352 _wp_ajax_delete_comment_response( $comment->comment_ID ); 341 353 die( '0' ); 342 354 break; -
trunk/wp-includes/comment.php
r10579 r10681 1015 1015 * @param int $comment_id Comment ID. 1016 1016 * @param string $comment_status New comment status, either 'hold', 'approve', 'spam', or 'delete'. 1017 * @param bool $wp_error Whether to return a WP_Error object if there is a failure. Default is false. 1017 1018 * @return bool False on failure or deletion and true on success. 1018 1019 */ 1019 function wp_set_comment_status($comment_id, $comment_status ) {1020 function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) { 1020 1021 global $wpdb; 1021 1022 … … 1041 1042 } 1042 1043 1043 if ( !$wpdb->query($query) ) 1044 return false; 1044 if ( !$wpdb->query($query) ) { 1045 if ( $wp_error ) 1046 return new WP_Error('db_update_error', __('Could not update comment status'), $wpdb->last_error); 1047 else 1048 return false; 1049 } 1045 1050 1046 1051 clean_comment_cache($comment_id);
Note: See TracChangeset
for help on using the changeset viewer.