| @@ -19,13 +19,29 @@ | ||
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function configure_security_settings(): void { |
| 23 | - $hostinger_plugin_settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, array() ); | |
| 23 | + $hostinger_plugin_settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, [] ); | |
| 24 | 24 | |
| 25 | + // Check and set bypass code | |
| 25 | 26 | if ( empty( $hostinger_plugin_settings['bypass_code'] ) ) { |
| 26 | 27 | $hostinger_plugin_settings['bypass_code'] = Helper::generate_bypass_code( 16 ); |
| 27 | - $this->update_plugin_settings( $hostinger_plugin_settings ); | |
| 28 | + $this->update_plugin_settings($hostinger_plugin_settings); | |
| 29 | + } | |
| 30 | + | |
| 31 | + $this->configure_authentication_password(); | |
| 32 | + } | |
| 33 | + | |
| 34 | + public function configure_authentication_password(): void { | |
| 35 | + global $wpdb; | |
| 36 | + $hostinger_plugin_settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, [] ); | |
| 37 | + | |
| 38 | + // Check if website have authentication passwords | |
| 39 | + $existing_passwords = (int)$wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key = %s", '_application_passwords' ) ); | |
| 40 | + | |
| 41 | + if ( $existing_passwords === 0 ) { | |
| 42 | + $hostinger_plugin_settings['disable_authentication_password'] = true; | |
| 43 | + $this->update_plugin_settings($hostinger_plugin_settings); | |
| 28 | 44 | } |
| 29 | 45 | } |
| 30 | 46 | |
| 31 | 47 | private function update_plugin_settings( array $settings ): void { |