Take the 2-minute tour ×

I disabled magic_quotes in my php.ini.

But I still get escaped strings in my form.

Note: I'm running this in a theme in Wordpress.

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

I actually already figured this out, just want to leave my solution here in case other people might find it useful:

Wordpress automatically escapes all request variables. If magic quotes are turned off, they strip the slashes first, but add them again afterwards.

wp-settings.php code piece:

// If already slashed, strip.
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes_deep($_GET );
$_POST = stripslashes_deep($_POST );
$_COOKIE = stripslashes_deep($_COOKIE);

// Escape with wpdb.
$_GET = add_magic_quotes($_GET );
$_POST = add_magic_quotes($_POST );
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);

Source: http://www.wptextads.com/blog/2007/05/19/gpc-magic-quotes-in-wordpress-is-compulsory/

share|improve this answer
more recently, this happens in wp-includes/load.php which wp-settings.php includes –  yitwail Mar 10 at 0:00
add comment

Your Answer


