Opened 3 years ago
Last modified 2 years ago
#12760 assigned defect (bug)
Escaping shortcode conditionally
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | low | Milestone: | Future Release |
| Component: | General | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch dev-feedback |
| Cc: | pavelevap@…, kunalb, markjaquith, azram19 |
Description (last modified by markjaquith)
Using additional brackets is the official way to "escape" a shortcode. e.g. [[escaped]]
Using additional brackets [[shortcode]] in a post works only when the plugin (function) for this shortcode is active. When deactivated, additional brackets are shown in the post. It is annoying for many users, because editors sometimes test a plugin, write about it in a post with shortcode example and after some months this plugin is deactivated. Now there will be additional brackets, breaking their example code.
Input:
[[shortcode_that_does_not_exist]]
Expected output, regardless of whether that plugin is active:
[shortcode_that_does_not_exist]
Actual output, if plugin is not active:
[[shortcode_that_does_not_exist]
[edited by Mark Jaquith]
Attachments (2)
Change History (9)
comment:1
markjaquith — 3 years ago
- Description modified (diff)
- Owner set to markjaquith
- Status changed from new to assigned
- Version changed from 2.9.2 to 3.0
- Milestone changed from Awaiting Triage to Future Release
- Priority changed from normal to low
comment:6
markjaquith — 2 years ago
- Cc markjaquith added
- Keywords dev-feedback added
Good idea. Let's get some eyes on the patch.

I've attached a patch that takes care of any shortcodes of the form [[foobar]] left over after running all registered shortcode functions: I avoided changing the get_shortcode_regex function to allow for general tags because of the way the embed shortcode is handled (calling do_shortcode twice, once with only the embed as the shortcode to handle, and once after that).
Getting [shortcode]Text[/shortcode] to display required an escape of the form [[shortcode]Text[/shortcode]] ; so non-shortcodes of this form are reduced accordingly.