| <?php |
| |
| add_filter('sanitize_file_name', 'hwk_sanitize_file_name'); |
| function hwk_sanitize_file_name($input){ |
| $path = pathinfo($input); |
| $extension = (isset($path['extension']) && !empty($path['extension'])) ? $path['extension'] : ''; |
| $file = (!empty($extension)) ? preg_replace('/.' . $extension . '$/', '', $input) : $input; |
| |
| return sanitize_title(str_replace('_', '–', $file)) . ((!empty($extension)) ? '.' . $extension : ''); |
| } |