Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: delete_comment

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.

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

Source View

Line Code
726  * @uses do_action() Calls 'delete_comment' hook on comment ID
727  * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter
728  * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object
729  *
730  * @param int $comment_id Comment ID
731  * @return bool False if delete comment query failure, true on success.
732  */
733 function wp_delete_comment($comment_id) {
734      global $wpdb;
735      do_action('delete_comment', $comment_id);
736
737      $comment = get_comment($comment_id);
738
739      if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
740           return false;
741
742      $post_id = $comment->comment_post_ID;
743      if ( $post_id && $comment->comment_approved == 1 )
744           wp_update_comment_count($post_id);