[wp-trac] [WordPress Trac] #59539: wp_register_style and wp_register_script adds ver incorrectly

WordPress Trac noreply at wordpress.org
Wed Oct 4 11:57:47 UTC 2023


#59539: wp_register_style and wp_register_script adds ver incorrectly
---------------------------+-----------------------------
 Reporter:  forcesail      |      Owner:  (none)
     Type:  defect (bug)   |     Status:  assigned
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Script Loader  |    Version:  6.3.1
 Severity:  major          |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 Hello,

 I'm sorry to report but it seems that function wp_enqueue_style adds ver
 incorrectly in case of existence some url parameters in src.

 **For example:**

 **Style example:**

 {{{#!php
 <?php
 add_action( 'wp_enqueue_scripts', function() {
 wp_enqueue_style( 'my-custom-font',
 'https://fonts.googleapis.com/css?family=Roboto+Condensed');
 });
 }}}


 adds:

 {{{
 <link rel='stylesheet' id='my-custom-font-css'
 href='https://fonts.googleapis.com/css?family=Roboto+Condensed&ver=6.3.1'
 type='text/css' media='all' />
 }}}


 (you see '&' instead of just '&')

 **Script example (from contact-form-7):**

 {{{#!php
 <?php
 wp_register_script( 'google-recaptcha',
     add_query_arg(
         array(
             'render' => $service->get_sitekey(),
         ),
         $url
     ),
     array(),
     '3.0',
     true
 );
 }}}

 adds:

 {{{
 <script type='text/javascript'
 src='https://www.google.com/recaptcha/api.js?render=6LfrGhQlAAAAAD6sCXSbihhcAwBHfR25-huvzmtQ&ver=3.0'
 id='google-recaptcha-js'></script>
 }}}


 (again, you see ‘&‘ instead of just ‘&’)


 You can find these issues on: https://forcesail.ru/

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59539>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list