Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: delete_attachment

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

Line Code
2584      if ( !$post = $wpdb->get_row(  $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
2585           return $post;
2586
2587      if ( 'attachment' != $post->post_type )
2588           return false;
2589
2590      $meta = wp_get_attachment_metadata( $postid );
2591      $file = get_attached_file( $postid );
2592
2593      do_action('delete_attachment', $postid);
2594
2595      /** @todo Delete for pluggable post taxonomies too */
2596      wp_delete_object_term_relationships($postid, array('category', 'post_tag'));
2597
2598      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
2599
2600      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $postid ));
2601
2602      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));