Make WordPress Core

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: chengas123's profile chengas123 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)

#1 @obenland
12 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
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 @obenland
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.

#4 @obenland
12 years ago

  • Keywords close removed

#5 @chengas123
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 @SergeyBiryukov
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 @chengas123
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 @SergeyBiryukov
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 @chengas123
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.

#10 @chengas123
12 years ago

  • Resolution set to duplicate
  • Status changed from reopened to closed

Duplicate of #21974.

Sorry. I missed that you marked this as a duplicate

Note: See TracTickets for help on using tickets.