Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

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.

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
200      $comment = get_comment($comment_id);
201
202      if ( ! $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1") )
203           return false;
204
205      $post_id = $comment->comment_post_ID;
206      if ( $post_id && $comment->comment_approved == 1 )
207           $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'" );
208
209      do_action('wp_set_comment_status', $comment_id, 'delete');
210      return true;
211 }
212
213 function clean_url( $url ) {
214      if ('' == $url) return $url;
215      $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $url);
216      $url = str_replace(';//', '://', $url);
217      $url = (!strstr($url, '://')) ? 'http://'.$url : $url;
218      $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $url);
 
Line Code
785            break;
786           case 'delete':
787                return wp_delete_comment($comment_id);
788           break;
789           default:
790                return false;
791     }
792     
793     if ($wpdb->query($query)) {
794           do_action('wp_set_comment_status', $comment_id, $comment_status);
795           
796           $comment = get_comment($comment_id);
797           $comment_post_ID = $comment->comment_post_ID;
798           $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" );
799           if( is_object( $c ) )
800                $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
801           return true;
802     } else {
803           return false;