PluginProbe
Hostinger Tools / 2.1.9
Hostinger Tools v2.1.9
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 / Bootstrap.php

Bootstrap.php in Hostinger Tools 2.1.9, at includes/Bootstrap.php

132 lines 3.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\Loader;
6 use Hostinger\Helper;
7 use Hostinger\Settings;
8 use Hostinger\I18n;
9 use Hostinger\Config;
10 use Hostinger\Cli;
11 use Hostinger\Admin\Assets as AdminAssets;
12 use Hostinger\Admin\Hooks as AdminHooks;
13 use Hostinger\Admin\Menu as AdminMenu;
14 use Hostinger\Admin\Ajax as AdminAjax;
15 use Hostinger\Admin\Redirects as AdminRedirects;
16 use Hostinger\Amplitude\Amplitude;
17 use Hostinger\Preview\Assets as PreviewAssets;
18 use Hostinger\Requests\Client;
19 use Hostinger\Admin\Onboarding\Settings as OnboardingSettings;
20 use Hostinger\Surveys\Rest\Rest as SurveysRest;
21 use Hostinger\Surveys\Surveys;
22 use Hostinger\Surveys\Questions as SurveysQuestions;
23 use Hostinger\Admin\Onboarding\AutocompleteSteps;
24
25 defined( 'ABSPATH' ) || exit;
26
27 class Bootstrap {
28 protected Loader $loader;
29
30 public function __construct() {
31 $this->loader = new Loader();
32 }
33
34 public function run(): void {
35 $this->load_dependencies();
36 $this->set_locale();
37 $this->loader->run();
38 }
39
40 private function load_dependencies(): void {
41 $this->load_onboarding_dependencies();
42 $this->load_public_dependencies();
43 $this->amplitude_dependencies();
44
45 if ( is_admin() ) {
46 $this->load_admin_dependencies();
47 if ( ! empty( Helper::get_api_token() ) ) {
48 $this->define_admin_surveys();
49 }
50 }
51
52 if ( defined( 'WP_CLI' ) && WP_CLI ) {
53 new Cli();
54 }
55
56 if ( get_option( 'hostinger_maintenance_mode', 0 ) ) {
57 require_once HOSTINGER_ABSPATH . 'includes/ComingSoon.php';
58 }
59 }
60
61 private function set_locale() {
62
63 $plugin_i18n = new I18n();
64 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
65 }
66
67 private function load_admin_dependencies(): void {
68 new AdminAssets();
69 new AdminHooks();
70 new AdminMenu();
71 new AdminAjax();
72 new AdminRedirects();
73 }
74
75 private function define_admin_surveys(): void {
76 $settings = new Settings();
77 $helper = new Helper();
78 $config_handler = new Config();
79 $survey_questions = new SurveysQuestions();
80 $client = new Client(
81 $config_handler->get_config_value( 'base_rest_uri', HOSTINGER_REST_URI ),
82 array(
83 Config::TOKEN_HEADER => $helper::get_api_token(),
84 Config::DOMAIN_HEADER => $helper->get_host_info(),
85 )
86 );
87 $rest = new SurveysRest( $client );
88 $surveys = new Surveys( $settings, $helper, $config_handler, $survey_questions, $rest );
89
90 switch ( true ) {
91 case $surveys->is_woocommerce_survey_enabled():
92 $survey_function = 'customer_csat_survey';
93 break;
94
95 case $surveys->is_prebuild_website_survey_enabled():
96 $survey_function = 'prebuild_website_survey';
97 break;
98
99 case $surveys->is_ai_onboarding_survey_enabled():
100 $survey_function = 'customer_ai_csat_survey';
101 break;
102
103 case $surveys->is_content_generation_survey_enabled():
104 $survey_function = 'ai_plugin_survey';
105 break;
106
107 case $surveys->is_affiliate_survey_enabled():
108 $survey_function = 'affiliate_plugin_survey';
109 break;
110
111 default:
112 return; // No survey enabled
113 }
114
115 $this->loader->add_action( 'admin_footer', $surveys, $survey_function, 10 );
116 }
117
118 private function load_public_dependencies(): void {
119 new PreviewAssets();
120 }
121
122 private function load_onboarding_dependencies(): void {
123 if ( ! OnboardingSettings::all_steps_completed() ) {
124 new AutocompleteSteps();
125 }
126 }
127
128 private function amplitude_dependencies(): void {
129 new Amplitude();
130 }
131 }
132