WordPress at a glance

wp_slash() WP 1.0

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.

No Hooks.

Return

String/Array. Slashed $value

Usage

wp_slash( $value );
$value(string/array) (required)
String or array of strings to slash.

Code of wp_slash: wp-includes/formatting.php VER 4.9.8

<?php
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;
}

Related Functions

From tag: Supporting (helper utility auxiliary)

More from category: Helper Functions

No comments
    Hello, !     Log In . Register