WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
| Line | Code |
|---|---|
| 2068 | * Filters the result when generating a unique file name. |
| 2069 | * |
| 2070 | * @since 4.5.0 |
| 2071 | * |
| 2072 | * @param string $filename Unique file name. |
| 2073 | * @param string $ext File extension, eg. ".png". |
| 2074 | * @param string $dir Directory path. |
| 2075 | * @param callable|null $unique_filename_callback Callback function that generates the unique file name. |
| 2076 | */ |
| 2077 | return apply_filters( 'wp_unique_filename', $filename2, $ext, $dir, $unique_filename_callback ); |
| 2078 | } |
| 2079 | |
| 2080 | while ( file_exists( $dir . "/$filename" ) ) { |
| 2081 | if ( '' == "$number$ext" ) { |
| 2082 | $filename = "$filename-" . ++$number; |
| 2083 | } else { |
| 2084 | $filename = str_replace( array( "-$number$ext", "$number$ext" ), "-" . ++$number . $ext, $filename ); |
| 2085 | } |
| 2086 | } |
| 2087 | } |
| 2088 | |
| 2089 | /** This filter is documented in wp-includes/functions.php */ |
| 2090 | return apply_filters( 'wp_unique_filename', $filename, $ext, $dir, $unique_filename_callback ); |
| 2091 | } |
| 2092 | |
| 2093 | /** |
| 2094 | * Create a file in the upload folder with given content. |
| 2095 | * |
| 2096 | * If there is an error, then the key 'error' will exist with the error message. |
| 2097 | * If success, then the key 'file' will have the unique file path, the 'url' key |
| 2098 | * will have the link to the new file. and the 'error' key will be set to false. |
| 2099 | * |