Add file deletion filter. Props to that Andy guy. fixes #2703
git-svn-id: https://develop.svn.wordpress.org/trunk@3768 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a72fbca9d1
commit
e0d1ccd210
@ -384,10 +384,15 @@ function wp_delete_attachment($postid) {
|
||||
|
||||
if ( ! empty($meta['thumb']) ) {
|
||||
// Don't delete the thumb if another attachment uses it
|
||||
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'"))
|
||||
@ unlink(str_replace(basename($file), $meta['thumb'], $file));
|
||||
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")) {
|
||||
$thumbfile = str_replace(basename($file), $meta['thumb'], $file);
|
||||
$thumbfile = apply_filters('wp_delete_file', $thumbfile);
|
||||
@ unlink($thumbfile);
|
||||
}
|
||||
}
|
||||
|
||||
$file = apply_filters('wp_delete_file', $file);
|
||||
|
||||
if ( ! empty($file) )
|
||||
@ unlink($file);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user