diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index 2fc2e6e63a..1d6d987bb9 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -3482,20 +3482,8 @@ function wp_audio_shortcode( $attr, $content = '' ) { $attr_strings = array(); - foreach ( $html_atts as $attribute_name => $attribute_value ) { - if ( in_array( $attribute_name, array( 'loop', 'autoplay', 'muted' ), true ) && true === $attribute_value ) { - // Add boolean attributes without their value for true. - $attr_strings[] = esc_attr( $attribute_name ); - } elseif ( 'preload' === $attribute_name && ! empty( $attribute_value ) ) { - // Handle the preload attribute with specific allowed values. - $allowed_preload_values = array( 'none', 'metadata', 'auto' ); - if ( in_array( $attribute_value, $allowed_preload_values, true ) ) { - $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); - } - } elseif ( ! empty( $attribute_value ) ) { - // For non-boolean attributes, add them with their value. - $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); - } + foreach ( $html_atts as $k => $v ) { + $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; } $html = ''; @@ -3767,8 +3755,20 @@ function wp_video_shortcode( $attr, $content = '' ) { } $attr_strings = array(); - foreach ( $html_atts as $k => $v ) { - $attr_strings[] = $k . '="' . esc_attr( $v ) . '"'; + foreach ( $html_atts as $attribute_name => $attribute_value ) { + if ( in_array( $attribute_name, array( 'loop', 'autoplay', 'muted' ), true ) && true === $attribute_value ) { + // Add boolean attributes without their value for true. + $attr_strings[] = esc_attr( $attribute_name ); + } elseif ( 'preload' === $attribute_name && ! empty( $attribute_value ) ) { + // Handle the preload attribute with specific allowed values. + $allowed_preload_values = array( 'none', 'metadata', 'auto' ); + if ( in_array( $attribute_value, $allowed_preload_values, true ) ) { + $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); + } + } elseif ( ! empty( $attribute_value ) ) { + // For non-boolean attributes, add them with their value. + $attr_strings[] = sprintf( '%s="%s"', esc_attr( $attribute_name ), esc_attr( $attribute_value ) ); + } } $html = '';