How to stop jQuery ajax from adding slashes to JSON string? How to stop jQuery ajax from adding slashes to JSON string? wordpress wordpress

How to stop jQuery ajax from adding slashes to JSON string?


WordPress made the decision a long time ago to auto add slashes to all global input variables ($_POST, etc). They pass it through an internal wp_slash() function. The official recommended way to remove these slashes is to use their provided wp_unslash:

wp_unslash( $_POST['preset'] );

Here is the codex reference.

**Note: It looks like this might be getting fixed in version 5.0, where they will be doing the wp_unslash for you when you request values from the global input variables.