Title: wp_magic_quotes
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_magic_quotes()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#description)
 * [Source](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Adds magic quotes to `$_GET`, `$_POST`, `$_COOKIE`, and `$_SERVER`.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#description)󠁿

Also forces `$_REQUEST` to be `$_GET + $_POST`. If `$_SERVER`, `$_COOKIE`, or `$
_ENV` are needed, use those superglobals directly.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#source)󠁿

    ```php
    function wp_magic_quotes() {
    	// Escape with wpdb.
    	$_GET    = add_magic_quotes( $_GET );
    	$_POST   = add_magic_quotes( $_POST );
    	$_COOKIE = add_magic_quotes( $_COOKIE );
    	$_SERVER = add_magic_quotes( $_SERVER );

    	// Force REQUEST to be GET + POST.
    	$_REQUEST = array_merge( $_GET, $_POST );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/load.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/load.php#L1285)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/load.php#L1285-L1294)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#related)󠁿

| Uses | Description | 
| [add_magic_quotes()](https://developer.wordpress.org/reference/functions/add_magic_quotes/)`wp-includes/functions.php` |

Walks the array while sanitizing the contents.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_magic_quotes/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_magic_quotes%2F)
before being able to contribute a note or feedback.