[wp-trac] [WordPress Trac] #24834: wp_enqueue_script passing null for $ver produces unexpected results

WordPress Trac noreply at wordpress.org
Mon Aug 5 13:29:22 UTC 2013


#24834: wp_enqueue_script passing null for $ver produces unexpected results
--------------------------+------------------------------
 Reporter:  bobbingwide   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  3.5.2
 Severity:  normal        |  Resolution:
 Keywords:  close         |
--------------------------+------------------------------

Comment (by bobbingwide):

 Replying to [comment:8 pauldewouters]:

 Some more information... I'll try to answer my own questions.

 1. In my experience when the value for the $handle parameter contains a
 query string ( such as when it matches the $src parameter, as in my
 example) then the API doesn't work as expected... the value of null for
 $ver is ignored.

 The patch I provided works for 3.5.2, 3.6 and 3.7-alpha-24954. But it may
 cause the special case logic to fail. The special case logic is documented
 in the codex as:

 As a special case, if the string contains a '?' character, the preceding
 part of the string refers to the registered handle, and the succeeding
 part is appended to the URL as a query string.

 2. As a workaround I have changed my code to use the PHP uniqid() function
 to provide the $handle
 {{{
 $src = "http://www.example.com/widget.js?token=something%3d%3d";
 wp_enqueue_script( uniqid(), $src, array( "jquery"), null );
 }}}

 Perhaps THIS should be documented in the codex? I wonder how many people
 are making use of the special case logic.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/24834#comment:9>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list