| @@ -121,9 +121,9 @@ | ||
| 121 | 121 | } |
| 122 | 122 | if ( isset( $this->_args['additional_headers'] ) ) { |
| 123 | 123 | $this->_additional_headers = $this->_args['additional_headers']; |
| 124 | 124 | } |
| 125 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Constructor called for params = %s', print_r( $params, true ) ), 'debug', __FILE__, __LINE__ ); | |
| 125 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'JSON source initialized.', 'debug', __FILE__, __LINE__ ); | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * Get the root elements for JSON-endpoint. |
| @@ -282,9 +282,9 @@ | ||
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | $this->_data = $data; |
| 285 | 285 | |
| 286 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Parsed data endpoint %s with root %s is %s', $this->_url, $this->_root, print_r( $data, true ) ), 'debug', __FILE__, __LINE__ ); | |
| 286 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'JSON endpoint data parsed.', 'debug', __FILE__, __LINE__ ); | |
| 287 | 287 | |
| 288 | 288 | return true; |
| 289 | 289 | } |
| 290 | 290 | |
| @@ -378,9 +378,9 @@ | ||
| 378 | 378 | $root = $this->getRootElements( $now, $key, $root, $value ); |
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | 381 | $roots = array_unique( $root ); |
| 382 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Roots found for %s = %s', $this->_url, print_r( $roots, true ) ), 'debug', __FILE__, __LINE__ ); | |
| 382 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'JSON root elements parsed.', 'debug', __FILE__, __LINE__ ); | |
| 383 | 383 | return $roots; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
| @@ -396,9 +396,10 @@ | ||
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | $response = $this->connect( $url ); |
| 399 | 399 | if ( is_wp_error( $response ) || ! in_array( intval( $response['response']['code'] ), array( 200, 201 ), true ) ) { |
| 400 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Error while fetching JSON endpoint %s = %s', $url, print_r( $response, true ) ), 'error', __FILE__, __LINE__ ); | |
| 400 | + $error_code = is_wp_error( $response ) ? $response->get_error_code() : (string) wp_remote_retrieve_response_code( $response ); | |
| 401 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Error while fetching JSON endpoint: %s', $error_code ), 'error', __FILE__, __LINE__ ); | |
| 401 | 402 | return null; |
| 402 | 403 | } |
| 403 | 404 | |
| 404 | 405 | // this filter can be used to rearrange columns e.g. in candlestick charts |
| @@ -407,9 +408,9 @@ | ||
| 407 | 408 | $response_body = wp_remote_retrieve_body( $response ); |
| 408 | 409 | $response_body = preg_replace( "/^$bom/", '', $response_body ); |
| 409 | 410 | $array = apply_filters( 'visualizer_json_massage_data', json_decode( $response_body, true ), $url ); |
| 410 | 411 | |
| 411 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'JSON array for the endpoint is %s = ', print_r( $array, true ) ), 'debug', __FILE__, __LINE__ ); | |
| 412 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, 'JSON response decoded.', 'debug', __FILE__, __LINE__ ); | |
| 412 | 413 | |
| 413 | 414 | return $array; |
| 414 | 415 | } |
| 415 | 416 | |
| @@ -466,10 +467,10 @@ | ||
| 466 | 467 | } |
| 467 | 468 | $args['headers']['X-Visualizer-Token'] = $token; |
| 468 | 469 | } |
| 469 | 470 | |
| 470 | - do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Connecting to %s with args = %s ', $url, print_r( $args, true ) ), 'debug', __FILE__, __LINE__ ); | |
| 471 | - return wp_remote_request( $url, $args ); | |
| 471 | + do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Connecting to JSON endpoint with method %s', $args['method'] ), 'debug', __FILE__, __LINE__ ); | |
| 472 | + return Visualizer_Remote_Fetch::request( $url, $args ); | |
| 472 | 473 | } |
| 473 | 474 | |
| 474 | 475 | /** |
| 475 | 476 | * Refresh the data for the provided series. |