[wp-trac] [WordPress Trac] #33213: has_shortcode spec in 4.3

WordPress Trac noreply at wordpress.org
Fri Jul 31 08:04:53 UTC 2015


#33213: has_shortcode spec in 4.3
--------------------------+-----------------------------
 Reporter:  tmatsuur      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Shortcodes    |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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.

 source:
 {{{
 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):
 {{{
 bool(true)
 string(14) "<!-- [abc] -->"
 bool(true)
 string(19) "<![CDATA[ [abc] ]]>"
 bool(true)
 string(23) "<input value="[abc]" />"
 bool(true)
 string(29) "<div class="abc">Hello.</div>"
 bool(true)
 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?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33213>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list