Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#33213 new defect (bug)

has_shortcode spec in 4.3

Reported by: tmatsuur's profile tmatsuur Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Shortcodes Keywords:
Focuses: Cc:


There is a question about the specification of the has_shortcode function.

The specification of the do_shortcode function was changed in version 4.2.3, but it doesn't seem that the has_shortcode function is changed.

The next contents were tested.


function shortcode_abc( $atts, $content='' ) {
	return 'abc';
add_shortcode( 'abc', 'shortcode_abc' );

var_dump( has_shortcode( "<!-- [abc] -->", 'abc' ) );
var_dump( do_shortcode( "<!-- [abc] -->" ) );

var_dump( has_shortcode( "<![CDATA[ [abc] ]]>", 'abc' ) );
var_dump( do_shortcode( "<![CDATA[ [abc] ]]>" ) );

var_dump( has_shortcode( "<input value=\"[abc]\" />", 'abc' ) );
var_dump( do_shortcode( "<input value=\"[abc]\" />" ) );

var_dump( has_shortcode( "<div class=\"[abc]\">Hello.</div>", 'abc' ) );
var_dump( do_shortcode( "<div class=\"[abc]\">Hello.</div>" ) );

var_dump( has_shortcode( "[abc]", 'abc' ) );
var_dump( do_shortcode( "[abc]" ) );

result(4.3 RC1):

string(14) "<!-- [abc] -->"
string(19) "<![CDATA[ [abc] ]]>"
string(23) "<input value="[abc]" />"
string(29) "<div class="abc">Hello.</div>"
string(3) "abc"

(1).I think $ignore_html parameter is also necessary to the has_shortcode function.

function has_shortcode( $content, $tag, $ignore_html = false )

(2).Shouldn't a result of the has_shortcode function make the specification of the do_shortcode function identical?

Change History (3)

#1 @miqrogroove
9 years ago

has_shortcode does a lot of things that don't match do_shortcode... It matches escaped shortcodes and runs recursively too.

#2 @tmatsuur
9 years ago

I'd like to confirm result of has_shortcode function.
I think that may be the status quo if the result is simple accuracy of has_shortcode function.

#3 @miqrogroove
9 years ago

  • Milestone changed from Awaiting Review to Future Release

Seems like a valid bug.

Note: See TracTickets for help on using tickets.