WP hooks navigation: Home/browse • Actions index • Filters index
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.
This hook occurs 3 times in this file.
Line | Code |
---|---|
1497 | function delete_post_meta_by_key($post_meta_key) { |
1498 | if ( !$post_meta_key ) |
1499 | return false; |
1500 |
|
1501 | global $wpdb; |
1502 | $post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key)); |
1503 | if ( $post_ids ) { |
1504 | $postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key ) ); |
1505 | $in = implode( ',', array_fill(1, count($postmetaids), '%d')); |
1506 | do_action( 'delete_postmeta', $postmetaids ); |
1507 | $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids )); |
1508 | do_action( 'deleted_postmeta', $postmetaids ); |
1509 | foreach ( $post_ids as $post_id ) |
1510 | wp_cache_delete($post_id, 'post_meta'); |
1511 | return true; |
1512 | } |
1513 | return false; |
1514 | } |
1515 |
|
Line | Code |
2026 | if ( ! empty($comment_ids) ) { |
2027 | do_action( 'delete_comment', $comment_ids ); |
2028 | foreach ( $comment_ids as $comment_id ) |
2029 | wp_delete_comment( $comment_id, true ); |
2030 | do_action( 'deleted_comment', $comment_ids ); |
2031 | } |
2032 |
|
2033 | $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid )); |
2034 | if ( !empty($post_meta_ids) ) { |
2035 | do_action( 'delete_postmeta', $post_meta_ids ); |
2036 | $in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'"; |
2037 | $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" ); |
2038 | do_action( 'deleted_postmeta', $post_meta_ids ); |
2039 | } |
2040 |
|
2041 | do_action( 'delete_post', $postid ); |
2042 | $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid )); |
2043 | do_action( 'deleted_post', $postid ); |
2044 |
|
Line | Code |
3793 | if ( ! empty( $comment_ids ) ) { |
3794 | do_action( 'delete_comment', $comment_ids ); |
3795 | foreach ( $comment_ids as $comment_id ) |
3796 | wp_delete_comment( $comment_id, true ); |
3797 | do_action( 'deleted_comment', $comment_ids ); |
3798 | } |
3799 |
|
3800 | $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id )); |
3801 | if ( !empty($post_meta_ids) ) { |
3802 | do_action( 'delete_postmeta', $post_meta_ids ); |
3803 | $in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'"; |
3804 | $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" ); |
3805 | do_action( 'deleted_postmeta', $post_meta_ids ); |
3806 | } |
3807 |
|
3808 | do_action( 'delete_post', $post_id ); |
3809 | $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id )); |
3810 | do_action( 'deleted_post', $post_id ); |
3811 |
|