Created
October 12, 2015 13:43
-
-
Save JudeRosario/9f0c3a7164544244b525 to your computer and use it in GitHub Desktop.
Custom Upload Dirs
This file contains 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
/* | |
Plugin Name: Custom Upload Dirs | |
Description: Changes the upload directory to what we would like, instead of what WordPress likes. | |
Author: Mark | |
Version: 1.0 | |
Author URI: http://google.com | |
*/ | |
add_action( 'init', 'change_upload_dir' ) ; | |
function change_upload_dir() { | |
add_filter('upload_dir', 'ml_media_upload_dir'); | |
} | |
/** | |
* Changes the upload directory to what we would like, instead of what WordPress likes. | |
*/ | |
function ml_media_upload_dir($upload) { | |
global $user_ID; | |
$blog_id = get_current_blog_id(); | |
if ((int)$user_ID > 0) { | |
$upload['subdir'] = "/wp-content/uploads/sites/".$blog_id."/". get_the_time('Y'). "/" .get_the_time('m'); | |
$upload['path'] .= $upload['subdir']; | |
$upload['url'] .= $upload['subdir']; | |
} | |
return $upload; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"/". get_the_time('Y'). "/" .get_the_time('m') results in //