/**
 * Makes file name safe to use
 *
 * @param   string  $file  The name of the file [not full path]
 *
 * @return  string  The sanitised string
 *
 * @since   1.7.0
 */
public static function makeSafe($file)
{
    // Remove any trailing dots, as those aren't ever valid file names.
    $file = rtrim($file, '.');
    // Try transliterating the file name using the native php function
    if (function_exists('transliterator_transliterate') && function_exists('iconv')) {
        // Using iconv to ignore characters that can't be transliterated
        $file = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", transliterator_transliterate('Any-Latin; Latin-ASCII', $file));
    }
    $regex = array('#(\\.){2,}#', '#[^A-Za-z0-9\\.\\_\\- ]#', '#^\\.#');
    return trim(preg_replace($regex, '', $file));
}