function get_current_post_type() {
global $post, $typenow, $current_screen;
if ( $post && $post->post_type )
return $post->post_type;
elseif( $typenow )
return $typenow;
elseif( $current_screen && $current_screen->post_type )
return $current_screen->post_type;
elseif( isset( $_REQUEST['post_type'] ) )
return sanitize_key( $_REQUEST['post_type'] );
return null;
}
function custom_post_type_upload_directory( $args ) {
if( 'rsg_download' == get_current_post_type() ) {
$mydir = '/rsg-uploads';
$args['path'] = $args['basedir'] . $mydir;
$args['url'] = $args['baseurl'] . $mydir;
}
return $args;
}
add_filter( 'upload_dir', 'custom_post_type_upload_directory' );