Make WordPress Core


Ignore:
Timestamp:
01/09/2007 10:53:14 PM (15 years ago)
Author:
ryan
Message:

sanitize_file_name(). fixes #3382 #3554

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r4672 r4710  
    287287
    288288    return $string;
     289}
     290
     291function sanitize_file_name( $name ) { // Like sanitize_title, but with periods
     292    $name = strtolower( $name );
     293    $name = preg_replace('/&.+?;/', '', $name); // kill entities
     294    $name = str_replace( '_', '-', $name );
     295    $name = preg_replace('/[^a-z0-9\s-.]/', '', $name);
     296    $name = preg_replace('/\s+/', '-', $name);
     297    $name = preg_replace('|-+|', '-', $name);
     298    $name = trim($name, '-');
     299    return $name;
    289300}
    290301
Note: See TracChangeset for help on using the changeset viewer.