PluginProbe
Hostinger Tools / 3.0.79
Hostinger Tools v3.0.79
3.0.79 3.0.78 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 All 110 releases
hostinger / includes / DefaultOptions.php

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

75 lines 2.0 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\PluginSettings;
6 use Hostinger\Helper;
7
8 defined( 'ABSPATH' ) || exit;
9
10 class DefaultOptions {
11
12 private PluginSettings $plugin_settings;
13
14 public function __construct( PluginSettings $plugin_settings ) {
15 $this->plugin_settings = $plugin_settings;
16 }
17
18 public function add_options(): void {
19 $this->configure_plugin_settings();
20
21 foreach ( $this->options() as $key => $option ) {
22 update_option( $key, $option );
23 }
24 }
25
26 /**
27 * A later activation must never override a choice the site owner has already made.
28 */
29 private function configure_plugin_settings(): void {
30 $is_first_setup = ! $this->plugin_settings->has_stored_settings();
31 $plugin_options = $this->plugin_settings->get_plugin_settings();
32 $needs_bypass_code = empty( $plugin_options->get_bypass_code() );
33
34 if ( ! $is_first_setup && ! $needs_bypass_code ) {
35 return;
36 }
37
38 if ( $is_first_setup ) {
39 $plugin_options->set_enable_llms_txt( true );
40 }
41
42 if ( $needs_bypass_code ) {
43 $plugin_options->set_bypass_code( Helper::generate_bypass_code( 16 ) );
44 }
45
46 $this->plugin_settings->save_plugin_settings( $plugin_options );
47 }
48
49 /**
50 * @return string[]
51 */
52 private function options(): array {
53 $options = array(
54 'optin_monster_api_activation_redirect_disabled' => 'true',
55 'wpforms_activation_redirect' => 'true',
56 'aioseo_activation_redirect' => 'false',
57 );
58
59 if ( Helper::is_plugin_active( 'astra-sites' ) ) {
60 $options = array_merge( $options, $this->get_astra_options() );
61 }
62
63 return $options;
64 }
65
66 /**
67 * @return string[]
68 */
69 private function get_astra_options(): array {
70 return array(
71 'astra_sites_settings' => 'gutenberg',
72 );
73 }
74 }
75