Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: delete_post

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
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
2045      if ( 'page' == $post->post_type ) {
2046           clean_page_cache($postid);
2047
2048           foreach ( (array) $children as $child )
2049                clean_page_cache($child->ID);
2050
 
Line Code
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
3812      $uploadpath = wp_upload_dir();
3813
3814      if ( ! empty($meta['thumb']) ) {
3815           // Don't delete the thumb if another attachment uses it
3816           if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $meta['thumb'] . '%', $post_id)) ) {
3817                $thumbfile = str_replace(basename($file), $meta['thumb'], $file);