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
1774      if ( count( $parts ) <= 2 ) {
1775           /**
1776            * Filters a sanitized filename string.
1777            *
1778            * @since 2.8.0
1779            *
1780            * @param string $filename     Sanitized filename.
1781            * @param string $filename_raw The filename prior to sanitization.
1782            */
1783           return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
1784      }
1785
1786      // Process multiple extensions
1787      $filename = array_shift($parts);
1788      $extension = array_pop($parts);
1789      $mimes = get_allowed_mime_types();
1790
1791      /*
1792       * Loop over any intermediate extensions. Postfix them with a trailing underscore
 
Line Code
1804                          break;
1805                     }
1806                }
1807                if ( !$allowed )
1808                     $filename .= '_';
1809           }
1810      }
1811      $filename .= '.' . $extension;
1812      /** This filter is documented in wp-includes/formatting.php */
1813      return apply_filters('sanitize_file_name', $filename, $filename_raw);
1814 }
1815
1816 /**
1817  * Sanitizes a username, stripping out unsafe characters.
1818  *
1819  * Removes tags, octets, entities, and if strict is enabled, will only keep
1820  * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
1821  * raw username (the username in the parameter), and the value of $strict as
1822  * parameters for the {@see 'sanitize_user'} filter.