Filesystem API: Add a filter to `wp_unique_filename()`.
Props SergeyBiryukov, MikeHansenMe, johnbillion, swissspidy. Fixes #19121. Built from https://develop.svn.wordpress.org/trunk@36310 git-svn-id: http://core.svn.wordpress.org/trunk@36277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6951e8d045
commit
16142a461e
|
@ -2003,7 +2003,18 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
|
|||
$filename2 = str_replace( array( "-$number$ext2", "$number$ext2" ), "-$new_number$ext2", $filename2 );
|
||||
$number = $new_number;
|
||||
}
|
||||
return $filename2;
|
||||
|
||||
/**
|
||||
* Filter the result when generating a unique file name.
|
||||
*
|
||||
* @since 4.5.0
|
||||
*
|
||||
* @param string $filename Unique file name.
|
||||
* @param string $ext File extension, eg. ".png".
|
||||
* @param string $dir Directory path.
|
||||
* @param callable|null $unique_filename_callback Callback function that generates the unique file name.
|
||||
*/
|
||||
return apply_filters( 'wp_unique_filename', $filename2, $ext, $dir, $unique_filename_callback );
|
||||
}
|
||||
|
||||
while ( file_exists( $dir . "/$filename" ) ) {
|
||||
|
@ -2015,7 +2026,8 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
|
|||
}
|
||||
}
|
||||
|
||||
return $filename;
|
||||
/** This filter is documented in wp-includes/functions.php */
|
||||
return apply_filters( 'wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-alpha-36309';
|
||||
$wp_version = '4.5-alpha-36310';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue