Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#23853 closed defect (bug) (duplicate)

wp_enqueue_style does not properly handle URLs with a colon in the query parameters

Reported by: chengas123 Owned by:
Priority: normal Milestone:
Component: General Version:
Severity: normal Keywords:
Cc: Focuses:

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)

#1 @obenland
14 years ago

  • Keywords close added

add_query_arg() does not force a protocol. In my tests it returned the above mentioned example just fine.

#2 @chengas123
14 years ago

  • Summary Add support for relative URLs in add_query_arg → 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 @obenland
14 years ago

  • Milestone Awaiting Review
  • Resolution → invalid
  • Status new → 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.

#4 @obenland
14 years ago

  • Keywords close removed

#5 @chengas123
14 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 @SergeyBiryukov
14 years ago

  • Resolution invalid → 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 @chengas123
14 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 @SergeyBiryukov
14 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 @chengas123
14 years ago

  • Resolution duplicate
  • Status closed → reopened
  • Summary Add support for relative URLs in wp_enqueue_style → 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.

#10 @chengas123
14 years ago

  • Resolution → duplicate
  • Status reopened → closed

Duplicate of #21974.

Sorry. I missed that you marked this as a duplicate

Note: See TracTickets for help on using tickets.