[wp-trac] [WordPress Trac] #24990: Nested Shortcode Inside [caption]

WordPress Trac noreply at wordpress.org
Thu Apr 24 09:18:49 UTC 2014


#24990: Nested Shortcode Inside [caption]
------------------------------------------+-----------------------------
 Reporter:  prionkor                      |       Owner:
     Type:  defect (bug)                  |      Status:  new
 Priority:  normal                        |   Milestone:  Future Release
Component:  Media                         |     Version:  3.6
 Severity:  normal                        |  Resolution:
 Keywords:  needs-patch needs-unit-tests  |     Focuses:
------------------------------------------+-----------------------------

Comment (by pputzer):

 @prionkor: Yeah, it does. My workaround looks like this:

 {{{
         function media_credit_caption_shortcode($attr, $content = null) {
                 // New-style shortcode with the caption inside the
 shortcode with the link and image tags.
                 if ( ! isset( $attr['caption'] ) ) {
                         if ( preg_match( '#((?:\[media-
 credit[^\]]+\]\s*)(?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?(?:\s*\[/media-
 credit\])?)(.*)#is', $content, $matches ) ) {
                                 $content = $matches[1];
                                 $attr['caption'] = trim( $matches[2] );
                         }
                 }

                 return img_caption_shortcode($attr, $content);
         }
         add_shortcode('wp_caption', 'media_credit_caption_shortcode');
         add_shortcode('caption', 'media_credit_caption_shortcode');
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/24990#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list