![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/store.cartinsight.co/wp-content/themes/woodmart/inc/classes/ |
<?php if ( ! defined( 'WOODMART_THEME_DIR' ) ) exit( 'No direct script access allowed' ); /** * Communicate with server API (activate, update) */ class WOODMART_Api { public $token = ''; public $base_url; public $url = ''; public function __construct() { $this->base_url = WOODMART_API_URL; } public function call($method, $data = array() ) { $response = wp_remote_get( $this->get_url($method, $data), array( 'headers' => $this->get_headers(), ) ); return $response; } public function get_headers() { if( empty( $this->token ) ) return array(); return array( 'Authorization' => 'Bearer ' . $this->token ); } public function get_url( $method, $args = array() ) { $this->url = $this->base_url; $this->url .= $method; if( ! empty( $args ) ) { foreach ($args as $key => $value) { $this->add_url_param($key, $value); } } return $this->url; } public function add_url_param( $key, $value ) { $this->url = add_query_arg( $key, $value, $this->url ); } }