REDROOM
PHP 8.0.30
Path:
Logout
Edit File
Size: 2.72 KB
Close
/home/certprox/template.certproxywizard.com/wp-content/plugins/hostinger-reach/src/Api/Handlers/ApiHandler.php
Text
Base64
<?php namespace Hostinger\Reach\Api\Handlers; use Hostinger\Reach\Functions; use WP_Error; use WP_Http; use WP_REST_Response; if ( ! defined( 'ABSPATH' ) ) { die; } class ApiHandler { private array $default_headers = array(); protected string $api_base_name; private Functions $functions; public function __construct( Functions $functions ) { $this->functions = $functions; } public function get_functions(): Functions { return $this->functions; } public function get_api_basename(): string { return $this->api_base_name; } public function get_default_headers(): array { return $this->default_headers; } public function get_generic_error_message(): string { return __( 'Something went wrong. Please try again.', 'hostinger-reach' ); } public function get( string $endpoint, array $params = array(), array $headers = array(), int $timeout = 120 ): WP_Error|array { $url = $this->get_api_basename() . $endpoint; $request_args = array( 'method' => 'GET', 'headers' => array_merge( $this->get_default_headers(), $headers ), 'timeout' => $timeout, ); if ( ! empty( $params ) ) { $url = add_query_arg( $params, $url ); } return wp_remote_get( $url, $request_args ); } public function post( string $endpoint, array $params = array(), array $headers = array(), int $timeout = 120 ): mixed { $url = $this->get_api_basename() . $endpoint; $request_args = array( 'method' => 'POST', 'timeout' => $timeout, 'headers' => array_merge( $this->get_default_headers(), $headers ), 'body' => $params, ); return wp_remote_post( $url, $request_args ); } public function handle_wp_error( WP_Error $error ): WP_REST_Response { $response = new WP_REST_Response(); $error_data = $error->get_error_data() ?? array( 'status' => WP_Http::BAD_REQUEST ); if ( current_user_can( 'manage_options' ) ) { $response->set_data( array( 'errors' => $error->get_error_code() ) ); } else { $response->set_data( array( 'errors' => $this->get_generic_error_message() ) ); } $response->set_status( $error_data['status'] ); return $response; } public function handle_response( array $response ): WP_REST_Response { $wp_response = new WP_REST_Response(); $wp_response->set_status( wp_remote_retrieve_response_code( $response ) ); $body = wp_remote_retrieve_body( $response ); $wp_response->set_data( json_decode( $body ? $body : '', true ) ); return $wp_response; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 5
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
ApiHandler.php
2.72 KB
lrw-r--r--
2026-06-10 16:30:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
FormsApiHandler.php
3.39 KB
lrw-r--r--
2026-06-10 16:30:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
HostingApiHandler.php
1.82 KB
lrw-r--r--
2026-06-10 16:30:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
IntegrationsApiHandler.php
8.74 KB
lrw-r--r--
2026-06-10 16:30:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ReachApiHandler.php
16.09 KB
lrw-r--r--
2026-06-10 16:30:29
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).