Opened 11 years ago
Last modified 7 years ago
#33213 new defect (bug)
has_shortcode spec in 4.3
| Reported by: | tmatsuur | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Shortcodes | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
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?
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
has_shortcode does a lot of things that don't match do_shortcode... It matches escaped shortcodes and runs recursively too.