Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: delete_postmeta

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 3 times in this file.

Line Code
1466 function delete_post_meta_by_key($post_meta_key) {
1467      if ( !$post_meta_key )
1468           return false;
1469
1470      global $wpdb;
1471      $post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
1472      if ( $post_ids ) {
1473           $postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key ) );
1474           $in = implode( ',', array_fill(1, count($postmetaids), '%d'));
1475           do_action( 'delete_postmeta', $postmetaids );
1476           $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ));
1477           do_action( 'deleted_postmeta', $postmetaids );
1478           foreach ( $post_ids as $post_id )
1479                wp_cache_delete($post_id, 'post_meta');
1480           return true;
1481      }
1482      return false;
1483 }
1484
 
Line Code
1995      if ( ! empty($comment_ids) ) {
1996           do_action( 'delete_comment', $comment_ids );
1997           foreach ( $comment_ids as $comment_id )
1998                wp_delete_comment( $comment_id, true );
1999           do_action( 'deleted_comment', $comment_ids );
2000      }
2001
2002      $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
2003      if ( !empty($post_meta_ids) ) {
2004           do_action( 'delete_postmeta', $post_meta_ids );
2005           $in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'";
2006           $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" );
2007           do_action( 'deleted_postmeta', $post_meta_ids );
2008      }
2009
2010      do_action( 'delete_post', $postid );
2011      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
2012      do_action( 'deleted_post', $postid );
2013
 
Line Code
3708      if ( ! empty( $comment_ids ) ) {
3709           do_action( 'delete_comment', $comment_ids );
3710           foreach ( $comment_ids as $comment_id )
3711                wp_delete_comment( $comment_id, true );
3712           do_action( 'deleted_comment', $comment_ids );
3713      }
3714
3715      $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
3716      if ( !empty($post_meta_ids) ) {
3717           do_action( 'delete_postmeta', $post_meta_ids );
3718           $in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'";
3719           $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" );
3720           do_action( 'deleted_postmeta', $post_meta_ids );
3721      }
3722
3723      do_action( 'delete_post', $post_id );
3724      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));
3725      do_action( 'deleted_post', $post_id );
3726