[wp-trac] [WordPress Trac] #9405: Shortcode parameter names can't have dashes in them

WordPress Trac noreply at wordpress.org
Wed Jun 17 13:35:26 UTC 2015


#9405: Shortcode parameter names can't have dashes in them
--------------------------+-----------------------------
 Reporter:  Viper007Bond  |       Owner:
     Type:  defect (bug)  |      Status:  reopened
 Priority:  lowest        |   Milestone:  Future Release
Component:  Shortcodes    |     Version:  2.8
 Severity:  minor         |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------------

Comment (by aaroncampbell):

 Replying to [comment:15 azaozz]:
 > I'm not sure this is a good idea. Why would we want dashes in shortcode
 attribute names, what (critical) problem is solved with that?

 I'm not sure it's "critical" but I do think it's a problem that should be
 solved. When you create a shortcode, try to use a hyphenated parameter
 name, and it doesn't work...it seems broke. These are only getting more
 popular now with modern HTML using things like data-*, aria-*, etc. There
 are certainly characters we don't need to support here, but I think that
 `[\w-]` is not only understandable, but expected.


 > The shortcode regexps are pretty big/slow already, making them even more
 complex is undesirable imho. Also, imagine the billions of times this
 slower regexp will run every day. Is it really worth the extra kWh of
 electricity for the servers so we can have slightly fancier attribute
 names (that few would ever use)?

 This actually doesn't affect the main shortcode regex (the one we've
 struggled with keeping memory-friendly). It only affects the shortcode
 attributes regex, which is only ever run on the content inside the opening
 shortcode tag (match 3 from the shortcode regex). Since the change is one
 that affects only the attributes regex, and since the only change to that
 regex it to use `[\w-]` instead of `\w` for attribute names, I think it's
 a reasonable move.

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


More information about the wp-trac mailing list