Make WordPress Core

Opened 11 years ago

Closed 10 years ago

#27068 closed defect (bug) (worksforme)

JS var thickboxL10n is added twice

Reported by: finalwebsites's profile finalwebsites Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.1
Component: Script Loader Keywords: reporter-feedback
Focuses: Cc:

Description

Hi,

If you enable thickbox using

wp_enqueue_script('thickbox');
wp_enqueue_style('thickbox');

Wordpress inserts the text/labels in your blog's language into the footer like:

var thickboxL10n = {"next":"Volgende >","prev":"< Vorige","image":"Afbeelding","of":"van","close":"Sluiten","noiframes":"Deze eigenschap vereist inline frames. Je hebt inline frames uitgeschakeld of je browser ondersteunt dit niet.","loadingAnimation":"http:\/\/www.domein.nl\/wp-includes\/js\/thickbox\/loadingAnimation.gif"};

Since version 3.8 this code is added twice into the footer.
Anything else related to thickbox is okay

Change History (3)

#1 @finalwebsites
11 years ago

  • Component changed from I18N to Script Loader
  • Keywords needs-testing added

I found the problem located in wp-includes/script-loader.php.

The localization function need be called before the thickbox script is added.
If you switch position the problem is solved:

	did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array(
			'next' => __('Next &gt;'),
			'prev' => __('&lt; Prev'),
			'image' => __('Image'),
			'of' => __('of'),
			'close' => __('Close'),
			'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'),
			'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'),
	) );
	$scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 );

#2 @SergeyBiryukov
11 years ago

  • Keywords reporter-feedback added; needs-testing removed

Could not reproduce on a clean install, thickboxL10n is only added once for me.

Could you check if the issue still exists with all plugins disabled and a default theme (Twenty Fourteen or Twenty Thirteen) activated? Make sure you use the correct action for wp_enqueue_script(), i.e. wp_enqueue_scripts or admin_enqueue_scripts.

Swapping $scripts->localize() with $scripts->add() here seems weird and would be inconsistent with localizing other scripts.

#3 @wonderboymusic
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.