HEX
Server: nginx/1.27.1
System: Linux in-4 5.15.0-131-generic #141-Ubuntu SMP Fri Jan 10 21:18:28 UTC 2025 x86_64
User: ilikadirect (1186)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v6964/testingff/public_html/fdfctr/wp-content/plugins/site-reviews/plugin/Api.php
<?php

namespace GeminiLabs\SiteReviews;

use GeminiLabs\SiteReviews\Helper;

class Api
{
    protected const BASE_URL = 'https://api.site-reviews.com/v1/';

    public function args(array $args = []): array
    {
        $args = wp_parse_args($args, [
            'sslverify' => Helper::isLocalServer(),
        ]);
        return glsr()->filterArray('api/args', $args);
     }

    public function baseUrl(): string
    {
        return glsr()->filterString('api/base_url', static::BASE_URL);
    }

    public function get(string $path, array $args = []): Response
    {
        $args['method'] = 'GET';
        return $this->request($path, $args);
    }

    public function post(string $path, array $args = []): Response
    {
        $args['method'] = 'POST';
        return $this->request($path, $args);
    }

    public function request(string $path, array $args = []): Response
    {
        $args = $this->args($args);
        $transient = sprintf('%sapi_%s', glsr()->prefix, sanitize_key($path));
        $response = get_transient($transient);
        if (!empty($response) && empty($args['force'])) { // bypass transient with: $arg['force'] = true
            return new Response($response);
        }
        $response = wp_remote_request($this->url($path), $args);
        if (!is_wp_error($response)) {
            set_transient($transient, $response, DAY_IN_SECONDS);
        }
        return new Response($response);
    }

    public function url(string $path): string
    {
        return trailingslashit($this->baseUrl()).ltrim($path, '/');
    }
}