[wp-trac] [WordPress Trac] #14557: Side by side shortcodes leave one as text

WordPress Trac wp-trac at lists.automattic.com
Mon Nov 1 07:26:22 UTC 2010


#14557: Side by side shortcodes leave one as text
--------------------------+-------------------------------------------------
 Reporter:  adiant        |       Owner:                 
     Type:  defect (bug)  |      Status:  new            
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Shortcodes    |     Version:  3.0.1          
 Severity:  normal        |    Keywords:  parsing        
--------------------------+-------------------------------------------------
Changes (by stringfold):

 * cc: stringfold (added)


Comment:

 I can confirm this is a problem. If you have any two shortcodes directly
 one after the other (e.g. [tweet][like] then the regular expression in
 get_shortcode_regex() in shortcodes.php doesn't work.

 For example, I have three shortcodes in a row: [facebook-lite][tweet-
 button][sharethis], but this is what the shortcode regex expression finds:

 {{{

 Array
 (
 [0] => >[facebook-like][
 [1] => >
 [2] => facebook-like
 [3] =>
 [4] =>
 [5] =>
 [6] => [
 )
 Array
 (
 [0] => ][sharethis]T
 [1] => ]
 [2] => sharethis
 [3] =>
 [4] =>
 [5] =>
 [6] => T
 )

 }}}

 In other words, the middle shortcode of the three [tweet-button] is not
 found because it looks like the regex is picking up the opening bracket as
 part of the previous shortcode.

 Sadly, I am not a regex expert so I have to decline to attempt to fix
 this. I suspect a competent regex person will be able to fix this in short
 order.

 There is a workaround -- if you add any single character between the
 shortcodes then the regex works fine -- so you can use a space (or even
  ) to prevent your adjoining shortcodes from disappearing.

 This should be a one-line fix, so it would be nice to include it in a
 point release.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14557#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list