PluginProbe
Hostinger Tools / 3.0.39
Hostinger Tools v3.0.39
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
← All changes | includes/DefaultOptions.php +33 -29 3.0.383.0.39 View file →
@@ -7,11 +7,11 @@
7 7
8 8 defined( 'ABSPATH' ) || exit;
9 9
10 10 class DefaultOptions {
11 - /**
12 - * @return void
13 - */
11 + /**
12 + * @return void
13 + */
14 14 public function add_options(): void {
15 15 $this->configure_security_settings();
16 16
17 17 foreach ( $this->options() as $key => $option ) {
@@ -24,50 +24,54 @@
24 24
25 25 // Check and set bypass code
26 26 if ( empty( $hostinger_plugin_settings['bypass_code'] ) ) {
27 27 $hostinger_plugin_settings['bypass_code'] = Helper::generate_bypass_code( 16 );
28 + $this->update_plugin_settings($hostinger_plugin_settings);
28 29 }
29 30
30 - $hostinger_plugin_settings = $this->check_authentication_password( $hostinger_plugin_settings );
31 -
32 - $plugin_options = new PluginOptions( $hostinger_plugin_settings );
33 - update_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, $plugin_options->to_array(), false );
31 + $this->configure_authentication_password();
34 32 }
35 33
36 - public function check_authentication_password( array $settings ): array {
34 + public function configure_authentication_password(): void {
37 35 global $wpdb;
36 + $hostinger_plugin_settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, [] );
38 37
38 + // Check if website have authentication passwords
39 39 $existing_passwords = (int)$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key = %s", '_application_passwords' ) );
40 40
41 41 if ( $existing_passwords === 0 ) {
42 - $settings['disable_authentication_password'] = true;
42 + $hostinger_plugin_settings['disable_authentication_password'] = true;
43 + $this->update_plugin_settings($hostinger_plugin_settings);
43 44 }
45 + }
44 46
45 - return $settings;
47 + private function update_plugin_settings( array $settings ): void {
48 + $plugin_options = new PluginOptions( $settings );
49 + update_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, $plugin_options->to_array(), false );
46 50 }
47 51
48 - /**
49 - * @return string[]
50 - */
51 - private function options(): array {
52 - $options = array(
52 + /**
53 + * @return string[]
54 + */
55 + private function options(): array {
56 + $options = array(
53 57 'optin_monster_api_activation_redirect_disabled' => 'true',
54 58 'wpforms_activation_redirect' => 'true',
55 59 'aioseo_activation_redirect' => 'false',
56 - );
60 + );
57 61
58 - if ( Helper::is_plugin_active( 'astra-sites' ) ) {
59 - $options = array_merge( $options, $this->get_astra_options() );
60 - }
62 + if ( Helper::is_plugin_active( 'astra-sites' ) ) {
63 + $options = array_merge( $options, $this->get_astra_options() );
64 + }
61 65
62 - return $options;
63 - }
66 + return $options;
67 + }
64 68
65 - /**
66 - * @return string[]
67 - */
68 - private function get_astra_options(): array {
69 - return array(
70 - 'astra_sites_settings' => 'gutenberg',
71 - );
72 - }
69 + /**
70 + * @return string[]
71 + */
72 + private function get_astra_options(): array {
73 + return array(
74 + 'astra_sites_settings' => 'gutenberg',
75 + );
76 + }
73 77 }