WordPress.org

Make WordPress Core

#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:
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)

comment:1 obenland13 months ago

  • Keywords close added

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

comment:2 chengas12313 months 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 );

comment:3 obenland13 months 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.

comment:4 obenland13 months ago

  • Keywords close removed

comment:5 chengas12313 months 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.

comment:6 SergeyBiryukov12 months 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.

comment:7 chengas12312 months 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?

comment:8 SergeyBiryukov12 months 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

comment:9 chengas12312 months 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.

comment:10 chengas12312 months 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.