[wp-trac] [WordPress Trac] #11948: Shortcode parser doesn't support hyphen in shortcode name

WordPress Trac wp-trac at lists.automattic.com
Tue Jan 19 11:51:12 UTC 2010


#11948: Shortcode parser doesn't support hyphen in shortcode name
--------------------------+-------------------------------------------------
 Reporter:  ukdmbfan      |       Owner:                               
     Type:  defect (bug)  |      Status:  new                          
 Priority:  low           |   Milestone:  Unassigned                   
Component:  General       |     Version:  2.9.1                        
 Severity:  minor         |    Keywords:  shortcode api wpmu hypen dash
--------------------------+-------------------------------------------------
 I tried creating a Shortcode with a hyphen (-) in the name, namely
 "contact-us", but the parser was not recognising the Shortcode. Removing
 the hyphen from the name made it work.

 It may be that the parser is not supposed to support hyphens in Shortcode
 names, however the documentation suggests that it does by using examples
 with hyphens in them ("my-shortcode", for example).

 You should be able to easily reproduce this by creating a Shortcode with a
 hyphen in the name. Code I was using is below, removing the hyphen from
 the Shortcode name in the first parameter of the add_shortcode hook (and
 subsequently in the associated call in the blog post) returned the correct
 result. When the hyphen was present, the Shortcode tag was parsed and
 removed from the post, but was not replaced with the correct output and
 the associated function itself wasn't called at all.

 Using WPMU 2.9.1.1.

 {{{
 function contact_us_func($atts, $content = null) {
     return '123';
 }

 /* NOT WORKING */

 add_shortcode('contact-us', 'contact_us_func');
 // [contact-us]

 /* WORKING */

 add_shortcode('contactus', 'contact_us_func');
 // [contactus]
 }}}

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


More information about the wp-trac mailing list