Opened 12 years ago
Closed 10 years ago
#23661 closed enhancement (wontfix)
get_theme_root_uri doesn't get correct theme root for themes in folders registered by register_theme_directory
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5.1 |
Component: | Themes | Keywords: | |
Focuses: | Cc: |
Description
get_theme_root_uri doesn't get correct theme root for themes in folders registered by register_theme_directory
Doing this in wp-config.php:
define('DKO_ABSPATH', __DIR__ . '/'); // just sets DKO_ABSPATH to the path of the wp-config.php file, which happens to be my web root
Doing this in an mu-plugin:
register_theme_directory( DKO_ABSPATH . 'themes/' ); // add the webroot/themes folder as a theme directory, trailing slash required (ideally trailingslashit in the register_theme_directory function)
Yields this for get_stylesheet_uri():
http://www.davidosomething.dev/wp/Users/dotrakoun/Sites/openshift/main/php/themes/2013-davidosomething/style.css?ver=3.5.1
i.e. the full path is returned instead of the uri.
Think the case matching in theme.php lines 477-490 (get_theme_root_uri) doesn't cover paths registered using register_theme_directory but outside of ABSPATH, site_url, and content_url
Change History (3)
Note: See
TracTickets for help on using
tickets.
There's a comment in get_theme_root_uri() — "Absolute path. Make an educated guess. YMMV -- but note the filter below." (As in Your Mileage May Vary.) This isn't a bug, it's a known thing. There's no way for us to know the URL of such a theme directory, when it is outside all other known directories.
One thing we can do — something I've not yet bothered to do, but have thought about it — is add a second, optional URL argument to register_theme_directory().