From 52151956ea92a3e42d3ca9e76aa65188c53e6a47 Mon Sep 17 00:00:00 2001 From: Mark Jaquith Date: Tue, 28 Oct 2014 21:12:10 +0000 Subject: [PATCH] Define `JSON_PRETTY_PRINT` so it can be used with `wp_json_encode()` * `JSON_PRETTY_PRINT` was introduced in PHP 5.4 * Now you can use it with lower PHP versions, without a notice fixes #30139 see #28786 git-svn-id: https://develop.svn.wordpress.org/trunk@30075 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/compat.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php index 83a8c64652..ab4045250a 100644 --- a/src/wp-includes/compat.php +++ b/src/wp-includes/compat.php @@ -122,4 +122,10 @@ function hash_equals( $a, $b ) { return $result === 0; } -endif; \ No newline at end of file +endif; + +// JSON_PRETTY_PRINT was introduced in PHP 5.4 +// Defined here to prevent a notice when using it with wp_json_encode() +if ( ! defined( 'JSON_PRETTY_PRINT' ) ) { + define( 'JSON_PRETTY_PRINT', 128 ); +}