wp_slash() – Add slashes to a string or array of strings, in a recursive manner.

You appear to be a bot. Output may be restricted

Description

Adds slashes to a string or recursively adds slashes to strings within an array.

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.

Usage

$string|array = wp_slash( $value );

Parameters

$value
( string|array ) required – String or array of data to slash.

Returns

string|array Slashed `$value`, in the same type as supplied.

Source

File name: wordpress/wp-includes/formatting.php
Lines:

1 to 11 of 11
function wp_slash( $value ) {
  if ( is_array( $value ) ) {
    $value = array_map( 'wp_slash', $value );
  }

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

  return $value;
}
 

 View on GitHub View on Trac