To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN
(without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )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.
| Line | Code |
|---|---|
| 808 | * @uses do_action() Calls 'deleted_comment' hook on comment ID after deletion, on success |
| 809 | * @uses do_action() Calls 'wp_set_comment_status' hook on comment ID with 'delete' set for the second parameter |
| 810 | * @uses wp_transition_comment_status() Passes new and old comment status along with $comment object |
| 811 | * |
| 812 | * @param int $comment_id Comment ID |
| 813 | * @return bool False if delete comment query failure, true on success. |
| 814 | */ |
| 815 | function wp_delete_comment($comment_id) { |
| 816 | global $wpdb; |
| 817 | if (!$comment = get_comment($comment_id)) |
| 818 | return false; |
| 819 | |
| 820 | if (wp_get_comment_status($comment_id) != 'trash' && wp_get_comment_status($comment_id) != 'spam' && EMPTY_TRASH_DAYS > 0) |
| 821 | return wp_trash_comment($comment_id); |
| 822 | |
| 823 | do_action('delete_comment', $comment_id); |
| 824 | |
| 825 | // Move children up a level. |
| 826 | $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) ); |
| 827 | if ( !empty($children) ) { |
| 828 | $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id)); |
| 829 | clean_comment_cache($children); |
| 830 | } |
| 831 | |
| 832 | // Delete metadata |
| 833 | $meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->commentmeta WHERE comment_id = %d ", $comment_id ) ); |
| 834 | if ( !empty($meta_ids) ) { |
| 835 | do_action( 'delete_commentmeta', $meta_ids ); |
| 836 | $in_meta_ids = "'" . implode("', '", $meta_ids) . "'"; |
| 837 | $wpdb->query( "DELETE FROM $wpdb->commentmeta WHERE meta_id IN ($in_meta_ids)" ); |
| 838 | do_action( 'deleted_commentmeta', $meta_ids ); |