
Property changes on: src
___________________________________________________________________
Modified: svn:ignore
   - .wp-tests-version
.htaccess

   + .wp-tests-version
.htaccess
wp-config.php


Index: src/wp-includes/functions.wp-scripts.php
===================================================================
--- src/wp-includes/functions.wp-scripts.php	(revision 30534)
+++ src/wp-includes/functions.wp-scripts.php	(working copy)
@@ -67,11 +67,22 @@
  *                               to end of path as a query string. If no version is specified or set to false, a version
  *                               number is automatically added equal to current installed WordPress version.
  *                               If set to null, no version is added. Default 'false'. Accepts 'false', 'null', or 'string'.
- * @param bool        $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
- *                               Default 'false'. Accepts 'false' or 'true'.
+ * @param array       $args      Optional script arguments.
+ * - bool  - in_footer  - Whether to enqueue the script before </head> or before </body>. Default 'false'. Accepts 'false' or 'true'.
+ * - array - attributes - Array of script tag attributes. Default: array( 'type' => 'text/javascript' )
  */
-function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) {
+function wp_register_script( $handle, $src, $deps = array(), $ver = false, $args = array() ) {
 	global $wp_scripts;
+
+	// For back-compat. If it's not an array, convert to boolean.
+	$args = ! is_array( $args ) ? array( 'in_footer' => (bool) $args ) : $args;
+	$args = wp_parse_args( $args, array(
+		'in_footer'  => false,
+		'attributes' => array(),
+	) );
+
+	$attributes = wp_parse_args( $args['attributes'], array( 'type' => 'text/javascript' ) );
+
 	if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
 		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.' ),
@@ -79,9 +90,10 @@
 		$wp_scripts = new WP_Scripts();
 	}
 
-	$wp_scripts->add( $handle, $src, $deps, $ver );
-	if ( $in_footer )
+	$wp_scripts->add( $handle, $src, $deps, $ver, array( 'attributes' => $attributes ) );
+	if ( $args['in_footer'] ) {
 		$wp_scripts->add_data( $handle, 'group', 1 );
+	}
 }
 
 /**
@@ -189,11 +201,22 @@
  * @param string|bool $ver       Optional. String specifying the script version number, if it has one. This parameter
  *                               is used to ensure that the correct version is sent to the client regardless of caching,
  *                               and so should be included if a version number is available and makes sense for the script.
- * @param bool        $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
- *                               Default 'false'. Accepts 'false' or 'true'.
+ * @param array       $args      Optional script arguments.
+ * - bool  - in_footer  - Whether to enqueue the script before </head> or before </body>. Default 'false'. Accepts 'false' or 'true'.
+ * - array - attributes - Array of script tag attributes. Default: array( 'type' => 'text/javascript' )
  */
-function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
+function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $args = array() ) {
 	global $wp_scripts;
+
+	// For back-compat. If it's not an array, convert to boolean.
+	$args = ! is_array( $args ) ? array( 'in_footer' => (bool) $args ) : $args;
+	$args = wp_parse_args( $args, array(
+		'in_footer'  => false,
+		'attributes' => array(),
+	) );
+
+	$attributes = wp_parse_args( $args['attributes'], array( 'type' => 'text/javascript' ) );
+
 	if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) {
 		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.' ),
@@ -203,9 +226,10 @@
 
 	if ( $src ) {
 		$_handle = explode('?', $handle);
-		$wp_scripts->add( $_handle[0], $src, $deps, $ver );
-		if ( $in_footer )
+		$wp_scripts->add( $_handle[0], $src, $deps, $ver, array( 'attributes' => $attributes ) );
+		if ( $args['in_footer'] ) {
 			$wp_scripts->add_data( $_handle[0], 'group', 1 );
+		}
 	}
 	$wp_scripts->enqueue( $handle );
 }
