wp_unslash( string|array $value )

Removes slashes from a string or recursively removes slashes from strings within an array.

Description Description

This should be used to remove slashes from data passed to core API that expects data to be unslashed.

Top ↑

Parameters Parameters


(string|array) (Required) String or array of data to unslash.

Top ↑

Return Return

(string|array) Unslashed $value.

Top ↑

Source Source

File: wp-includes/formatting.php

function wp_unslash( $value ) {
	return stripslashes_deep( $value );

Top ↑

Changelog Changelog

Version Description
3.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Code Tốt

    This function was called when we try to read $_COOKIES:

    $viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) : array(); // @codingStandardsIgnoreLine
    $viewed_products = array_reverse( array_filter( array_map( 'absint', $viewed_products ) ) );
  2. Skip to note 2 content
    Contributed by Codex


    This function can be used in replacement of stripslashes_deep(). As it is a recursive function, when an array is given, it will remove slashes in all sub-arrays too.

    $arr = array(
    	"Is your name O\'reilly?",
    	"Person\'s Assets"
    $arr = wp_unslash( $arr );
          "Is your name O'reilly?",
          "Person's Assets"

You must log in before being able to contribute a note or feedback.