Opened 13 years ago
Closed 11 years ago
#19200 closed enhancement (duplicate)
Introduce themes_url() and upload_url()
Reported by: | ramiy | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Template | Keywords: | has-patch |
Focuses: | Cc: |
Description
WordPress has some very usefull url tempalate tags in the wp-includes/link-template.php file, functions like:
home_url() => ../ site_url() => ../ admin_url() => ../wp-admin/ includes_url() => ../wp-includes/ content_url() => ../wp-content/ plugins_url() => ../wp-content/plugins/
we need 2 more functions:
themes_url() => ../wp-content/themes/ upload_url() => ../wp-content/upload/
they will make developers life easier.
Attachments (3)
Change History (24)
#2
in reply to:
↑ 1
@
13 years ago
- Cc mikeschinkel@… added
Replying to scribu:
We already have wp_upload_dir().
wp_upload_dir()
returns an array and since PHP does not allow indexing the return values of a function -- i.e. since this is not valid in PHP: wp_upload_dir()['baseurl']
-- it would be really nice to have an upload_url()
function, for consistency with the others if nothing else.
#3
@
13 years ago
function upload_url() { $upload_dir = wp_upload_dir(); return $upload_dir['baseurl']; }
#5
@
13 years ago
I don't think this is check is appropriate here:
if ( 0 === strpos($url, 'http') && is_ssl() ) $url = str_replace( 'http://', 'https://', $url );
Instead, we should make wp_upload_dir() use get_site_url().
Also, you have some missing whitespace around function calls.
#6
@
13 years ago
Actually, the problem is that the uploads url can be an entirely different domain, which is not guaranteed to have SSL.
In any case, uploads_url() should just use what wp_upload_dir() returns, without modifying the protocol.
#8
@
13 years ago
- Keywords commit added
- Milestone changed from Awaiting Review to Future Release
19200b.patch looks good.
#10
@
13 years ago
- Keywords commit removed
Wait a second. Why should upload_url() return 'baseurl', rather than 'url'?
#11
@
13 years ago
The 'baseurl' will return <http://example.com/wp-content/uploads>
and the 'url' will return <http://example.com/wp-content/uploads/2012/01>
We want to return the "upload" directory (=baseurl).
#12
@
13 years ago
And if someone doesn't agree, are we going to introduce an upload_base_url() helper as well? What about upload paths?
#14
follow-up:
↓ 15
@
13 years ago
No, because there's only one plugins directory, whereas you have a base uploads directory and a current uploads directory (uploads/2012/01).
#15
in reply to:
↑ 14
@
13 years ago
Same with plugins/themes,
we have a base directory <http://example.com/wp-content/plugins>
and a current plugin dirctory <http://example.com/wp-content/plugins/some-plugin>
#16
@
13 years ago
Another thing - if we will use upload_base_url() and upload_url(), the function names won't be consistant with the functions mentioned above in the introductory paragraph.
We already have wp_upload_dir().