wp_unique_filename хук-фильтрWP 4.5.0

Filters the result when generating a unique file name.

Использование

add_filter( 'wp_unique_filename', 'wp_kama_unique_filename_filter', 10, 6 );

/**
 * Function for `wp_unique_filename` filter-hook.
 * 
 * @param string        $filename                 Unique file name.
 * @param string        $ext                      File extension. Example: ".png".
 * @param string        $dir                      Directory path.
 * @param callable|null $unique_filename_callback Callback function that generates the unique file name.
 * @param string[]      $alt_filenames            Array of alternate file names that were checked for collisions.
 * @param int|string    $number                   The highest number that was used to make the file name unique or an empty string if unused.
 *
 * @return string
 */
function wp_kama_unique_filename_filter( $filename, $ext, $dir, $unique_filename_callback, $alt_filenames, $number ){

	// filter...
	return $filename;
}
$filename(строка)
Unique file name.
$ext(строка)
File extension. Example: ".png".
$dir(строка)
Directory path.
$unique_filename_callback(callable|null)
Callback function that generates the unique file name.
$alt_filenames(string[])
Array of alternate file names that were checked for collisions.
$number(int|строка)
The highest number that was used to make the file name unique or an empty string if unused.

Список изменений

С версии 4.5.0 Введена.
С версии 5.8.1 The $alt_filenames and $number parameters were added.

Где вызывается хук

wp_unique_filename()
wp_unique_filename
wp-includes/functions.php 2765
return apply_filters( 'wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback, $alt_filenames, $number );

Где используется хук в WordPress

Использование не найдено.