Ticket #17864: 17864.2.diff
File 17864.2.diff, 6.3 KB (added by , 10 years ago) |
---|
-
wp-includes/post.php
3733 3733 delete_post_meta($post_id, '_wp_trash_meta_status'); 3734 3734 delete_post_meta($post_id, '_wp_trash_meta_time'); 3735 3735 3736 $meta = wp_get_attachment_metadata( $post_id );3737 $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true );3738 $file = get_attached_file( $post_id );3739 3740 3736 if ( is_multisite() ) 3741 3737 delete_transient( 'dirsize_cache' ); 3742 3738 … … 3767 3763 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id )); 3768 3764 do_action( 'deleted_post', $post_id ); 3769 3765 3770 $uploadpath = wp_upload_dir(); 3766 // Delete all the associated files 3767 $meta = wp_get_attachment_metadata( $post_id ); 3768 $backup_sizes = get_post_meta( $post->ID, '_wp_attachment_backup_sizes', true ); 3769 $file = $meta['file']; 3771 3770 3772 3771 if ( ! empty($meta['thumb']) ) { 3773 3772 // Don't delete the thumb if another attachment uses it 3774 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 $thumbfile = str_replace(basename($file), $meta['thumb'], $file); 3776 $thumbfile = apply_filters('wp_delete_file', $thumbfile); 3777 @ unlink( path_join($uploadpath['basedir'], $thumbfile) ); 3773 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)) ) { 3774 wp_delete_file( path_join( dirname($file), $meta['thumb'] ) ); 3778 3775 } 3779 3776 } 3780 3777 3781 // remove intermediate and backup images if there are any3782 3778 foreach ( get_intermediate_image_sizes() as $size ) { 3783 3779 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) ); 3780 wp_delete_file( $intermediate['path'] ); 3786 3781 } 3787 3782 } 3788 3783 3789 if ( is_array( $backup_sizes) ) {3784 if ( is_array( $backup_sizes ) ) { 3790 3785 foreach ( $backup_sizes as $size ) { 3791 $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) ); 3786 wp_delete_file( path_join( dirname($file), $size['file'] ) ); 3794 3787 } 3795 3788 } 3796 3789 3797 $file = apply_filters('wp_delete_file', $file);3790 wp_delete_file( $file ); 3798 3791 3799 if ( ! empty($file) )3800 @ unlink($file);3801 3802 3792 clean_post_cache($post_id); 3803 3793 3804 3794 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 ?> -
wp-admin/includes/image-edit.php
440 440 if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { 441 441 // delete only if it's edited image 442 442 if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) { 443 $delpath = apply_filters('wp_delete_file', $file); 444 @unlink($delpath); 443 wp_delete_file( $file ); 445 444 } 446 445 } else { 447 446 $backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']); … … 465 464 if ( defined('IMAGE_EDIT_OVERWRITE') && IMAGE_EDIT_OVERWRITE ) { 466 465 // delete only if it's edited image 467 466 if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) { 468 $delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) ); 469 @unlink($delpath); 467 wp_delete_file( path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) ); 470 468 } 471 469 } else { 472 470 $backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size]; … … 656 654 } 657 655 658 656 if ( $delete ) { 659 $delpath = apply_filters('wp_delete_file', $new_path); 660 @unlink($delpath); 657 wp_delete_file( $new_path ); 661 658 } 662 659 663 660 imagedestroy($img); -
wp-admin/custom-header.php
722 722 } 723 723 724 724 $attachment_id = absint( $_POST['attachment_id'] ); 725 $original = get_attached_file( $attachment_id);725 $original = get_attached_file( $attachment_id ); 726 726 727 727 $cropped = wp_crop_image( $attachment_id, (int) $_POST['x1'], (int) $_POST['y1'], (int) $_POST['width'], (int) $_POST['height'], HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT ); 728 728 if ( is_wp_error( $cropped ) ) … … 751 751 752 752 set_theme_mod('header_image', $url); 753 753 754 // cleanup755 $medium = str_replace(basename($original), 'midsize-'.basename($original), $original);756 @unlink( apply_filters( 'wp_delete_file', $medium ));757 @unlink( apply_filters( 'wp_delete_file', $original ));754 // Delete old files 755 $medium = path_join( dirname($original), 'midsize-' . basename($original) ); 756 wp_delete_file( $medium ); 757 wp_delete_file( $original ); 758 758 759 759 return $this->finished(); 760 760 }