Opened 12 years ago
Closed 12 years ago
#23853 closed defect (bug) (duplicate)
wp_enqueue_style does not properly handle URLs with a colon in the query parameters
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
I have to call add_query_arg with the protocol:
add_query_arg( $query_args, "http://fonts.googleapis.com/css" )
However, I'd prefer to leave it off and believe that's generally the better practice:
add_query_arg( $query_args, "//fonts.googleapis.com/css" )
Change History (10)
#2
@
12 years ago
- Summary changed from Add support for relative URLs in add_query_arg to Add support for relative URLs in wp_enqueue_style
You're right. Sorry, I misreported this bug originally. It's wp_enqueue_style that has a problem with styles that do not include a protocol.
I'm forced to do this:
wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null );
When I would like to do this:
wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "//fonts.googleapis.com/css" ), array(), null );
#3
@
12 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Support for relative urls in wp_enqueue_*()
functions was added in r21166 for 3.5.
We define a protocol in Twenty Twelve for backwards compatibility with previous versions of WordPress.
#5
@
12 years ago
Hmm. I have 3.5.1 and it doesn't work for me when I try to custom edit the template. Maybe it's coming in a newer version of 3.5? In any case, thanks for the help.
#6
@
12 years ago
- Resolution changed from invalid to duplicate
Duplicate of #21974.
The issue here is not a relative URL by itself, it's a combination of a relative URL and a colon.
#7
@
12 years ago
Huh? What are you talking about? There's no colon in:
wp_enqueue_style( 'twentytwelve-fonts', add_query_arg( $query_args, "fonts.googleapis.com/css" ), array(), null );
Have I misunderstood?
#8
@
12 years ago
What is the value of $query_args
?
If you have copied it from Twenty Twelve, the family
attribute has a colon in it:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-content/themes/twentytwelve/functions.php#L135
#9
@
12 years ago
- Resolution duplicate deleted
- Status changed from closed to reopened
- Summary changed from Add support for relative URLs in wp_enqueue_style to wp_enqueue_style does not properly handle URLs with a colon in the query parameters
Ah, yes, I see. It should be able to handle that though! This is definitely a bug. Though obviously the title I reported it with is not accurate, so I have renamed it.
add_query_arg()
does not force a protocol. In my tests it returned the above mentioned example just fine.