[wp-trac] [WordPress Trac] #26343: has_shortcode not recognizing nested shortcodes

WordPress Trac noreply at wordpress.org
Fri Jul 18 13:03:43 UTC 2014


#26343: has_shortcode not recognizing nested shortcodes
-----------------------------------+-----------------------------
 Reporter:  sunyatasattva          |       Owner:  wonderboymusic
     Type:  defect (bug)           |      Status:  reopened
 Priority:  normal                 |   Milestone:  4.0
Component:  Shortcodes             |     Version:  3.6
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+-----------------------------

Comment (by aaroncampbell):

 The problem is that `has_shortcode()` can now return true for a shortcode
 that will never be run. Try this:

 {{{
 <?php
 function test_ticket_26343( $atts, $content = '' ) {
         return 'Content is: ' . $content;
 }
 add_shortcode( 'ticket26343', 'test_ticket_26343' );
 add_shortcode( 'ticket26343-2', 'test_ticket_26343' );

 $content = "Testing [ticket26343]In one Before [ticket26343-2]In
 Both[/ticket26343-2] In one After[/ticket26343]\n";

 var_dump( has_shortcode( $content, 'ticket26343' ) ); // True before patch
 and after, always runs
 var_dump( has_shortcode( $content, 'ticket26343-2' ) ); // False before
 patch, true after, never runs
 var_dump( do_shortcode( $content ) );

 $content = "Testing again [ticket26343-2]In one Before [ticket26343]In
 Both[/ticket26343] In one After[/ticket26343-2]\n";

 var_dump( has_shortcode( $content, 'ticket26343' ) ); // True before patch
 and after, always runs
 var_dump( has_shortcode( $content, 'ticket26343-2' ) ); // False before
 patch, true after, never runs
 var_dump( do_shortcode( $content ) );
 }}}

 It's the second one in both of those tests that's the problem. The
 shortcode never runs, but *is* in the content. Should `has_shortcode()`
 return true or false in that case?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/26343#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list