PluginProbe
Hostinger Tools / 1.8.1
Hostinger Tools v1.8.1
3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 All 108 releases
hostinger / includes / class-hostinger-config.php

class-hostinger-config.php in Hostinger Tools 1.8.1, at includes/class-hostinger-config.php

33 lines 905 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class Hostinger_Config {
8 private array $config = [];
9 public const TOKEN_HEADER = 'X-Hpanel-Order-Token';
10 public const DOMAIN_HEADER = 'X-Hpanel-Domain';
11 public function __construct() {
12 $this->decode_config( HOSTINGER_WP_CONFIG_PATH );
13 }
14
15 private function decode_config( string $path ): void {
16 if ( file_exists( $path ) ) {
17 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
18 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
19 $filesystem = new WP_Filesystem_Direct( true );
20 $config_content = $filesystem->get_contents( $path );
21 $this->config = json_decode( $config_content, true );
22 }
23 }
24
25 public function get_config_value( string $key, $default ): string {
26 if ( $this->config && isset( $this->config[ $key ] ) ) {
27 return $this->config[ $key ];
28 }
29
30 return $default;
31 }
32 }
33