A WordPress-centric search engine for devs and theme authors



wp_slash ›

Since3.6.0
Deprecatedn/a
wp_slash ( $value )
Parameters:
  • (string|string[]) $value String or array of strings to slash.
    Required: Yes
Returns:
  • (string|string[]) Slashed $value.
Defined at:
Codex:
Change Log:
  • 5.5.0

Add slashes to a string or array of strings, in a recursive manner.

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.


Related Functions: wp_unslash, wp_hash, wp_styles, wp_rss, deslash

Source

function wp_slash( $value ) {
	if ( is_array( $value ) ) {
		$value = array_map( 'wp_slash', $value );
	}

	if ( is_string( $value ) ) {
		return addslashes( $value );
	}

	return $value;
}