WordPress.org

Make WordPress Core

Ticket #14627: 14627.diff

File 14627.diff, 1.5 KB (added by nacin, 9 years ago)
  • wp-includes/functions.php

     
    21982198 * before the extension, and will continue adding numbers until the filename is
    21992199 * unique.
    22002200 *
    2201  * The callback must accept two parameters, the first one is the directory and
    2202  * the second is the filename. The callback must be a function.
     2201 * The callback is passed three parameters, the first one is the directory, the
     2202 * second is the filename, and the third is the extension.
    22032203 *
    22042204 * @since 2.5
    22052205 *
    22062206 * @param string $dir
    22072207 * @param string $filename
    2208  * @param string $unique_filename_callback Function name, must be a function.
     2208 * @param mixed $unique_filename_callback Callback.
    22092209 * @return string New filename, if given wasn't unique.
    22102210 */
    22112211function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
     
    22212221        if ( $name === $ext )
    22222222                $name = '';
    22232223
    2224         // Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied.
     2224        // Increment the file number until we have a unique file to save in $dir. Use callback if supplied.
    22252225        if ( $unique_filename_callback && is_callable( $unique_filename_callback ) ) {
    2226                 $filename = $unique_filename_callback( $dir, $name );
     2226                $filename = call_user_func( $unique_filename_callback, $dir, $name, $ext );
    22272227        } else {
    22282228                $number = '';
    22292229