wc_esc_json( string $json, bool $html = false )
Escape JSON for use on HTML or attribute text nodes.
Description Description
Parameters Parameters
- $json
-
(Required) JSON to escape.
- $html
-
(Optional) True if escaping for HTML text node, false for attributes. Determines how quotes are handled.
Default value: false
Return Return
(string) Escaped JSON.
Source Source
File: includes/wc-formatting-functions.php
function wc_esc_json( $json, $html = false ) { return _wp_specialchars( $json, $html ? ENT_NOQUOTES : ENT_QUOTES, // Escape quotes in attribute nodes only. 'UTF-8', // json_encode() outputs UTF-8 (really just ASCII), not the blog's charset. true // Double escape entities: `&` -> `&`. ); }
Changelog Changelog
Version | Description |
---|---|
3.5.5 | Introduced. |