Last active
December 14, 2016 19:46
-
-
Save mmilosheski/5eaa13a1b7e1b821ac772fe7d3a2747e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*mile test */ | |
function make_filename_hash($filename) { | |
if( isset($_REQUEST['post_id']) ) { | |
$post_id = (int)$_REQUEST['post_id']; | |
}else{ | |
$post_id=0; | |
} | |
$info = pathinfo($filename); | |
$ext = empty($info['extension']) ? '' : '.' . $info['extension']; | |
$name = "imported"; | |
if($post_id>0){ | |
return get_the_title($post_id)."_".$name . $ext; | |
}else{ | |
return $name . $ext; | |
} | |
} | |
add_filter('sanitize_file_name', 'make_filename_hash', 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment