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
1084      if ( count( $parts ) <= 2 ) {
1085           /**
1086            * Filter a sanitized filename string.
1087            *
1088            * @since 2.8.0
1089            *
1090            * @param string $filename     Sanitized filename.
1091            * @param string $filename_raw The filename prior to sanitization.
1092            */
1093           return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
1094      }
1095
1096      // Process multiple extensions
1097      $filename = array_shift($parts);
1098      $extension = array_pop($parts);
1099      $mimes = get_allowed_mime_types();
1100
1101      /*
1102       * Loop over any intermediate extensions. Postfix them with a trailing underscore
 
Line Code
1114                          break;
1115                     }
1116                }
1117                if ( !$allowed )
1118                     $filename .= '_';
1119           }
1120      }
1121      $filename .= '.' . $extension;
1122      /** This filter is documented in wp-includes/formatting.php */
1123      return apply_filters('sanitize_file_name', $filename, $filename_raw);
1124 }
1125
1126 /**
1127  * Sanitizes a username, stripping out unsafe characters.
1128  *
1129  * Removes tags, octets, entities, and if strict is enabled, will only keep
1130  * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
1131  * raw username (the username in the parameter), and the value of $strict as
1132  * parameters for the 'sanitize_user' filter.