WordPress.org

Make WordPress Core

Ticket #2703: delete-filter.diff

File delete-filter.diff, 1.0 KB (added by skeltoac, 12 years ago)
  • wp-inst/wp-includes/functions-post.php

     
    384384
    385385        if ( ! empty($meta['thumb']) ) {
    386386                // Don't delete the thumb if another attachment uses it
    387                 if (! $foo = $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"))
    388                         @ unlink(str_replace(basename($file), $meta['thumb'], $file));
     387                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")) {
     388                        $thumbfile = str_replace(basename($file), $meta['thumb'], $file);
     389                        $thumbfile = apply_filters('wp_delete_file', $thumbfile);
     390                        @ unlink($thumbfile);
     391                }
    389392        }
    390393
     394        $file = apply_filters('wp_delete_file', $file);
     395
    391396        if ( ! empty($file) )
    392397                @ unlink($file);
    393398