Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#23502 closed defect (bug) (duplicate)

wp_register_script results in the appearance of & HTML entity

Reported by: computerslayer1's profile computerslayer1 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description

When using the wp_register_script function in the functions.php file to override the jquery.js script, the HTML erroneously converts the ampersand for the cache busting query string into the HTML entity.

/**
 * Override jquery
 */
function mytheme_init(){
	if ( !is_admin() ){
		wp_deregister_script('jquery');
		wp_register_script('jquery', get_template_directory_uri().'/js/jquery.js?183', array(), '1');
	} 
}
add_action('init', 'mytheme_init');

When wp_head() is in the header.php file, it results in this HTML:

<script type='text/javascript' src='http://ymca.saratogaregionalymca.org/content/themes/mytheme/js/jquery.js?183&#038;ver=1'></script>

This appears to be an old bug, as there is a forum thread over a year old about the issue: http://wordpress.org/support/topic/wp_register_script-char-is-converted-to?replies=2

Change History (4)

#1 @ocean90
12 years ago

  • Keywords close added; needs-patch needs-testing removed

#2 @SergeyBiryukov
12 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #9243.

#3 @SergeyBiryukov
12 years ago

  • Version 3.5.1 deleted

#4 @TobiasBg
12 years ago

On a side note: And please, please, please, please, please don't override jQuery with your own version! This is basically never necessary! And you will easily break other plugins's JS code.

Note: See TracTickets for help on using tickets.