PluginProbe
Hostinger Tools / 3.0.58
Hostinger Tools v3.0.58
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
hostinger / includes / DefaultOptions.php

DefaultOptions.php in Hostinger Tools 3.0.58, at includes/DefaultOptions.php

76 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hostinger;
4
5 use Hostinger\Admin\Options\PluginOptions;
6 use Hostinger\Helper;
7
8 defined( 'ABSPATH' ) || exit;
9
10 class DefaultOptions {
11 /**
12 * @return void
13 */
14 public function add_options(): void {
15 $this->configure_security_settings();
16
17 foreach ( $this->options() as $key => $option ) {
18 update_option( $key, $option );
19 }
20 }
21
22 public function configure_security_settings(): void {
23 $hostinger_plugin_settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, array() );
24
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
30 $this->configure_authentication_password();
31 }
32
33 public function configure_authentication_password(): void {
34 global $wpdb;
35 $hostinger_plugin_settings = get_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, array() );
36
37 $existing_passwords = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->usermeta} WHERE meta_key = %s", '_application_passwords' ) );
38
39 if ( $existing_passwords === 0 ) {
40 $hostinger_plugin_settings['disable_authentication_password'] = true;
41 $this->update_plugin_settings( $hostinger_plugin_settings );
42 }
43 }
44
45 private function update_plugin_settings( array $settings ): void {
46 $plugin_options = new PluginOptions( $settings );
47 update_option( HOSTINGER_PLUGIN_SETTINGS_OPTION, $plugin_options->to_array(), false );
48 }
49
50 /**
51 * @return string[]
52 */
53 private function options(): array {
54 $options = array(
55 'optin_monster_api_activation_redirect_disabled' => 'true',
56 'wpforms_activation_redirect' => 'true',
57 'aioseo_activation_redirect' => 'false',
58 );
59
60 if ( Helper::is_plugin_active( 'astra-sites' ) ) {
61 $options = array_merge( $options, $this->get_astra_options() );
62 }
63
64 return $options;
65 }
66
67 /**
68 * @return string[]
69 */
70 private function get_astra_options(): array {
71 return array(
72 'astra_sites_settings' => 'gutenberg',
73 );
74 }
75 }
76