[wp-hackers] shortcode API > $content > TINY MCE filters

Haluk Karamete halukkaramete at gmail.com
Wed May 14 19:49:30 UTC 2014


When, we place the following sample text into the text editor ( thru the
text tab right of the tiny MCE );

line1 & < >
line2

line3

and we save the post, we save it as is.

Carriage returns are preserved and the & < > stays as they are.

However, when this section makes it into a shortcode as part of the
$content portion.

the content becomes like this;

<p>line1 & < ><br />
> line2</p>
> <p>line3</p>
> <p>{args}<br />
>
>

Mind due the wp_posts.post_content field does not have those <br /> and <p>
add ons.
When my shortcode $content has the above red text, it appears in the DB as
follows;

line1 & < >
> line2
>
> line3
>


I'm wondering what's the best course of action for me to take in my
shortcode so that I can reverse this $content back to how it was stored in
the database?

If you are wondering, why on earth I'd do something ike this; here is the
reasoning;
I'm exploring some new things with the WordPress' shortcode system and I'm
using the content area which makes it into my shortcode function as
$content for storing structured data.

And when I see my structured data has been filtered and changed, I feel
like I have to undo all that changes so that I can get it exactly how it
was authored in Tiny MCE's Text Tab.
But I do not want to get into a bunch of replacestring operations to
achieve that.

What's the best way to address this problem?

I also noticed that when you do a quick click on visual tab and then
another quick click back on the TEXT tab, I end up changing this original
text

line1 & < >
line2

line3

into this;

line1 & < >
line2

line3

Though, this part is not as important as my first question, but I'm very
curious to know thw wisdom to do so. I'm also wondering if there are ways
to prevent that from happening and what would be harms of doing so?  Is
that to take care of an XSS issues?


More information about the wp-hackers mailing list