PluginProbe
Hostinger Tools / 2.1.5
Hostinger Tools v2.1.5
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.5, at includes/Bootstrap.php

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