[wp-trac] [WordPress Trac] #14481: Shortcode Enhancements

WordPress Trac noreply at wordpress.org
Wed Jan 22 04:45:29 UTC 2014


#14481: Shortcode Enhancements
----------------------------------------+-----------------------------
 Reporter:  deadowl                     |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Future Release
Component:  Shortcodes                  |     Version:  3.0
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |
----------------------------------------+-----------------------------

Comment (by daveagp):

 A long time passed since my earlier comment here, so I can tell you what
 was my main problem personally, and how I worked around it.

 Because I was making a website to teach programming and using shortcodes
 to create exercises, it was very important for me that shortcode argument
 values (at least quoted ones) would be able to contain any string, not
 just a limited set of characters. (I didn't care about shortcode argument
 names.)

 Problem 1. WordPress will not allow any of the shortcode arg values to
 contain
 a closing square bracket ] under any circumstances, even if it is quoted.

 Problem 2. Each shortcode arg value may either be (a) unquoted but contain
 no spaces,
 (b) single-quoted but contain no single quotes, or (c) double-quoted
 but contain no double quotes. This restriction means you can't pass both
 kinds at once. It's a weird restriction because the values are later run
 through
 stripcslashes anyway.

 To get around it, I wrote some modified version of the shortcode
 infrastructure that would recognize backslashes as escapes and wait for a
 closing quote rather than stopping when it hit a ]. Once I figured out
 that this was what I wanted to do, the rest was pretty straightforward:

 https://github.com/cemc/cscircles-wp-
 content/blob/master/plugins/pybox/sweetcodes.php

 Sorry that this file is part of a monolithic plugin but if it would help
 for me to explain or extract the part of it that's relevant (mostly the
 giant regex) let me know.

 If it is likely that these character classes could become kosher for
 quoted shortcode arguments, I would be happy to do some work to
 incorporate it!

 Many of the other improvements sure seem like good ideas, like being able
 to self-nest the same shortcode, even though it's never affected me
 directly.

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


More information about the wp-trac mailing list