| @@ -4,10 +4,10 @@ | ||
| 4 | 4 | exit; |
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | class Hostinger_Config { |
| 8 | - private array $config = []; | |
| 9 | - public const TOKEN_HEADER = 'X-Hpanel-Order-Token'; | |
| 8 | + private array $config = array(); | |
| 9 | + public const TOKEN_HEADER = 'X-Hpanel-Order-Token'; | |
| 10 | 10 | public const DOMAIN_HEADER = 'X-Hpanel-Domain'; |
| 11 | 11 | public function __construct() { |
| 12 | 12 | $this->decode_config( HOSTINGER_WP_CONFIG_PATH ); |
| 13 | 13 | } |
| @@ -13,18 +13,15 @@ | ||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | private function decode_config( string $path ): void { |
| 16 | 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 ); | |
| 17 | + $config_content = file_get_contents( $path ); | |
| 21 | 18 | $this->config = json_decode( $config_content, true ); |
| 22 | 19 | } |
| 23 | 20 | } |
| 24 | 21 | |
| 25 | 22 | public function get_config_value( string $key, $default ): string { |
| 26 | - if ( $this->config && isset( $this->config[ $key ] ) ) { | |
| 23 | + if ( $this->config && isset( $this->config[ $key ] ) && ! empty( $this->config[ $key ] ) ) { | |
| 27 | 24 | return $this->config[ $key ]; |
| 28 | 25 | } |
| 29 | 26 | |
| 30 | 27 | return $default; |