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
2843           return wp_trash_post( $post_id );
2844
2845      delete_post_meta($post_id, '_wp_trash_meta_status');
2846      delete_post_meta($post_id, '_wp_trash_meta_time');
2847
2848      $meta = wp_get_attachment_metadata( $post_id );
2849      $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );
2850      $file = get_attached_file( $post_id );
2851
2852      do_action('delete_attachment', $post_id);
2853
2854      wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
2855      wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
2856
2857      $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_thumbnail_id' AND meta_value = %d", $post_id ));
2858
2859      $comment_ids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
2860      if ( ! empty($comment_ids) ) {
2861           do_action( 'delete_comment', $comment_ids );