diff --git a/src/wp-includes/shortcodes.php b/src/wp-includes/shortcodes.php index 47cb57a9b2..fc850460f2 100644 --- a/src/wp-includes/shortcodes.php +++ b/src/wp-includes/shortcodes.php @@ -165,8 +165,11 @@ function has_shortcode( $content, $tag ) { return false; foreach ( $matches as $shortcode ) { - if ( $tag === $shortcode[2] ) + if ( $tag === $shortcode[2] ) { return true; + } elseif ( isset( $shortcode[5] ) && has_shortcode( $shortcode[5], $tag ) ) { + return has_shortcode( $shortcode[5], $tag ); + } } } return false; diff --git a/tests/phpunit/tests/shortcode.php b/tests/phpunit/tests/shortcode.php index 79f21cb5cd..7e8b97188a 100644 --- a/tests/phpunit/tests/shortcode.php +++ b/tests/phpunit/tests/shortcode.php @@ -394,4 +394,17 @@ EOF; $this->assertEquals( $output, shortcode_unautop( $in ) ); } } + + /** + * @ticket 26343 + */ + function test_has_shortcode() { + $content = 'This is a blob with [gallery] in it'; + $this->assertTrue( has_shortcode( $content, 'gallery' ) ); + + add_shortcode( 'foo', '__return_false' ); + $content_nested = 'This is a blob with [foo] [gallery] [/foo] in it'; + $this->assertTrue( has_shortcode( $content_nested, 'gallery' ) ); + remove_shortcode( 'foo' ); + } }