| @@ -1,61 +1,35 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Hostinger; |
| 4 | 4 | |
| 5 | -use Hostinger\Admin\Options\PluginOptions; | |
| 6 | 5 | use Hostinger\Helper; |
| 7 | 6 | |
| 8 | 7 | defined( 'ABSPATH' ) || exit; |
| 9 | 8 | |
| 10 | 9 | class DefaultOptions { |
| 11 | - /** | |
| 12 | - * @return void | |
| 13 | - */ | |
| 14 | - public function add_options(): void { | |
| 15 | - $this->configure_security_settings(); | |
| 10 | + public function add_options(): void { | |
| 11 | + foreach ( $this->options() as $key => $option ) { | |
| 12 | + update_option( $key, $option ); | |
| 13 | + } | |
| 14 | + } | |
| 16 | 15 | |
| 17 | - foreach ( $this->options() as $key => $option ) { | |
| 18 | - update_option( $key, $option ); | |
| 19 | - } | |
| 20 | - } | |
| 16 | + private function options(): array { | |
| 17 | + $options = array( | |
| 18 | + 'optin_monster_api_activation_redirect_disabled' => 'true', | |
| 19 | + 'wpforms_activation_redirect' => 'true', | |
| 20 | + 'aioseo_activation_redirect' => 'false', | |
| 21 | + ); | |
| 21 | 22 | |
| 22 | - public function configure_security_settings(): void { | |
| 23 | - $hostinger_plugin_settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, array() ); | |
| 23 | + if ( Helper::is_plugin_active( 'astra-sites' ) ) { | |
| 24 | + $options = array_merge( $options, $this->get_astra_options() ); | |
| 25 | + } | |
| 24 | 26 | |
| 25 | - if ( empty( $hostinger_plugin_settings['bypass_code'] ) ) { | |
| 26 | - $hostinger_plugin_settings['bypass_code'] = Helper::generate_bypass_code( 16 ); | |
| 27 | - $this->update_plugin_settings( $hostinger_plugin_settings ); | |
| 28 | - } | |
| 29 | - } | |
| 27 | + return $options; | |
| 28 | + } | |
| 30 | 29 | |
| 31 | - private function update_plugin_settings( array $settings ): void { | |
| 32 | - $plugin_options = new PluginOptions( $settings ); | |
| 33 | - update_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, $plugin_options->to_array(), false ); | |
| 34 | - } | |
| 35 | - | |
| 36 | - /** | |
| 37 | - * @return string[] | |
| 38 | - */ | |
| 39 | - private function options(): array { | |
| 40 | - $options = array( | |
| 41 | - 'optin_monster_api_activation_redirect_disabled' => 'true', | |
| 42 | - 'wpforms_activation_redirect' => 'true', | |
| 43 | - 'aioseo_activation_redirect' => 'false', | |
| 44 | - ); | |
| 45 | - | |
| 46 | - if ( Helper::is_plugin_active( 'astra-sites' ) ) { | |
| 47 | - $options = array_merge( $options, $this->get_astra_options() ); | |
| 48 | - } | |
| 49 | - | |
| 50 | - return $options; | |
| 51 | - } | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * @return string[] | |
| 55 | - */ | |
| 56 | - private function get_astra_options(): array { | |
| 57 | - return array( | |
| 58 | - 'astra_sites_settings' => 'gutenberg', | |
| 59 | - ); | |
| 60 | - } | |
| 30 | + private function get_astra_options(): array { | |
| 31 | + return array( | |
| 32 | + 'astra_sites_settings' => 'gutenberg', | |
| 33 | + ); | |
| 34 | + } | |
| 61 | 35 | } |