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.


git-svn-id: https://develop.svn.wordpress.org/trunk@28840 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2014-06-26 01:37:13 +00:00
parent 0105f41c77
commit f106f80768
1 changed files with 1 additions and 2 deletions

View File

@ -116,8 +116,7 @@ function wp_localize_script( $handle, $object_name, $l10n ) {
if ( ! did_action( 'init' ) ) 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.' ), _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' ); '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' );
$wp_scripts = new WP_Scripts();
return false;
} }
return $wp_scripts->localize( $handle, $object_name, $l10n ); return $wp_scripts->localize( $handle, $object_name, $l10n );