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
1137      if ( count( $parts ) <= 2 ) {
1138           /**
1139            * Filter a sanitized filename string.
1140            *
1141            * @since 2.8.0
1142            *
1143            * @param string $filename     Sanitized filename.
1144            * @param string $filename_raw The filename prior to sanitization.
1145            */
1146           return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
1147      }
1148
1149      // Process multiple extensions
1150      $filename = array_shift($parts);
1151      $extension = array_pop($parts);
1152      $mimes = get_allowed_mime_types();
1153
1154      /*
1155       * Loop over any intermediate extensions. Postfix them with a trailing underscore
 
Line Code
1167                          break;
1168                     }
1169                }
1170                if ( !$allowed )
1171                     $filename .= '_';
1172           }
1173      }
1174      $filename .= '.' . $extension;
1175      /** This filter is documented in wp-includes/formatting.php */
1176      return apply_filters('sanitize_file_name', $filename, $filename_raw);
1177 }
1178
1179 /**
1180  * Sanitizes a username, stripping out unsafe characters.
1181  *
1182  * Removes tags, octets, entities, and if strict is enabled, will only keep
1183  * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
1184  * raw username (the username in the parameter), and the value of $strict as
1185  * parameters for the 'sanitize_user' filter.