Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Ciantic
Created June 10, 2011 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ciantic/1019157 to your computer and use it in GitHub Desktop.
Save Ciantic/1019157 to your computer and use it in GitHub Desktop.
Non quoted api for WP: load.php (patch)
<?PHP
$WP_NONQUOTED_POST = array();
/**
* Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
*
* Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
* or $_ENV are needed, use those superglobals directly.
*
* @access private
* @since 3.0.0
*/
function wp_magic_quotes() {
global $WP_NONQUOTED_POST;
// If already slashed, strip.
if ( get_magic_quotes_gpc() ) {
$_GET = stripslashes_deep( $_GET );
$_POST = stripslashes_deep( $_POST );
$_COOKIE = stripslashes_deep( $_COOKIE );
}
// Original non quoted
$WP_NONQUOTED_POST = $_POST;
// Escape with wpdb.
$_GET = add_magic_quotes( $_GET );
$_POST = add_magic_quotes( $_POST );
$_COOKIE = add_magic_quotes( $_COOKIE );
$_SERVER = add_magic_quotes( $_SERVER );
// Force REQUEST to be GET + POST.
$_REQUEST = array_merge( $_GET, $_POST );
}
/**
* Return original POST without magic quoting
*
* @param false|string $key Key, if not given whole POST is returned
* @param mixed $default Default value if key is not found
* @return mixed Returns the value or default value if key is not found
*/
function wp_get_post($key=false, $default=null) {
global $WP_NONQUOTED_POST;
if ($key === false) {
return $WP_NONQUOTED_POST;
}
return isset($WP_NONQUOTED_POST[$key]) ?
$WP_NONQUOTED_POST[$key] : $default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment