PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.5.9
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.5.9
1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / src / Api / Handlers / HostingApiHandler.php
hostinger-reach / src / Api / Handlers Last commit date
ApiHandler.php 2 weeks ago FormsApiHandler.php 4 months ago HostingApiHandler.php 2 months ago IntegrationsApiHandler.php 2 months ago ReachApiHandler.php 2 weeks ago
HostingApiHandler.php
60 lines
1 <?php
2
3 namespace Hostinger\Reach\Api\Handlers;
4
5 use Hostinger\WpHelper\Requests\Client;
6 use Hostinger\Reach\Functions;
7 use WP_REST_Response;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 die;
11 }
12
13 class HostingApiHandler extends ApiHandler {
14
15 private Client $client;
16
17 public function __construct( Functions $functions, Client $client ) {
18 parent::__construct( $functions );
19 $this->client = $client;
20 }
21
22 public function get_domain_details_handler(): WP_REST_Response {
23 // For non Hostinger Users prevent request and just return an empty array.
24 if ( ! $this->get_functions()->is_hostinger_user() ) {
25 return $this->handle_response(
26 array(
27 'response' => array(
28 'code' => 200,
29 ),
30 'body' => wp_json_encode( array() ),
31 )
32 );
33 }
34
35 $siteurl = get_option( 'siteurl' );
36 $domain = apply_filters( 'hostinger_reach_domain', parse_url( $siteurl, PHP_URL_HOST ) );
37 $transient_key = 'hostinger_reach_domain_details_' . md5( $domain );
38 $disable_cache = apply_filters( 'hostinger_reach_disable_rest_cache', false );
39
40 if ( ! $disable_cache ) {
41 $cached_response = get_transient( $transient_key );
42 if ( $cached_response !== false ) {
43 return $this->handle_response( $cached_response );
44 }
45 }
46
47 $response = $this->client->get( '/v3/wordpress/domain-details', array( 'domain' => $domain ) );
48
49 if ( is_wp_error( $response ) ) {
50 return $this->handle_wp_error( $response );
51 }
52
53 if ( ! $disable_cache ) {
54 set_transient( $transient_key, $response, MINUTE_IN_SECONDS );
55 }
56
57 return $this->handle_response( $response );
58 }
59 }
60