Changes between Initial Version and Version 1 of Ticket #14481
- Timestamp:
- 07/31/2010 04:02:50 AM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #14481 – Description
initial v1 1 Somewhat of a copy of a post to wp-hackers: I wrote my own implementation of shortcodes. It does things a bit 2 differently, has nested evaluation, and allows self-nesting. Since 3 there are some significant differences to the existing implementation, 1 Somewhat of a copy of a post to wp-hackers: I wrote my own implementation of shortcodes. It does things a bit differently, has nested evaluation, and allows self-nesting. Since there are some significant differences to the existing implementation, 4 2 5 A lot of the changes are borrowed 6 from definitions in the HTML specification (particularly name and 7 attribute matching). The following are the comments at the top of my 8 shortcode file. I tried to keep track of all the differences (and 9 questions) there. 3 A lot of the changes are borrowed from definitions in the HTML specification (particularly name and attribute matching). The following are the comments at the top of my shortcode file. I tried to keep track of all the differences (and questions) there. 10 4 11 From Test Cases 5 == From Test Cases == 6 12 7 (http://svn.automattic.com/wordpress-tests/wp-testcase/test_shortcode.php) 13 ========================================================================================== 8 {{{ 14 9 Shortcode Statuses (to implement, or not to implement?) 15 10 enabled = the shortcode works as normal (default) … … 22 17 disabled = the shortcode is not parsed at all. e.g. 23 18 '[shortcode foo="bar"]' products '[shortcode foo="bar"]' 19 }}} 24 20 21 == Major Differences/Improvements == 25 22 26 Major Differences/Improvements:27 ===============================28 23 I. Addressing http://codex.wordpress.org/Shortcode_API#Limitations 29 24 30 1. You can nest any tag at any depth regardless of ancestors 31 (Ticket #10702) 25 1. You can nest any tag at any depth regardless of ancestors (#10702) 32 26 33 2. Tag and attribute names may match 34 /[A-Za-z][-A-Za-z0-9_:.]*//* (trialing /* because that comment ends), 35 with case-insensitive interpretation 27 2. Tag and attribute names may match: `/[A-Za-z][-A-Za-z0-9_:.]*//*` (trialing /* because that comment ends), with case-insensitive interpretation 36 28 37 29 3. Interpretation doesn't get tripped up by things like hyphens 38 30 39 II. Addressing Ticket #12760, 31 == II. Addressing Ticket #12760, == 40 32 41 1. Changed from fix in #6518 42 Reasoning: balancing double-square-brackets can have 43 misleading results with nesting 33 1. Changed from fix in #6518. Reasoning: balancing double-square-brackets can have misleading results with nesting 44 34 45 2. Shortcodes escapable by using [[, ]]35 2. Shortcodes escapable by using `[[`, `]]` 46 36 47 3. ']]' is escaped "right to left", so '[shortcode]]]' would 48 evaluate to 'result]' 37 3. `]]` is escaped "right to left", so `[shortcode]]]` would evaluate to `result]` 49 38 50 4. '[[' is escaped left to right '[[[shortcode]]]' => '[result]'39 4. '[[' is escaped left to right `[[[shortcode]]]` => `[result]` 51 40 52 III. Enhancements 41 == III. Enhancements == 53 42 54 1. Only matches valid shortcode for registered hooks, 55 everything else will appear as text 43 1. Only matches valid shortcode for registered hooks, everything else will appear as text 56 44 57 2. Can register multiple hooks to single shortcode, uses 58 priority (default: 10) 45 2. Can register multiple hooks to single shortcode, uses priority (default: 10) 59 46 60 IV. Conflicting Design Changes 47 == IV. Conflicting Design Changes == 61 48 62 49 1. Quoted literals are escaped by entities rather than cslashes 63 50 64 2. Inline (self-closing) shortcodes get passed content to 65 accomodate multiple callbacks 51 2. Inline (self-closing) shortcodes get passed content to accomodate multiple callbacks 66 52 67 3. No equivalent to shortcode_parse_atts function 68 (Not marked private in function reference, but not 69 documented in shortcode API page) 53 3. No equivalent to shortcode_parse_atts function (Not marked private in function reference, but not documented in shortcode API page) 70 54 71 4. Boolean attributes take the place of positional attributes 72 [foo bar] gets attributes array('bar' => 'bar') instead of 73 array('0' => 'bar') 55 4. Boolean attributes take the place of positional attributes `[foo bar]` gets attributes `array('bar' => 'bar')` instead of `array('0' => 'bar')` 74 56 75 5. Disallows attribute and tag names that don't match 76 /[A-Za-z][-A-Za-z0-9_:.]*/ 57 5. Disallows attribute and tag names that don't match `/[A-Za-z][-A-Za-z0-9_:.]*/` 77 58 78 6. Disallows unquoted attribute values (also boolean 79 attributes), unless they match /[-A-Za-z0-9_:.]+/ 59 6. Disallows unquoted attribute values (also boolean attributes), unless they match `/[-A-Za-z0-9_:.]+/` 80 60 61 == Basic Interpretation Method == 81 62 82 Basic Interpretation Method: 83 ============================ 84 1. If an open tag is encountered, it is added to the stack 63 1. If an open tag is encountered, it is added to the stack 85 64 86 2. If a close tag is encountered and there is no matching open tag on the stack 87 the close tag is ignored 65 2. If a close tag is encountered and there is no matching open tag on the stack the close tag is ignored 88 66 89 3. If a close tag is encountered and there is a matching open tag on the stack 90 all opened tags on the stack before the matched tag will be 91 implicitly self-closed 67 3. If a close tag is encountered and there is a matching open tag on the stack all opened tags on the stack before the matched tag will be implicitly self-closed 92 68 93 4. If text or an inline tag is encountered, it will be evaluated to its parent's 94 content immediately 69 4. If text or an inline tag is encountered, it will be evaluated to its parent's content immediately 95 70 96 5. If tags are not closed by the end of the interpretation, they will 97 be implicitly 98 self-closed 71 5. If tags are not closed by the end of the interpretation, they will be implicitly self-closed 99 72 73 == Issues == 100 74 101 Issues: 102 ======= 103 1. Haven't written new unit tests to reflect new functionality added, 104 functionality differences 75 1. Haven't written new unit tests to reflect new functionality added, functionality differences 105 76 106 2. Documentation is not as good (though I hope most of the code is 107 self-explanatory) 77 2. Documentation is not as good (though I hope most of the code is self-explanatory) 108 78 109 3. Not 100% backwards compatible79 3. Not 100% backwards compatible