**Update:** This is not the right way to do this. Use WordPress functions to sanitize data. April 27, 2012
While I might be showing a bit about my PHP naivety but while working with theme options recently I found that some of my content had a just before a single quote. Now I knew it was working to escape the content but didn’t know how to get that dang out of the content. After reading up a bit more on escaping and data sanitization I found the
stripslashes();
function and guess what it does exactly what you’d think.
Remember if you’re going to echo any theme options to call
stripslashes();
on it too. So my theme options changed from
[php]
echo get_option( theme_option_name );
[php]
to
[php]
echo stripslashes( get_option( theme_option_name ) );
[php]
And we’ve killed the that were messing us up.
2 responses to “Using stripslashes() with Theme Options”
Finaly! Seriously, I’ve been banging my head over this, trying to get this working on my new WordPress theme, when calling a theme option.
I’ve tried different codes in the functions.php and so on, but it was really this simple.
Gawd, what a relief – thanks!
No problem, I did the same thing for a while then found the solution and figured others would have the same issue.