Opened 17 years ago
Closed 17 years ago
#6762 closed enhancement (fixed)
Would be useful for wp_upload_dir to be able to return without date sub directories
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
I'm writing a plugin which needs to cache certain web readable files (CSS & JS, etc). The obvious writable directory is wp-content/uploads/, however to work out the filesystem path and web path for this dir is not easy, because wp_upload_dir always returns with the date based subdirs. I could remove the subdirs from the paths afterwards, but this seems needlessly hard.
The attached patch adds an additional argument to wp_upload_dir which requires the function to return the dirs without the date subdirs. The argument defaults to false to maintain backwards compatibility.
Attachments (2)
Change History (5)
#1
follow-up:
↓ 2
@
17 years ago
A Better method would be to simply return 'base_dir' in the $uploads array rather than turning it on/off via a seperate arguement. (See patch)
I needed exactly the same thing in another plugin, but instead i used this in combination with wp_upload_dir():
$uploads_folder = defined('UPLOADS') ? UPLOADS : (trim(get_option('upload_path')) === '' ? 'wp-content/uploads' : get_option('upload_path'));
Another way now that i look at the code again, would be to simply to trim $subdir off the end of the $dir and $url return vals.. But its ugly and could cause problems if the subdir is empty.
Amend upload_no_subdirs to allow it to return without date sub directories by passing an argument