diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php
index 7bfda66f1c..24c370769d 100644
--- a/src/wp-includes/media.php
+++ b/src/wp-includes/media.php
@@ -1589,11 +1589,29 @@ function img_caption_shortcode( $attr, $content = null ) {
}
if ( $html5 ) {
- $html = ''
- . do_shortcode( $content ) . '' . $atts['caption'] . '';
+ $html = sprintf(
+ '%s%s',
+ $atts['id'],
+ $style,
+ esc_attr( $class ),
+ do_shortcode( $content ),
+ sprintf(
+ '%s',
+ $atts['caption']
+ )
+ );
} else {
- $html = '
'
- . do_shortcode( $content ) . '
' . $atts['caption'] . '
';
+ $html = sprintf(
+ '%s%s
',
+ $atts['id'],
+ $style,
+ esc_attr( $class ),
+ do_shortcode( $content ),
+ sprintf(
+ '%s
',
+ $atts['caption']
+ )
+ );
}
return $html;