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
1392      if ( count( $parts ) <= 2 ) {
1393           /**
1394            * Filter a sanitized filename string.
1395            *
1396            * @since 2.8.0
1397            *
1398            * @param string $filename     Sanitized filename.
1399            * @param string $filename_raw The filename prior to sanitization.
1400            */
1401           return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
1402      }
1403
1404      // Process multiple extensions
1405      $filename = array_shift($parts);
1406      $extension = array_pop($parts);
1407      $mimes = get_allowed_mime_types();
1408
1409      /*
1410       * Loop over any intermediate extensions. Postfix them with a trailing underscore
 
Line Code
1422                          break;
1423                     }
1424                }
1425                if ( !$allowed )
1426                     $filename .= '_';
1427           }
1428      }
1429      $filename .= '.' . $extension;
1430      /** This filter is documented in wp-includes/formatting.php */
1431      return apply_filters('sanitize_file_name', $filename, $filename_raw);
1432 }
1433
1434 /**
1435  * Sanitizes a username, stripping out unsafe characters.
1436  *
1437  * Removes tags, octets, entities, and if strict is enabled, will only keep
1438  * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
1439  * raw username (the username in the parameter), and the value of $strict as
1440  * parameters for the 'sanitize_user' filter.