Created
June 10, 2011 16:03
-
-
Save Ciantic/1019157 to your computer and use it in GitHub Desktop.
Non quoted api for WP: load.php (patch)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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