From 913c9aeac40e7c6c801eab7c2881b412c50f68b3 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Wed, 28 Jun 2023 16:42:20 +0200 Subject: [PATCH] put @context at the top of the JSON output --- includes/activity/class-base-object.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/includes/activity/class-base-object.php b/includes/activity/class-base-object.php index 18382a5..0ad4457 100644 --- a/includes/activity/class-base-object.php +++ b/includes/activity/class-base-object.php @@ -587,6 +587,13 @@ class Base_Object { } } + // replace 'context' key with '@context' and move it to the top. + if ( array_key_exists( 'context', $array ) ) { + $context = $array['context']; + unset( $array['context'] ); + $array = array_merge( array( '@context' => $context ), $array ); + } + $class = new \ReflectionClass( $this ); $class = strtolower( $class->getShortName() );