Source View: wp_set_comment_status

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
535      if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
536           return false;
537
538      $post_id = $comment->comment_post_ID;
539      if ( $post_id && $comment->comment_approved == 1 )
540           wp_update_comment_count($post_id);
541
542      clean_comment_cache($comment_id);
543
544      do_action('wp_set_comment_status', $comment_id, 'delete');
545      return true;
546 }
547
548 /**
549  * The status of a comment by ID.
550  *
551  * @since 1.0.0
552  *
553  * @param int $comment_id Comment ID
 
Line Code
776           default:
777                return false;
778      }
779
780      if ( !$wpdb->query($query) )
781           return false;
782
783      clean_comment_cache($comment_id);
784
785      do_action('wp_set_comment_status', $comment_id, $comment_status);
786      $comment = get_comment($comment_id);
787      wp_update_comment_count($comment->comment_post_ID);
788
789      return true;
790 }
791
792 /**
793  * Parses and updates an existing comment in the database.
794  *