| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Hostinger\Admin\Options; |
| 3 | 3 | |
| 4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | - die; | |
| 5 | + die; | |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Class for handling plugin options |
| @@ -8,186 +8,133 @@ | ||
| 8 | 8 | /** |
| 9 | 9 | * Class for handling plugin options |
| 10 | 10 | */ |
| 11 | 11 | class PluginOptions { |
| 12 | - /** | |
| 13 | - * @var bool | |
| 14 | - */ | |
| 15 | - private bool $maintenance_mode = false; | |
| 12 | + /** | |
| 13 | + * @var bool | |
| 14 | + */ | |
| 15 | + private bool $maintenance_mode = false; | |
| 16 | 16 | |
| 17 | - /** | |
| 18 | - * @var string | |
| 19 | - */ | |
| 20 | - private string $bypass_code = ''; | |
| 17 | + /** | |
| 18 | + * @var string | |
| 19 | + */ | |
| 20 | + private string $bypass_code = ''; | |
| 21 | 21 | |
| 22 | - /** | |
| 23 | - * @var bool | |
| 24 | - */ | |
| 25 | - private bool $disable_xml_rpc = false; | |
| 22 | + /** | |
| 23 | + * @var bool | |
| 24 | + */ | |
| 25 | + private bool $disable_xml_rpc = false; | |
| 26 | 26 | |
| 27 | - /** | |
| 28 | - * @var bool | |
| 29 | - */ | |
| 30 | - private bool $force_https = false; | |
| 27 | + /** | |
| 28 | + * @var bool | |
| 29 | + */ | |
| 30 | + private bool $force_https = false; | |
| 31 | 31 | |
| 32 | - /** | |
| 33 | - * @var bool | |
| 34 | - */ | |
| 35 | - private bool $force_www = false; | |
| 32 | + /** | |
| 33 | + * @var bool | |
| 34 | + */ | |
| 35 | + private bool $force_www = false; | |
| 36 | 36 | |
| 37 | - /** | |
| 38 | - * @var bool | |
| 39 | - */ | |
| 40 | - private bool $disable_authentication_password = false; | |
| 37 | + /** | |
| 38 | + * @param array $settings plugin settings array. | |
| 39 | + */ | |
| 40 | + public function __construct( array $settings = array() ) { | |
| 41 | + $this->maintenance_mode = ! empty( $settings['maintenance_mode'] ); | |
| 42 | + $this->bypass_code = ! empty( $settings['bypass_code'] ) ? $settings['bypass_code'] : ''; | |
| 43 | + $this->disable_xml_rpc = ! empty( $settings['disable_xml_rpc'] ); | |
| 44 | + $this->force_https = ! empty( $settings['force_https'] ); | |
| 45 | + $this->force_www = ! empty( $settings['force_www'] ); | |
| 46 | + } | |
| 41 | 47 | |
| 42 | - /** | |
| 43 | - * @var bool | |
| 44 | - */ | |
| 45 | - private bool $enable_llms_txt = false; | |
| 48 | + /** | |
| 49 | + * @return bool | |
| 50 | + */ | |
| 51 | + public function get_maintenance_mode(): bool { | |
| 52 | + return $this->maintenance_mode; | |
| 53 | + } | |
| 46 | 54 | |
| 47 | - /** | |
| 48 | - * @var bool | |
| 49 | - */ | |
| 50 | - private bool $optin_mcp = false; | |
| 55 | + /** | |
| 56 | + * @param bool $maintenance_mode | |
| 57 | + * | |
| 58 | + * @return void | |
| 59 | + */ | |
| 60 | + public function set_maintenance_mode( bool $maintenance_mode ): void { | |
| 61 | + $this->maintenance_mode = $maintenance_mode; | |
| 62 | + } | |
| 51 | 63 | |
| 52 | - /** | |
| 53 | - * @param array $settings plugin settings array. | |
| 54 | - */ | |
| 55 | - public function __construct( array $settings = array() ) { | |
| 56 | - $this->maintenance_mode = ! empty( $settings['maintenance_mode'] ); | |
| 57 | - $this->bypass_code = ! empty( $settings['bypass_code'] ) ? $settings['bypass_code'] : ''; | |
| 58 | - $this->disable_xml_rpc = ! empty( $settings['disable_xml_rpc'] ); | |
| 59 | - $this->force_https = ! empty( $settings['force_https'] ); | |
| 60 | - $this->force_www = ! empty( $settings['force_www'] ); | |
| 61 | - $this->disable_authentication_password = ! empty( $settings['disable_authentication_password'] ); | |
| 62 | - $this->enable_llms_txt = ! empty( $settings['enable_llms_txt'] ); | |
| 63 | - $this->optin_mcp = ! empty( $settings['optin_mcp'] ); | |
| 64 | - } | |
| 64 | + /** | |
| 65 | + * @return string | |
| 66 | + */ | |
| 67 | + public function get_bypass_code(): string { | |
| 68 | + return $this->bypass_code; | |
| 69 | + } | |
| 65 | 70 | |
| 66 | - /** | |
| 67 | - * @return bool | |
| 68 | - */ | |
| 69 | - public function get_maintenance_mode(): bool { | |
| 70 | - return $this->maintenance_mode; | |
| 71 | - } | |
| 71 | + /** | |
| 72 | + * @param string $bypass_code | |
| 73 | + * | |
| 74 | + * @return void | |
| 75 | + */ | |
| 76 | + public function set_bypass_code( string $bypass_code ): void { | |
| 77 | + $this->bypass_code = $bypass_code; | |
| 78 | + } | |
| 72 | 79 | |
| 73 | - /** | |
| 74 | - * @param bool $maintenance_mode | |
| 75 | - * | |
| 76 | - * @return void | |
| 77 | - */ | |
| 78 | - public function set_maintenance_mode( bool $maintenance_mode ): void { | |
| 79 | - $this->maintenance_mode = $maintenance_mode; | |
| 80 | - } | |
| 80 | + /** | |
| 81 | + * @return bool | |
| 82 | + */ | |
| 83 | + public function get_disable_xml_rpc(): bool { | |
| 84 | + return $this->disable_xml_rpc; | |
| 85 | + } | |
| 81 | 86 | |
| 82 | - /** | |
| 83 | - * @return string | |
| 84 | - */ | |
| 85 | - public function get_bypass_code(): string { | |
| 86 | - return $this->bypass_code; | |
| 87 | - } | |
| 87 | + /** | |
| 88 | + * @param bool $disable_xml_rpc | |
| 89 | + * | |
| 90 | + * @return void | |
| 91 | + */ | |
| 92 | + public function set_disable_xml_rpc( bool $disable_xml_rpc ): void { | |
| 93 | + $this->disable_xml_rpc = $disable_xml_rpc; | |
| 94 | + } | |
| 88 | 95 | |
| 89 | - /** | |
| 90 | - * @param string $bypass_code | |
| 91 | - * | |
| 92 | - * @return void | |
| 93 | - */ | |
| 94 | - public function set_bypass_code( string $bypass_code ): void { | |
| 95 | - $this->bypass_code = $bypass_code; | |
| 96 | - } | |
| 96 | + /** | |
| 97 | + * @return bool | |
| 98 | + */ | |
| 99 | + public function get_force_https(): bool { | |
| 100 | + return $this->force_https; | |
| 101 | + } | |
| 97 | 102 | |
| 98 | - /** | |
| 99 | - * @return bool | |
| 100 | - */ | |
| 101 | - public function get_disable_xml_rpc(): bool { | |
| 102 | - return $this->disable_xml_rpc; | |
| 103 | - } | |
| 103 | + /** | |
| 104 | + * @param bool $force_https | |
| 105 | + * | |
| 106 | + * @return void | |
| 107 | + */ | |
| 108 | + public function set_force_https( bool $force_https ): void { | |
| 109 | + $this->force_https = $force_https; | |
| 110 | + } | |
| 104 | 111 | |
| 105 | - /** | |
| 106 | - * @param bool $disable_xml_rpc | |
| 107 | - * | |
| 108 | - * @return void | |
| 109 | - */ | |
| 110 | - public function set_disable_xml_rpc( bool $disable_xml_rpc ): void { | |
| 111 | - $this->disable_xml_rpc = $disable_xml_rpc; | |
| 112 | - } | |
| 112 | + /** | |
| 113 | + * @return bool | |
| 114 | + */ | |
| 115 | + public function get_force_www(): bool { | |
| 116 | + return $this->force_www; | |
| 117 | + } | |
| 113 | 118 | |
| 114 | - /** | |
| 115 | - * @return bool | |
| 116 | - */ | |
| 117 | - public function get_force_https(): bool { | |
| 118 | - return $this->force_https; | |
| 119 | - } | |
| 119 | + /** | |
| 120 | + * @param bool $force_www | |
| 121 | + * | |
| 122 | + * @return void | |
| 123 | + */ | |
| 124 | + public function set_force_www( bool $force_www ): void { | |
| 125 | + $this->force_www = $force_www; | |
| 126 | + } | |
| 120 | 127 | |
| 121 | - /** | |
| 122 | - * @param bool $force_https | |
| 123 | - * | |
| 124 | - * @return void | |
| 125 | - */ | |
| 126 | - public function set_force_https( bool $force_https ): void { | |
| 127 | - $this->force_https = $force_https; | |
| 128 | - } | |
| 129 | - | |
| 130 | - /** | |
| 131 | - * @return bool | |
| 132 | - */ | |
| 133 | - public function get_force_www(): bool { | |
| 134 | - return $this->force_www; | |
| 135 | - } | |
| 136 | - | |
| 137 | - /** | |
| 138 | - * @param bool $force_www | |
| 139 | - * | |
| 140 | - * @return void | |
| 141 | - */ | |
| 142 | - public function set_force_www( bool $force_www ): void { | |
| 143 | - $this->force_www = $force_www; | |
| 144 | - } | |
| 145 | - | |
| 146 | - /** | |
| 147 | - * @return bool | |
| 148 | - */ | |
| 149 | - public function get_disable_authentication_password(): bool { | |
| 150 | - return $this->disable_authentication_password; | |
| 151 | - } | |
| 152 | - | |
| 153 | - /** | |
| 154 | - * @param bool $authentication_password | |
| 155 | - * | |
| 156 | - * @return void | |
| 157 | - */ | |
| 158 | - public function set_disable_authentication_password( bool $authentication_password ): void { | |
| 159 | - $this->disable_authentication_password = $authentication_password; | |
| 160 | - } | |
| 161 | - | |
| 162 | - public function get_enable_llms_txt(): bool { | |
| 163 | - return $this->enable_llms_txt; | |
| 164 | - } | |
| 165 | - | |
| 166 | - public function set_enable_llms_txt( bool $llmstxt_enabled ): void { | |
| 167 | - $this->enable_llms_txt = $llmstxt_enabled; | |
| 168 | - } | |
| 169 | - | |
| 170 | - public function get_optin_mcp(): bool { | |
| 171 | - return $this->optin_mcp; | |
| 172 | - } | |
| 173 | - | |
| 174 | - public function set_optin_mcp( bool $optin_mcp ): void { | |
| 175 | - $this->optin_mcp = $optin_mcp; | |
| 176 | - } | |
| 177 | - | |
| 178 | - /** | |
| 179 | - * @return array | |
| 180 | - */ | |
| 181 | - public function to_array(): array { | |
| 182 | - return array( | |
| 183 | - 'maintenance_mode' => $this->get_maintenance_mode(), | |
| 184 | - 'bypass_code' => $this->get_bypass_code(), | |
| 185 | - 'disable_xml_rpc' => $this->get_disable_xml_rpc(), | |
| 186 | - 'force_https' => $this->get_force_https(), | |
| 187 | - 'force_www' => $this->get_force_www(), | |
| 188 | - 'disable_authentication_password' => $this->get_disable_authentication_password(), | |
| 189 | - 'enable_llms_txt' => $this->get_enable_llms_txt(), | |
| 190 | - 'optin_mcp' => $this->get_optin_mcp(), | |
| 191 | - ); | |
| 192 | - } | |
| 128 | + /** | |
| 129 | + * @return array | |
| 130 | + */ | |
| 131 | + public function to_array(): array { | |
| 132 | + return array( | |
| 133 | + 'maintenance_mode' => $this->get_maintenance_mode(), | |
| 134 | + 'bypass_code' => $this->get_bypass_code(), | |
| 135 | + 'disable_xml_rpc' => $this->get_disable_xml_rpc(), | |
| 136 | + 'force_https' => $this->get_force_https(), | |
| 137 | + 'force_www' => $this->get_force_www(), | |
| 138 | + ); | |
| 139 | + } | |
| 193 | 140 | } |