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

$value

(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

Changelog
Version Description
3.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by Codex

    Example

    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 );
    /*
     Outputs: 
     array(
          "Is your name O'reilly?",
          "Person's Assets"
     );
    */
    

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