Add file deletion filter. Props to that Andy guy. fixes #2703
git-svn-id: http://svn.automattic.com/wordpress/trunk@3768 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ed13228400
commit
5adf0d701b
|
@ -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…
Reference in New Issue