From 5adf0d701be24fa84162d5cf85bcc60f71b66778 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 9 May 2006 22:44:51 +0000 Subject: [PATCH] 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 --- wp-includes/functions-post.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index dada52cd6a..e684051076 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -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);