Search code examples
phpwordpressmagic-quotes

Although magic_quotes are turned off still escaped strings?


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.


Solution

  • 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/