[wp-trac] [WordPress Trac] #35856: While shortcodes shouldn't be allowed inside of HTML, should closing shortcodes be allowed "inside" of HTML?

WordPress Trac noreply at wordpress.org
Thu Feb 18 08:07:46 UTC 2016


#35856: While shortcodes shouldn't be allowed inside of HTML, should closing
shortcodes be allowed "inside" of HTML?
--------------------------+-------------------------
 Reporter:  Viper007Bond  |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Shortcodes    |     Version:  trunk
 Severity:  normal        |  Resolution:  worksforme
 Keywords:                |     Focuses:
--------------------------+-------------------------

Comment (by Viper007Bond):

 Replying to [comment:2 Viper007Bond]:
 > It also helps that I came up with a workaround for my plugin. :)

 [https://xkcd.com/979/ Incase anyone stumbles across this via Google],
 here's the workaround I ended up using:

 https://github.com/Viper007Bond/syntaxhighlighter/commit/2f4011ab40f1ef5e5fbb507a9c141796802f4a39

 The less complex version of that code is just this:

 {{{
 $pattern = get_shortcode_regex( $tagnames );
 $content = preg_replace_callback( "/$pattern/", 'do_shortcode_tag',
 $content );
 }}}

 It's a clone of `do_shortcode()`'s core functionality so that
 `shortcode_hack_extra_escape_escaped_shortcodes()` doesn't get called.

 '''Note that this isn't a great idea for rendering! ''' I'm only using it
 in the context of escaping shortcode contents when a post is going into
 the database and decoding them when they're heading to the editor. I'm
 using the safe `do_shortcode( $content, true )` when actually parsing the
 shortcodes for render.

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


More information about the wp-trac mailing list