sanitize_file_name_chars

sanitize_file_name_chars

Appears in: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,
Hook Type: filter

See hook in core

Displaying hooks found in version: wordpress-6.5.2

apply_filters('sanitize_file_name_chars') is found 1 times:

  • /wp-includes/formatting.php line 2061
    	 *
    	 * @param string[] $special_chars Array of characters to remove.
    	 * @param string   $filename_raw  The original filename to be sanitized.
    	 */
    	$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );
    
    	$filename = str_replace( $special_chars, '', $filename );
    	$filename = str_replace( array( '%20', '+' ), '-', $filename );
    	$filename = preg_replace( '/\.{2,}/', '.', $filename );
    	$filename = preg_replace( '/[\r\n\t -]+/', '-', $filename );
    	$filename = trim( $filename, '.-_' );