From 136e19105b0d38b04c2c6d9714b7726ad08932d6 Mon Sep 17 00:00:00 2001 From: Ashish Ravi Date: Mon, 23 Mar 2020 11:50:07 +0530 Subject: [PATCH] JSON: Add ability to manipulate data before processing --- classes/Visualizer/Source/Json.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/classes/Visualizer/Source/Json.php b/classes/Visualizer/Source/Json.php index f06bd348..2945c49e 100644 --- a/classes/Visualizer/Source/Json.php +++ b/classes/Visualizer/Source/Json.php @@ -389,7 +389,9 @@ private function getJSON( $url = null ) { return null; } - $array = json_decode( wp_remote_retrieve_body( $response ), true ); + // this filter can be used to rearrange columns e.g. in candlestick charts + // or to add additional data to the root. + $array = apply_filters( 'visualizer_json_massage_data', json_decode( wp_remote_retrieve_body( $response ), true ), $url ); do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'JSON array for the endpoint is %s = ', print_r( $array, true ) ), 'debug', __FILE__, __LINE__ );