wp_check_filetype_and_ext

Filters the "real" file type of the given file.

Description

apply_filters( 'wp_check_filetype_and_ext', (string) $compact, (string) $file, (string) $filename, (array) $mimes ); 

Parameters (4)

0. $compact (string) => compact( 'ext', 'type', 'proper_filename' )
File data array containing ext,, type , and proper_filename keys.
1. $file (string)
Full path to the file.
2. $filename (string)
The name of the file (may differ from $file due to $file being in a tmp directory).
3. $mimes (array)
Key is the file extension with value as the mime type.

Usage

To run the hook, copy the example below.
  1. $compact = apply_filters( 'wp_check_filetype_and_ext', $compact, $file, $filename, $mimes ); 
  2.  
  3. if ( !empty( $compact ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_check_filetype_and_ext callback 
  2. function filter_wp_check_filetype_and_ext( $compact, $file, $filename, $mimes ) { 
  3. // make filter magic happen here... 
  4. return $compact
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_check_filetype_and_ext', 'filter_wp_check_filetype_and_ext', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_check_filetype_and_ext', 'filter_wp_check_filetype_and_ext', 10, 4 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/functions.php  
  1. return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes );