diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
old mode 100644
new mode 100755
index 03ff4e7..72b3c2e
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -1900,19 +1900,20 @@ function get_submit_button( $text = '', $type = 'primary large', $name = 'submit
 
 	$attributes = '';
 	if ( is_array( $other_attributes ) ) {
-		foreach ( $other_attributes as $attribute => $value ) {
-			$attributes .= $attribute . '="' . esc_attr( $value ) . '" '; // Trailing space is important
-		}
+		$attributes = html_attributes( $other_attributes );
 	} elseif ( ! empty( $other_attributes ) ) { // Attributes provided as a string
-		$attributes = $other_attributes;
+		$attributes = ' ' . $other_attributes;
 	}
 
-	// Don't output empty name and id attributes.
-	$name_attr = $name ? ' name="' . esc_attr( $name ) . '"' : '';
-	$id_attr = $id ? ' id="' . esc_attr( $id ) . '"' : '';
+	$atts = array(
+		'type'  => 'submit',
+		'name'  => $name,
+		'id'    => $id,
+		'class' => $class,
+		'value' => $text,
+	);
 
-	$button = '<input type="submit"' . $name_attr . $id_attr . ' class="' . esc_attr( $class );
-	$button	.= '" value="' . esc_attr( $text ) . '" ' . $attributes . ' />';
+	$button = '<input' . html_attributes( $atts ) . $attributes . ' />';
 
 	if ( $wrap ) {
 		$button = '<p class="submit">' . $button . '</p>';
diff --git a/wp-includes/class-wp-customize-control.php b/wp-includes/class-wp-customize-control.php
index bf17fb2..22d8e8d 100644
--- a/wp-includes/class-wp-customize-control.php
+++ b/wp-includes/class-wp-customize-control.php
@@ -386,9 +386,7 @@ class WP_Customize_Control {
 	 * @access public
 	 */
 	public function input_attrs() {
-		foreach( $this->input_attrs as $attr => $value ) {
-			echo $attr . '="' . esc_attr( $value ) . '" ';
-		}
+		echo html_attributes( $this->input_attrs );
 	}
 
 	/**
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
old mode 100644
new mode 100755
index 1f6e3b1..36a3008
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -4845,3 +4845,36 @@ function wp_delete_file( $file ) {
 		@unlink( $delete );
 	}
 }
+
+/**
+ * Get HTML attributes.
+ *
+ * @since 4.3.0
+ *
+ * @param array $attrs 
+ * @return string 
+ */
+function html_attributes( $attrs ) {
+	if ( ! is_array( $attrs ) ) {
+		return false;
+	}
+	
+	$html = array();
+	
+	foreach ( $attrs as $attr => $value ) {
+		if ( is_numeric( $attr ) ) {
+			$attr = $value;
+		}
+		
+		if ( ! empty( $value ) ) {
+			if ( in_array( $attr, array( 'href', 'src' ) ) ) {
+				$value = esc_url( $value );
+			} else {
+				$value = esc_attr( $value );
+			}
+			$html[] = $attr . '="' . $value . '"';
+		}
+	}
+
+	return count( $html ) > 0 ? ' ' . implode( ' ', $html ) : '';
+}
diff --git a/wp-includes/media.php b/wp-includes/media.php
old mode 100644
new mode 100755
index b69b328..b45625e
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -758,12 +758,8 @@ function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = fa
 		 * @param string|array $size       Requested size.
 		 */
 		$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );
-		$attr = array_map( 'esc_attr', $attr );
-		$html = rtrim("<img $hwstring");
-		foreach ( $attr as $name => $value ) {
-			$html .= " $name=" . '"' . $value . '"';
-		}
-		$html .= ' />';
+
+		$html = '<img ' . rtrim( $hwstring ) . html_attributes( $attr ) . ' />';
 	}
 
 	return $html;
@@ -879,13 +875,14 @@ function img_caption_shortcode( $attr, $content = null ) {
 	if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
 		return $content;
 
-	if ( ! empty( $atts['id'] ) )
-		$atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" ';
-
-	$class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] );
-
+	$html_atts = array(
+		'id'    => $atts['id'],
+		'style' => 'width: ' . (int) $atts['width'] . 'px;',
+		'class' => trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] )
+	);
+	
 	if ( current_theme_supports( 'html5', 'caption' ) ) {
-		return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">'
+		return '<figure' . html_attributes( $html_atts ) . '>' 
 		. do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>';
 	}
 
@@ -908,11 +905,11 @@ function img_caption_shortcode( $attr, $content = null ) {
 	 */
 	$caption_width = apply_filters( 'img_caption_shortcode_width', $caption_width, $atts, $content );
 
-	$style = '';
-	if ( $caption_width )
-		$style = 'style="width: ' . (int) $caption_width . 'px" ';
-
-	return '<div ' . $atts['id'] . $style . 'class="' . esc_attr( $class ) . '">'
+	if ( $caption_width ) {
+		$html_atts['style'] = 'width: ' . (int) $caption_width . 'px;';
+	}
+	
+	return '<div' . html_attributes( $html_atts ) . '>'
 	. do_shortcode( $content ) . '<p class="wp-caption-text">' . $atts['caption'] . '</p></div>';
 }
 
@@ -1641,17 +1638,12 @@ function wp_audio_shortcode( $attr, $content = '' ) {
 		}
 	}
 
-	$attr_strings = array();
-	foreach ( $html_atts as $k => $v ) {
-		$attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
-	}
-
 	$html = '';
 	if ( 'mediaelement' === $library && 1 === $instance ) {
 		$html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n";
 	}
-	$html .= sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) );
-
+	$html .= '<audio controls="controls"' . html_attributes( $html_atts ) . '>';
+	
 	$fileurl = '';
 	$source = '<source type="%s" src="%s" />';
 	foreach ( $default_types as $fallback ) {
@@ -1876,16 +1868,11 @@ function wp_video_shortcode( $attr, $content = '' ) {
 		}
 	}
 
-	$attr_strings = array();
-	foreach ( $html_atts as $k => $v ) {
-		$attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
-	}
-
 	$html = '';
 	if ( 'mediaelement' === $library && 1 === $instance ) {
 		$html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
 	}
-	$html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) );
+	$html .= '<video controls="controls"' . html_attributes( $html_atts ) . '>';
 
 	$fileurl = '';
 	$source = '<source type="%s" src="%s" />';
diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php
old mode 100644
new mode 100755
index 5feac80..a13d325
--- a/wp-includes/nav-menu-template.php
+++ b/wp-includes/nav-menu-template.php
@@ -140,16 +140,8 @@ class Walker_Nav_Menu extends Walker {
 		 */
 		$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
 
-		$attributes = '';
-		foreach ( $atts as $attr => $value ) {
-			if ( ! empty( $value ) ) {
-				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
-				$attributes .= ' ' . $attr . '="' . $value . '"';
-			}
-		}
-
 		$item_output = $args->before;
-		$item_output .= '<a'. $attributes .'>';
+		$item_output .= '<a' . html_attributes( $atts ) . '>';
 		/** This filter is documented in wp-includes/post-template.php */
 		$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
 		$item_output .= '</a>';
