apply_filters( 'pre_wp_unique_filename_file_list', array|null $files, string $dir, string $filename )
- Since
- 5.5.0
Filters the file list used for calculating a unique filename for a newly added file.
Description
Returning an array from the filter will effectively short-circuit retrieval from the filesystem and return the passed value instead.
Compatibility
- WordPress
- since 5.5.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Parameters
$filesarray|null- The list of files to use for filename comparisons.
Default null (to retrieve the list from the filesystem). $dirstring- The directory for the new file.
$filenamestring- The proposed filename for the new file.
Where this hook fires · 1
wp-includes/functions.php:2708wp_unique_filename()
Source code
* * @param array|null $files The list of files to use for filename comparisons. * Default null (to retrieve the list from the filesystem). * @param string $dir The directory for the new file. * @param string $filename The proposed filename for the new file. */ $files = apply_filters( 'pre_wp_unique_filename_file_list', null, $dir, $filename ); if ( null === $files ) { // List of all files and directories contained in $dir. $files = @scandir( $dir ); }Changelog
Introduced in 5.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
- Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.