[wp-trac] [WordPress Trac] #24834: wp_enqueue_script passing null for $ver produces unexpected results
WordPress Trac
noreply at wordpress.org
Mon Aug 5 17:55:36 UTC 2013
#24834: wp_enqueue_script passing null for $ver produces unexpected results
--------------------------+-----------------------
Reporter: bobbingwide | Owner:
Type: defect (bug) | Status: reopened
Priority: normal | Milestone:
Component: General | Version: 3.5.2
Severity: normal | Resolution:
Keywords: close |
--------------------------+-----------------------
Changes (by bobbingwide):
* status: closed => reopened
* resolution: invalid =>
Comment:
Replying to [comment:10 nacin]:
> Why are you using a uniqid() for $handle?
See my response to [comment:8 helen]
> This is a case of doing it wrong.
I have to "do it wrong" in order to get it to work.
Using uniqid() ensures that each instance will get enqueued.
Would you prefer it if I coded it like this?
{{{
// I'm not telling you how I set $src_uniq but uniqid() might be one
method!
// or this may be another $src_uniq = str_replace( array( "?" ), "-", $src
);
wp_register_script( $src_uniq, $src, array( "jquery"), null );
wp_enqueue_script( $src_uniq );
}}}
Using this technique allows me to specify the query parameters in $src AND
pass a null value for $ver.
If I try to specify the query parameters in the $handle and use $ver=null
then it won't work
{{{
wp_enqueue_script( "fladdle2?parm=ploing%2d%2D", "http://qw/bw/jq.js",
array( "jquery"), null );
}}}
gives
{{{
<script type='text/javascript'
src='http://qw/bw/jq.js?ver=parm=ploing%2d%2D'></script>
}}}
This is the restriction that Helen has documented.
For the record, results you may expect to get with non-null values for
$ver are:
{{{
wp_enqueue_script( "fladdle3?parm=ploing%3d%3D", "http://qw/bw/jq.js",
array( "jquery"), false );
}}}
gives
{{{
<script type='text/javascript'
src='http://qw/bw/jq.js?ver=3.7-alpha-24954&parm=ploing%3d%3D'></script>
}}}
which seems OK. Note: No conversion of %3d to %3D
AND
{{{
wp_enqueue_script( "fladdle4?parm=ploing%4d%4D",
"http://qw/bw/jq.js?farm=floing%4d%4D", array( "jquery") );
}}}
gives
{{{
<script type='text/javascript'
src='http://qw/bw/jq.js?farm=floingMM&ver=3.7-alpha-24954&parm=ploing%4d%4D'></script>
}}}
where the query parms on the $src are parsed and re-created by
add_query_arg(),
which may produce different results from expected.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24834#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list