// This Works -> Filters are utilized
add_action( 'current_screen', operate(){
$kind = get_current_screen()->post_type;
if(is_admin()){ // "true"
add_filter('upload_dir', operate($uploads){
$uploads['path'] = $uploads['basedir'] . "/ordenanzas";
$uploads['url'] = $uploads['baseurl'] . "/ordenanzas";
return $uploads;
});
add_filter('wp_handle_upload_prefilter', operate($file){
$file['name'] = "ORD-" . $file['name'];
return $file;
});
}
});
// This Would not Works -> Filters aren’t utilized
add_action( 'current_screen', operate(){
$kind = get_current_screen()->post_type;
if(is_admin() && $kind == 'ordenanzas'){ // when is "true" filters don't work
add_filter('upload_dir', operate($uploads){
$uploads['path'] = $uploads['basedir'] . "/ordenanzas";
$uploads['url'] = $uploads['baseurl'] . "/ordenanzas";
return $uploads;
});
add_filter('wp_handle_upload_prefilter', operate($file){
$file['name'] = "ORD-" . $file['name'];
return $file;
});
}
});