Index: src/wp-includes/class.wp-scripts.php
===================================================================
--- src/wp-includes/class.wp-scripts.php	(revision 30534)
+++ src/wp-includes/class.wp-scripts.php	(working copy)
@@ -82,26 +82,30 @@
 	}
 
 	public function do_item( $handle, $group = false ) {
-		if ( !parent::do_item($handle) )
+		if ( !parent::do_item( $handle ) ) {
 			return false;
+		}
 
-		if ( 0 === $group && $this->groups[$handle] > 0 ) {
+		if ( 0 === $group && $this->groups[ $handle ] > 0 ) {
 			$this->in_footer[] = $handle;
 			return false;
 		}
 
-		if ( false === $group && in_array($handle, $this->in_footer, true) )
+		if ( false === $group && in_array($handle, $this->in_footer, true) ) {
 			$this->in_footer = array_diff( $this->in_footer, (array) $handle );
+		}
 
-		if ( null === $this->registered[$handle]->ver )
+		if ( null === $this->registered[ $handle ]->ver ) {
 			$ver = '';
-		else
-			$ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
+		} else {
+			$ver = $this->registered[ $handle ]->ver ? $this->registered[ $handle ]->ver : $this->default_version;
+		}
 
-		if ( isset($this->args[$handle]) )
-			$ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
+		if ( isset( $this->args[ $handle ] ) ) {
+			$ver = $ver ? $ver . '&amp;' . $this->args[ $handle ] : $this->args[ $handle ];
+		}
 
-		$src = $this->registered[$handle]->src;
+		$src = $this->registered[ $handle ]->src;
 
 		if ( $this->do_concat ) {
 			/**
@@ -113,7 +117,7 @@
 			 * @param string $handle Script handle.
 			 */
 			$srce = apply_filters( 'script_loader_src', $src, $handle );
-			if ( $this->in_default_dir($srce) ) {
+			if ( $this->in_default_dir( $srce ) ) {
 				$this->print_code .= $this->print_extra_script( $handle, false );
 				$this->concat .= "$handle,";
 				$this->concat_version .= "$handle$ver";
@@ -124,42 +128,92 @@
 			}
 		}
 
-		$this->print_extra_script( $handle );
-		if ( !preg_match('|^(https?:)?//|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
-			$src = $this->base_url . $src;
+ 		$this->print_extra_script( $handle );
+		if ( !preg_match( '|^(https?:)?//|', $src ) && ! ( $this->content_url && 0 === strpos( $src, $this->content_url ) ) ) {
+ 			$src = $this->base_url . $src;
+ 		}
+
+		if ( !empty( $ver ) ) {
+			$src = add_query_arg( 'ver', $ver, $src );
 		}
 
-		if ( !empty($ver) )
-			$src = add_query_arg('ver', $ver, $src);
-
 		/** This filter is documented in wp-includes/class.wp-scripts.php */
 		$src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) );
 
-		if ( ! $src )
+		if ( ! $src ) {
 			return true;
+		}
 
-		$tag = "<script type='text/javascript' src='$src'></script>\n";
 
-		/** 
+		$attributes = $this->get_script_attributes( $handle, $src );
+		$script_tag = "<script$attributes></script>\n";
+
+		/**
 		 * Filter the HTML script tag of an enqueued script.
 		 *
 		 * @since 4.1.0
 		 *
-		 * @param string $tag    The `<script>` tag for the enqueued script.
-		 * @param string $handle The script's registered handle.
-		 * @param string $src    The script's source URL.
+		 * @param string $script_tag The `<script>` tag for the enqueued script.
+		 * @param string $handle     The script's registered handle.
+		 * @param string $src        The script's source URL.
 		 */
-		$tag = apply_filters( 'script_loader_tag', $tag, $handle, $src );
+		$script_tag = apply_filters( 'script_loader_tag', $script_tag, $handle, $src );
 
 		if ( $this->do_concat ) {
-			$this->print_html .= $tag;
+			$this->print_html .= $script_tag;
 		} else {
-			echo $tag;
+			echo $script_tag;
 		}
 
-		return true;
+ 		return true;
 	}
 
+ 	/**
+	 * Concatenates attributes for the script tag
+	 *
+	 * @since  4.0.0
+	 *
+	 * @param  string $handle Script registered handle
+	 * @param  string $src    Script registered src
+	 *
+	 * @return string         Concatenated attributes string
+	 */
+	public function get_script_attributes( $handle, $src ) {
+
+		$default_attributes = array(
+			'type' => 'text/javascript',
+			'src'  => $src
+		);
+
+		$attributes = isset( $this->registered[ $handle ]->args['attributes'] )
+			? (array) $this->registered[ $handle ]->args['attributes']
+			: array();
+
+		$attributes = wp_parse_args( $attributes, $default_attributes );
+
+		/**
+		 * Filter the script loader attributes.
+		 *
+		 * @since 4.1.0
+		 *
+		 * @param array  $attributes Array of script tag attributes.
+		 * @param string $handle     Script handle.
+		 * @param string $src        Script loader source path.
+		 */
+		$attributes = apply_filters( 'script_loader_attributes', $attributes, $handle, $src );
+		// Ensure source is set
+		$attributes['src'] = isset( $attributes['src'] ) ? $attributes['src'] : $src;
+
+		$concat_attributes = '';
+		foreach ( $attributes as $attribute => $attribute_value ) {
+			if ( ! is_null( $attribute ) && ! is_null( $attribute_value ) ) {
+				$concat_attributes .= ' '. esc_attr( $attribute ) .'="'. esc_attr( $attribute_value ) .'"';
+			}
+		}
+
+		return $concat_attributes;
+	}
+
 	/**
 	 * Localizes a script
 	 *
