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
1792      if ( count( $parts ) <= 2 ) {
1793           /**
1794            * Filters a sanitized filename string.
1795            *
1796            * @since 2.8.0
1797            *
1798            * @param string $filename     Sanitized filename.
1799            * @param string $filename_raw The filename prior to sanitization.
1800            */
1801           return apply_filters( 'sanitize_file_name', $filename, $filename_raw );
1802      }
1803
1804      // Process multiple extensions
1805      $filename = array_shift($parts);
1806      $extension = array_pop($parts);
1807      $mimes = get_allowed_mime_types();
1808
1809      /*
1810       * Loop over any intermediate extensions. Postfix them with a trailing underscore
 
Line Code
1822                          break;
1823                     }
1824                }
1825                if ( !$allowed )
1826                     $filename .= '_';
1827           }
1828      }
1829      $filename .= '.' . $extension;
1830      /** This filter is documented in wp-includes/formatting.php */
1831      return apply_filters('sanitize_file_name', $filename, $filename_raw);
1832 }
1833
1834 /**
1835  * Sanitizes a username, stripping out unsafe characters.
1836  *
1837  * Removes tags, octets, entities, and if strict is enabled, will only keep
1838  * alphanumeric, _, space, ., -, @. After sanitizing, it passes the username,
1839  * raw username (the username in the parameter), and the value of $strict as
1840  * parameters for the {@see 'sanitize_user'} filter.