add_magic_quotes() WordPress Function

The add_magic_quotes() function is used to add magic quotes to a string. This function is deprecated in favor of the addslashes() function.

add_magic_quotes( array $array ) #

Walks the array while sanitizing the contents.


Parameters

$array

(array)(Required)Array to walk while sanitizing contents.


Top ↑

Return

(array) Sanitized $array.


Top ↑

Source

File: wp-includes/functions.php

function add_magic_quotes( $array ) {
	foreach ( (array) $array as $k => $v ) {
		if ( is_array( $v ) ) {
			$array[ $k ] = add_magic_quotes( $v );
		} elseif ( is_string( $v ) ) {
			$array[ $k ] = addslashes( $v );
		} else {
			continue;
		}
	}

	return $array;
}


Top ↑

Changelog

Changelog
VersionDescription
5.5.0Non-string values are left untouched.
0.71Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More