From 886a8e9549ec8525c510715039549be1320b520a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Wed, 5 Mar 2014 04:54:15 +0000 Subject: [PATCH] Add a `class` attribute to the caption shortcode to allow for additional classes on the caption container. props rhyswynne, mcadwell. fixes #25295. Built from https://develop.svn.wordpress.org/trunk@27404 git-svn-id: http://core.svn.wordpress.org/trunk@27251 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/media.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/media.php b/wp-includes/media.php index 23e0721efa..cd53f5fc3c 100644 --- a/wp-includes/media.php +++ b/wp-includes/media.php @@ -673,6 +673,7 @@ add_shortcode('caption', 'img_caption_shortcode'); * 'aligncenter', alignright', 'alignnone'. * @type int $width The width of the caption, in pixels. * @type string $caption The caption text. + * @type string $class Additional class name(s) added to the caption container. * } * @param string $content Optional. Shortcode content. * @return string HTML content to display the caption. @@ -708,7 +709,8 @@ function img_caption_shortcode( $attr, $content = null ) { 'id' => '', 'align' => 'alignnone', 'width' => '', - 'caption' => '' + 'caption' => '', + 'class' => '', ), $attr, 'caption' ); $atts['width'] = (int) $atts['width']; @@ -741,7 +743,9 @@ function img_caption_shortcode( $attr, $content = null ) { if ( $caption_width ) $style = 'style="width: ' . (int) $caption_width . 'px" '; - return '
' + $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); + + return '
' . do_shortcode( $content ) . '

' . $atts['caption'] . '

'; }