Use call_user_func for wpnique_filename callback. fixes #14627.

git-svn-id: http://svn.automattic.com/wordpress/trunk@16025 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-10-27 22:27:06 +00:00
parent 82b1349664
commit 71815b682c
1 changed files with 5 additions and 5 deletions

View File

@ -2198,14 +2198,14 @@ function wp_upload_dir( $time = null ) {
* before the extension, and will continue adding numbers until the filename is * before the extension, and will continue adding numbers until the filename is
* unique. * unique.
* *
* The callback must accept two parameters, the first one is the directory and * The callback is passed three parameters, the first one is the directory, the
* the second is the filename. The callback must be a function. * second is the filename, and the third is the extension.
* *
* @since 2.5 * @since 2.5
* *
* @param string $dir * @param string $dir
* @param string $filename * @param string $filename
* @param string $unique_filename_callback Function name, must be a function. * @param mixed $unique_filename_callback Callback.
* @return string New filename, if given wasn't unique. * @return string New filename, if given wasn't unique.
*/ */
function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
@ -2221,9 +2221,9 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
if ( $name === $ext ) if ( $name === $ext )
$name = ''; $name = '';
// Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied. // Increment the file number until we have a unique file to save in $dir. Use callback if supplied.
if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) { if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) {
$filename = $unique_filename_callback( $dir, $name ); $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext );
} else { } else {
$number = ''; $number = '';