Skip to content

Instantly share code, notes, and snippets.

@sunny
Forked from LanF3usT/sunnytize.php
Created December 7, 2011 10:14
Show Gist options
  • Save sunny/1442272 to your computer and use it in GitHub Desktop.
Save sunny/1442272 to your computer and use it in GitHub Desktop.
WordPress plugin that removes evil characters in file names
<?php
/*
Plugin Name: Sunnytize
Plugin URI:
Description: A better file name sanitizer
Version: 2.0
Author: Sunny Ripert, Bastien Maillard, Guillaume Morisseau
Author URI: http://sunfox.org
*/
function sunnytize($name, $name_raw = "") {
return preg_replace('/[^a-z0-9-_\/]+/', '', $name);
}
add_filter('sanitize_file_name', 'sunnytize');
add_filter('editable_slug', 'sunnytize');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment