Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#10547 closed enhancement (duplicate)

There should be way to prevent WP from touching the content within a shortcode

Reported by: godfreykfc Owned by:
Milestone: Priority: low
Severity: normal Version:
Component: Shortcodes Keywords:
Focuses: Cc:


It is very furstrating now that "do_shortcode" is called after all the WP formatting stuff (e.g. wpautop, escaping html entities) because the content are usually messed up. There should be an option to get the RAW content.

Possible use cases:

  • Create a [noformat]...noformat shortcode
  • Create a [style]...style shortcode, which will put the content into a <style> element and inject it into the <head>
  • Create a [markdown]...markdown shortcode, which formats the content with markdown
  • Mini template language like the conditional custom fields shortcode plugin (or the php shortcode plugin)

Obviously, it is undesirable to have the content preformatted in either of the use cases listed above. For instance, in the CSS example, you'd have to go through the trouble of unescaping the HTML entities and then removing all the <br /> and <p> insterted by wpautop.

The trivial solution would be to put do_shortcode before the other formatting filters. However, this might have potential drawbacks too. For instance, the "unsafe" HTML inserted by the shortcode might get stripped too. (Which might or might not be a good thing). This enhancement obviously requries more thoughts so I'd like to see more disscusion of the potential advantages and disadvantages here.

Change History (1)

comment:1 @dd326 years ago

  • Milestone Unassigned deleted
  • Resolution set to duplicate
  • Status changed from new to closed

see #10548

Note: See TracTickets for help on using tickets.