Languages: English • Reference/wp slash 日本語 (Add your language)
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.
<?php $value = wp_slash($value); ?>
How to use wp_slash with a string within your plugin.
add_action('pre_get_posts', 'toolset_string_add_slashes'); function toolset_string_add_slashes(){ $name = "O'Reilly & Associates"; $name = wp_slash($name); echo "name=$name"; }
How to use wp_slash with an array within your plugin.
add_action('pre_get_posts', 'toolset_array_add_slashes'); function toolset_array_add_slashes(){ $names = array("Baba O'Reilly", "class of '99"); $names = wp_slash($names); print_r($names); }
wp_slash() is located in wp-includes/formatting.php
.
Slashing Functions: wp_slash(), wp_unslash(), stripslashes_deep(), addslashes_gpc()