mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 15:08:10 +01:00
Introduce wp_slash() and wp_unslash(). This will be used to cleanup the myriad calls to addslashes*, add_magic_quotes, stripslashes*. see #21767
git-svn-id: http://core.svn.wordpress.org/trunk@23555 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
43a7e695e9
commit
53f9496a2f
@ -3342,3 +3342,45 @@ function sanitize_trackback_urls( $to_ping ) {
|
||||
$urls_to_ping = implode( "\n", $urls_to_ping );
|
||||
return apply_filters( 'sanitize_trackback_urls', $urls_to_ping, $to_ping );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add slashes to a string or array of strings.
|
||||
*
|
||||
* This should be used when preparing data for core API that expects slashed data.
|
||||
* This should not be used to escape data going directly into an SQL query.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param string|array $value String or array of strings to slash.
|
||||
* @return string|array Slashed $value
|
||||
*/
|
||||
function wp_slash( $value ) {
|
||||
if ( is_array( $value ) ) {
|
||||
foreach ( $value as $k => $v ) {
|
||||
if ( is_array( $v ) ) {
|
||||
$value[$k] = wp_slash( $v );
|
||||
} else {
|
||||
$value[$k] = addslashes( $v );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$value = addslashes( $value );
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove slashes from a string or array of strings.
|
||||
*
|
||||
* This should be used to remove slashes from data passed to core API that
|
||||
* expects data to be unslashed.
|
||||
*
|
||||
* @since 3.6.0
|
||||
*
|
||||
* @param string|array $value String or array of strings to unslash.
|
||||
* @return string|array Unslashed $value
|
||||
*/
|
||||
function wp_unslash( $value ) {
|
||||
return stripslashes_deep( $value );
|
||||
}
|
Loading…
Reference in New Issue
Block a user