PHP docs stripslashes()

Using stripslashes() with Theme Options

**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 thoughts on “Using stripslashes() with Theme Options

  1. 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!

Comments are closed.

To get a head start, join thousands of other men and Stop The Struggle.

Get my free eBook to help you stop working all the hours without traction.

You’ll also get a weekly email with good resources to help you do family with the same intention you do your work. Both need to run well if you want to win.

%d bloggers like this: