In wp_localize_script(), instantiate the $wp_scripts global instead of bailing when it is called before wp_enqueue_scripts. This allows wp_enqueue_media() to be called on the front end with no JS errors.

Props ericlewis.
Fixes #24724.

Built from https://develop.svn.wordpress.org/trunk@28840


git-svn-id: http://core.svn.wordpress.org/trunk@28644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-06-26 01:38:15 +00:00
parent 6ab2f15b0b
commit 6bcb24a344

View File

@ -116,8 +116,7 @@ function wp_localize_script( $handle, $object_name, $l10n ) {
if ( ! did_action( 'init' ) )
_doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
'<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
return false;
$wp_scripts = new WP_Scripts();
}
return $wp_scripts->localize( $handle, $object_name, $l10n );