[wp-hackers] Shortcodes + wpautop() & wptexturize()

Viper007Bond viper at viper007bond.com
Thu May 22 03:56:41 GMT 2008


This is kinda RE: http://trac.wordpress.org/ticket/6444   but I thought I'd
take the discussion up here rather than re-open the ticket or make a new
one.


I'm (attempting) to write a shortcode-powered code posting plugin. You type
like [code lang="php"]some code here[/code] and it htmlspecialchar()'s it
and other things.

The problem I'm running into though is both wpautop() and wptexturize() are
both ruining the internals of my shortcodes by either formatting them or
adding paragraph marks where I have mutli-line code posts.

So I can think of three solutions:


1. wpautop() and wptexturize() get modified to not touch the internals of
valid shortcodes. I have tickets open for this (
http://trac.wordpress.org/ticket/6984 &
http://trac.wordpress.org/ticket/6969 ) but I don't know how those will pan
out or if it's even the best solution.

2. Bring back the before/after-10 code. This is also probably not the best
solution as it's ugly and adds tons of excess code.

3. I hook in pre-10 with my own filter, hack the $shortcode_tags global so
it only contains my shortcodes, apply do_shortcodes() to the $content, and
then put $shortcode_tags back to what it was. My shortcode processing
functions will need to replace the code blocks with placeholders that'll
survive wpautop() and wptexturize() and then at level 11, I replace my
placeholders with the real HTML I want. Ugh.


Any thoughts / suggestions on this whole ordeal?

-- 
Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/


More information about the wp-hackers mailing list