+ }
+
+ $output = trim( implode( "\n", $output ), "\n" );
+
+ if ( $echo ) {
+ printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );
+ }
+
+ return $output;
+ }
+
+ /**
+ * Localizes a script, only if the script has already been added.
+ *
+ * @since 2.1.0
+ * @access public
+ *
+ * @param string $handle
+ * @param string $object_name
+ * @param array $l10n
+ * @return bool
+ */
+ public function localize( $handle, $object_name, $l10n ) {
+ 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'];
+ unset($l10n['l10n_print_after']);
+ }
+
+ foreach ( (array) $l10n as $key => $value ) {
+ if ( !is_scalar($value) )
+ continue;
+
+ $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
+ }
+
+ $script = "var $object_name = " . wp_json_encode( $l10n ) . ';';
+
+ if ( !empty($after) )
+ $script .= "\n$after;";
+
+ $data = $this->get_data( $handle, 'data' );
+
+ if ( !empty( $data ) )
+ $script = "$data\n$script";
+
+ return $this->add_data( $handle, 'data', $script );
+ }
+
+ /**
+ * Sets handle group.
+ *
+ * @since 2.8.0
+ * @access public
+ *
+ * @see WP_Dependencies::set_group()
+ *
+ * @param string $handle Name of the item. Should be unique.
+ * @param bool $recursion Internal flag that calling function was called recursively.
+ * @param int|false $group Optional. Group level: (int) level, (false) no groups. Default false.
+ * @return bool Not already in the group or a lower group
+ */
+ public function set_group( $handle, $recursion, $group = false ) {
+ if ( isset( $this->registered[$handle]->args ) && $this->registered[$handle]->args === 1 )
+ $grp = 1;
+ else
+ $grp = (int) $this->get_data( $handle, 'group' );
+
+ if ( false !== $group && $grp > $group )
+ $grp = $group;
+
+ return parent::set_group( $handle, $recursion, $grp );