Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: sanitize_file_name

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
883      if ( count( $parts ) <= 2 ) {
884           /**
885            * Filter a sanitized filename string.
886            *
887            * @since 2.8.0
888            *
889            * @param string $filename     Sanitized filename.
890            * @param string $filename_raw The filename prior to sanitization.
891            */
892           return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
893      }
894
895      // Process multiple extensions
896      $filename = array_shift($parts);
897      $extension = array_pop($parts);
898      $mimes = get_allowed_mime_types();
899
900      /*
901       * Loop over any intermediate extensions. Postfix them with a trailing underscore
 
Line Code
913                          break;
914                     }
915                }
916                if ( !$allowed )
917                     $filename .= '_';
918           }
919      }
920      $filename .= '.' . $extension;
921      /** This filter is documented in wp-includes/formatting.php */
922      return apply_filters('sanitize_file_name', $filename, $filename_raw);
923 }
924
925 /**
926  * Sanitizes a username, stripping out unsafe characters.
927  *
928  * Removes tags, octets, entities, and if strict is enabled, will only keep
929  * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
930  * raw username (the username in the parameter), and the value of $strict as
931  * parameters for the 'sanitize_user' filter.