[wp-trac] [WordPress Trac] #21257: Shortcode not working when another earlier defined shortcode contains new shortcode

WordPress Trac wp-trac at lists.automattic.com
Fri Jul 13 10:53:25 UTC 2012


#21257: Shortcode not working when another earlier defined shortcode contains new
shortcode
--------------------------+--------------------------------------
 Reporter:  dannydehaan   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Shortcodes    |    Version:  3.4.1
 Severity:  normal        |   Keywords:  dev-feedback needs-patch
--------------------------+--------------------------------------
 Hi All,

 Hope my summary is clear enough.

 The problem.

 When you want to register a new shortcode and another shortcode that
 contains the new shortcode string is registered earlier, the earlier
 shortcode will be used by WordPress.

 To make it more clear, here's an example.

 {{{
 add_shortcode( 'this-is-a-shortcode', 'this_is_a_shortcode' );
 add_shortcode( 'this-is-a-shortcode-1', 'this_is_a_shortcode_1' );

 function this_is_a_shortcode() {
         return 'Shortcode Used';
 }

 function this_is_a_shortcode_1() {
         return 'Shortcode 1 Used';
 }
 }}}

 When i use the above and i call '''[this-is-a-shortcode-1]''' in my
 content, i get '''Shortcode Used''' instead of '''Shortcode 1 Used'''.

 When you change the order of the shortcode registration, WordPress will
 return '''Shortcode 1 Used''' like it should be.

 {{{
 add_shortcode( 'this-is-a-shortcode-1', 'this_is_a_shortcode_1' );
 add_shortcode( 'this-is-a-shortcode', 'this_is_a_shortcode' );

 function this_is_a_shortcode() {
         return 'Shortcode Used';
 }

 function this_is_a_shortcode_1() {
         return 'Shortcode 1 Used';
 }
 }}}

 I already searched in the wp-includes/shortcodes.php, but i saw a regex
 there and thougt... This isn't a fix for me ;)

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21257>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list