'content_url' (and other *_url() functions) not filterable
|Reported by:||krudolph||Owned by:||anonymous|
A call to content_url invariably returns the whole path, including the "http[s]:" prefix and the server name. This may not be desired. In fact, I've written a filter function for option_siteurl and option_home to strip all local URIs off their server name, i.e. "http://example.com/blog/x" becomes "/blog/x".
However, since content_url isn't pluggable, my filter function doesn't catch all URIs (especially not theme-related URIs such as the stylesheet link). Actually, content_url uses WP_CONTENT_URL, which, in turn, calls get_option('siteurl'), which, in turn, is pluggable. Unfortunately, this call is made before filter functions get registered because WP_CONTENT_URL is a global constant.
I propose two possible solutions:
- Make WP_CONTENT_URL a function. Since the constant is for internal use only, the scope of this change should be local. This solution would be preferred because it means that one hook would suffice to manipulate all local URIs created by WordPress.
- Make content_url pluggable.
Change History (11)
- Summary changed from 'content_url' not pluggable to 'content_url' not filterable
comment:8 coffee2code — 5 years ago
- Cc coffee2code added
- Keywords has-patch added
- Milestone changed from Future Release to 2.8
- Summary changed from 'content_url' not filterable to 'content_url' (and other *_url() functions) not filterable