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
2056           }
2057      }
2058
2059      // Split the filename into a base and extension[s].
2060      $parts = explode( '.', $filename );
2061
2062      // Return if only one extension.
2063      if ( count( $parts ) <= 2 ) {
2064           /** This filter is documented in wp-includes/formatting.php */
2065           return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
2066      }
2067
2068      // Process multiple extensions.
2069      $filename  = array_shift( $parts );
2070      $extension = array_pop( $parts );
2071      $mimes     = get_allowed_mime_types();
2072
2073      /*
2074       * Loop over any intermediate extensions. Postfix them with a trailing underscore
 
Line Code
2096
2097      /**
2098       * Filters a sanitized filename string.
2099       *
2100       * @since 2.8.0
2101       *
2102       * @param string $filename     Sanitized filename.
2103       * @param string $filename_raw The filename prior to sanitization.
2104       */
2105      return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
2106 }
2107
2108 /**
2109  * Sanitizes a username, stripping out unsafe characters.
2110  *
2111  * Removes tags, octets, entities, and if strict is enabled, will only keep
2112  * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
2113  * raw username (the username in the parameter), and the value of $strict as
2114  * parameters for the {@see 'sanitize_user'} filter.