Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: wp_delete_file

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
1382
1383      $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = '$postid'");
1384
1385      $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$postid'");
1386
1387      if ( ! empty($meta['thumb']) ) {
1388           // Don't delete the thumb if another attachment uses it
1389           if (! $wpdb->get_row("SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE '%".$wpdb->escape($meta['thumb'])."%' AND post_id <> $postid")) {
1390                $thumbfile = str_replace(basename($file), $meta['thumb'], $file);
1391                $thumbfile = apply_filters('wp_delete_file', $thumbfile);
1392                @ unlink($thumbfile);
1393           }
1394      }
1395
1396      $file = apply_filters('wp_delete_file', $file);
1397
1398      if ( ! empty($file) )
1399           @ unlink($file);
1400
1401      do_action('delete_attachment', $postid);
1402
1403      return $post;
1404 }
1405