Make a new function, wp_delete_file(). Use it.

Props scribu, wonderboymusic.
Fixes #17864.


git-svn-id: https://develop.svn.wordpress.org/trunk@31575 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-02-27 16:50:14 +00:00
parent 65c58832cb
commit 212d6d8046
4 changed files with 31 additions and 29 deletions

View File

@@ -616,10 +616,7 @@ function wp_restore_image($post_id) {
// Delete only if it's edited image.
if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) {
/** This filter is documented in wp-admin/custom-header.php */
$delpath = apply_filters( 'wp_delete_file', $file );
@unlink($delpath);
wp_delete_file( $file );
}
} elseif ( isset( $meta['width'], $meta['height'] ) ) {
$backup_sizes["full-$suffix"] = array('width' => $meta['width'], 'height' => $meta['height'], 'file' => $parts['basename']);
@@ -642,9 +639,8 @@ function wp_restore_image($post_id) {
// Delete only if it's edited image
if ( preg_match('/-e[0-9]{13}-/', $meta['sizes'][$default_size]['file']) ) {
/** This filter is documented in wp-admin/custom-header.php */
$delpath = apply_filters( 'wp_delete_file', path_join($parts['dirname'], $meta['sizes'][$default_size]['file']) );
@unlink($delpath);
$delete_file = path_join( $parts['dirname'], $meta['sizes'][$default_size]['file'] );
wp_delete_file( $delete_file );
}
} else {
$backup_sizes["$default_size-{$suffix}"] = $meta['sizes'][$default_size];
@@ -857,10 +853,7 @@ function wp_save_image( $post_id ) {
}
if ( $delete ) {
/** This filter is documented in wp-admin/custom-header.php */
$delpath = apply_filters( 'wp_delete_file', $new_path );
@unlink( $delpath );
wp_delete_file( $new_path );
}
$return->msg = esc_js( __('Image saved') );