Index: src/wp-includes/class.wp-scripts.php
===================================================================
--- src/wp-includes/class.wp-scripts.php	(revision 34451)
+++ src/wp-includes/class.wp-scripts.php	(working copy)
@@ -208,12 +208,13 @@
 	 *
 	 * @param string $handle
 	 * @param string $object_name
-	 * @param array $l10n
+	 * @param array|scalar $l10n
 	 * @return bool
 	 */
 	public function localize( $handle, $object_name, $l10n ) {
-		if ( $handle === 'jquery' )
+		if ( $handle === 'jquery' ) {
 			$handle = 'jquery-core';
+		}

 		if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present
 			$after = $l10n['l10n_print_after'];
@@ -220,11 +221,16 @@
 			unset($l10n['l10n_print_after']);
 		}

-		foreach ( (array) $l10n as $key => $value ) {
-			if ( !is_scalar($value) )
-				continue;
+		if ( is_scalar( $l10n ) ) {
+			$l10n = html_entity_decode( (string) $l10n, ENT_QUOTES, 'UTF-8');
+		} else {
+			foreach ( (array) $l10n as $key => $value ) {
+				if ( ! is_scalar( $value ) ) {
+					continue;
+				}

-			$l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
+				$l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
+			}
 		}

 		$script = "var $object_name = " . wp_json_encode( $l10n ) . ';';
Index: tests/phpunit/tests/dependencies/scripts.php
===================================================================
--- tests/phpunit/tests/dependencies/scripts.php	(revision 34451)
+++ tests/phpunit/tests/dependencies/scripts.php	(working copy)
@@ -156,6 +156,27 @@
 		$this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
 	}

+	/**
+	 * Testing `wp_localize_script` with scalar and array values.
+	 * @ticket 29722
+	 */
+	function test_wp_localize_script_with_non_array() {
+		// Enqueue & localize variables
+		wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null );
+		wp_localize_script( 'test-conditional-with-data', 'data', true );
+		wp_localize_script( 'test-conditional-with-data', 'dataArray', array( 'var' => 'string' ) );
+		$expected = "<script type='text/javascript'>\n/* <![CDATA[ */\n";
+		$expected.= "var data = \"1\";\n";
+		$expected.= "var dataArray = {\"var\":\"string\"};\n";
+		$expected.= "/* ]]> */\n";
+		$expected.= "</script>\n<script type='text/javascript' src='http://example.com'></script>\n";
+
+		$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
+
+		// No scripts left to print
+		$this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
+	}
+
     /**
      * Testing 'wp_register_script' return boolean success/failure value.
      *
