Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 18.226.214.156
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : Api.php
<?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 );

    }
}
© 2025 GrazzMean-Shell