[wp-trac] [WordPress Trac] #24990: Nested Shortcode Inside [caption]
WordPress Trac
noreply at wordpress.org
Thu Dec 4 18:04:34 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-unit-tests has-patch | Focuses:
----------------------------------------+-----------------------------
Comment (by kitwestneat):
I also ran into the "img tag replaced by shortcode" issue described in
comment:10, and worked around it by filtering the regex with a new filter
in media.php
{{{
--- a/wordpress/wp-includes/media.php Sat Nov 29 03:37:15 2014 -0500
+++ b/wordpress/wp-includes/media.php Thu Dec 04 12:50:49 2014 -0500
@@ -797,7 +797,9 @@
function img_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( '#((?:<a [^>]+>\s*)?<img
[^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) {
+ $regex = apply_filters('img_caption_shortcode_caption_regex',
+ '#((?:<a [^>]+>\s*)?<img
[^>]+>(?:\s*</a>)?)(.*)#is');
+ if ( preg_match( $regex, $content, $matches ) ) {
$content = $matches[1];
$attr['caption'] = trim( $matches[2] );
}
}}}
Also I noticed that there's a spot where do_shortcode is not called on
content - is that intentional?
{{{
@@ -831,7 +833,7 @@
$atts['width'] = (int) $atts['width'];
if ( $atts['width'] < 1 || empty( $atts['caption'] ) )
- return $content;
+ return do_shortcode($content);
if ( ! empty( $atts['id'] ) )
$atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" ';
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/24990#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list