Ticket #17864: 17864.diff
| File 17864.diff, 3.3 KB (added by scribu, 2 years ago) |
|---|
-
wp-includes/post.php
3735 3735 3736 3736 $meta = wp_get_attachment_metadata( $post_id ); 3737 3737 $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true ); 3738 $file = get_attached_file( $post_id );3738 $file = $meta['file']; 3739 3739 3740 3740 if ( is_multisite() ) 3741 3741 delete_transient( 'dirsize_cache' ); … … 3767 3767 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id )); 3768 3768 do_action( 'deleted_post', $post_id ); 3769 3769 3770 $uploadpath = wp_upload_dir();3771 3772 3770 if ( ! empty($meta['thumb']) ) { 3773 3771 // Don't delete the thumb if another attachment uses it 3774 3772 if (! $wpdb->get_row( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $meta['thumb'] . '%', $post_id)) ) { 3775 3773 $thumbfile = str_replace(basename($file), $meta['thumb'], $file); 3776 $thumbfile = apply_filters('wp_delete_file', $thumbfile); 3777 @ unlink( path_join($uploadpath['basedir'], $thumbfile) ); 3774 wp_delete_file( $thumbfile ); 3778 3775 } 3779 3776 } 3780 3777 3781 3778 // remove intermediate and backup images if there are any 3782 3779 foreach ( get_intermediate_image_sizes() as $size ) { 3783 3780 if ( $intermediate = image_get_intermediate_size($post_id, $size) ) { 3784 $intermediate_file = apply_filters('wp_delete_file', $intermediate['path']); 3785 @ unlink( path_join($uploadpath['basedir'], $intermediate_file) ); 3781 wp_delete_file( $intermediate['path'] ); 3786 3782 } 3787 3783 } 3788 3784 3789 if ( is_array( $backup_sizes) ) {3785 if ( is_array( $backup_sizes ) ) { 3790 3786 foreach ( $backup_sizes as $size ) { 3791 3787 $del_file = path_join( dirname($meta['file']), $size['file'] ); 3792 $del_file = apply_filters('wp_delete_file', $del_file); 3793 @ unlink( path_join($uploadpath['basedir'], $del_file) ); 3788 wp_delete_file( $del_file ); 3794 3789 } 3795 3790 } 3796 3791 3797 $file = apply_filters('wp_delete_file', $file);3792 wp_delete_file( $file ); 3798 3793 3799 if ( ! empty($file) )3800 @ unlink($file);3801 3802 3794 clean_post_cache($post_id); 3803 3795 3804 3796 return $post; -
wp-includes/media.php
669 669 } 670 670 671 671 /** 672 * Applies the 'wp_delete_file' filter before deleting the file 673 * 674 * @since 3.3 675 * 676 * @param string $file A file path, absolute or relative to the wp-uploads directory 677 */ 678 function wp_delete_file( $file ) { 679 $file = apply_filters( 'wp_delete_file', $file ); 680 681 if ( !empty( $file ) ) { 682 $wud = wp_upload_dir(); 683 @unlink( path_join( $wud['basedir'], $file ) ); 684 } 685 } 686 687 /** 672 688 * Adds a 'wp-post-image' class to post thumbnail thumbnails 673 689 * Uses the begin_fetch_post_thumbnail_html and end_fetch_post_thumbnail_html action hooks to 674 690 * dynamically add/remove itself so as to only filter post thumbnail thumbnails … … 1438 1454 return apply_filters( 'embed_googlevideo', '<embed type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docid=' . esc_attr($matches[2]) . '&hl=en&fs=true" style="width:' . esc_attr($width) . 'px;height:' . esc_attr($height) . 'px" allowFullScreen="true" allowScriptAccess="always" />', $matches, $attr, $url, $rawattr ); 1439 1455 } 1440 1456 1441 ?> 1442 No newline at end of file 1457 ?>
