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
1235 function delete_post_meta_by_key($post_meta_key) {
1236      if ( !$post_meta_key )
1237           return false;
1238
1239      global $wpdb;
1240      $post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
1241      if ( $post_ids ) {
1242           $postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key ) );
1243           $in = implode( ',', array_fill(1, count($postmetaids), '%d'));
1244           do_action( 'delete_postmeta', $postmetaids );
1245           $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN($in)", $postmetaids ));
1246           do_action( 'deleted_postmeta', $postmetaids );
1247           foreach ( $post_ids as $post_id )
1248                wp_cache_delete($post_id, 'post_meta');
1249           return true;
1250      }
1251      return false;
1252 }
1253
 
Line Code
1768      if ( ! empty($comment_ids) ) {
1769           do_action( 'delete_comment', $comment_ids );
1770           foreach ( $comment_ids as $comment_id )
1771                wp_delete_comment( $comment_id, true );
1772           do_action( 'deleted_comment', $comment_ids );
1773      }
1774
1775      $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
1776      if ( !empty($post_meta_ids) ) {
1777           do_action( 'delete_postmeta', $post_meta_ids );
1778           $in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'";
1779           $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" );
1780           do_action( 'deleted_postmeta', $post_meta_ids );
1781      }
1782
1783      do_action( 'delete_post', $postid );
1784      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
1785      do_action( 'deleted_post', $postid );
1786
 
Line Code
3466      if ( ! empty( $comment_ids ) ) {
3467           do_action( 'delete_comment', $comment_ids );
3468           foreach ( $comment_ids as $comment_id )
3469                wp_delete_comment( $comment_id, true );
3470           do_action( 'deleted_comment', $comment_ids );
3471      }
3472
3473      $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
3474      if ( !empty($post_meta_ids) ) {
3475           do_action( 'delete_postmeta', $post_meta_ids );
3476           $in_post_meta_ids = "'" . implode("', '", $post_meta_ids) . "'";
3477           $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_id IN($in_post_meta_ids)" );
3478           do_action( 'deleted_postmeta', $post_meta_ids );
3479      }
3480
3481      do_action( 'delete_post', $post_id );
3482      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));
3483      do_action( 'deleted_post', $post_id );
3484