From 6bcb24a344ef4fdd1b783a4eabd943d978649783 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 26 Jun 2014 01:38:15 +0000 Subject: [PATCH] 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 --- wp-includes/functions.wp-scripts.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wp-includes/functions.wp-scripts.php b/wp-includes/functions.wp-scripts.php index ea719df3f9..f2cbdbf915 100644 --- a/wp-includes/functions.wp-scripts.php +++ b/wp-includes/functions.wp-scripts.php @@ -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.' ), 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ), '3.3' ); - - return false; + $wp_scripts = new WP_Scripts(); } return $wp_scripts->localize( $handle, $object_name, $l10n );