From d2bb4d67457c259a15a8f4a4655b490c0cc031f0 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 6 Oct 2015 02:55:43 +0000 Subject: [PATCH] REST API: add `JsonSerializable()` compatibility interface for PHP <5.4 to `compat.php` Props rmmcue. See #33982. git-svn-id: https://develop.svn.wordpress.org/trunk@34845 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/compat.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/compat.php b/src/wp-includes/compat.php index b2308e8f22..781e7a728f 100644 --- a/src/wp-includes/compat.php +++ b/src/wp-includes/compat.php @@ -315,4 +315,20 @@ if ( ! function_exists( 'json_last_error_msg' ) ) : return 'An unknown error occurred'; } } -endif; \ No newline at end of file +endif; + +if ( ! interface_exists( 'JsonSerializable' ) ) { + define( 'WP_JSON_SERIALIZE_COMPATIBLE', true ); + /** + * JsonSerializable interface. + * + * Compatibility shim for PHP <5.4 + * + * @link http://php.net/jsonserializable + * + * @since 4.4.0 + */ + interface JsonSerializable { + public function jsonSerialize(); + } +}