PluginProbe
Hostinger Tools / 2.1.1
Hostinger Tools v2.1.1
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 / class-hostinger-bootstrap.php

class-hostinger-bootstrap.php in Hostinger Tools 2.1.1, at includes/class-hostinger-bootstrap.php

128 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined( 'ABSPATH' ) || exit;
4
5 class Hostinger_Bootstrap {
6 protected Hostinger_Loader $loader;
7
8 public function __construct() {
9 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-loader.php';
10 $this->loader = new Hostinger_Loader();
11 }
12
13 public function run(): void {
14 $this->load_dependencies();
15 $this->set_locale();
16 $this->session_actions();
17 $this->loader->run();
18 }
19
20 public function session_actions() {
21 $helper = new Hostinger_Helper();
22 $this->loader->add_action( 'init', $helper, 'register_session' );
23 $this->loader->add_action( 'wp_logout', $helper, 'destroy_session' );
24 }
25
26 private function load_dependencies(): void {
27 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-config.php';
28 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-helper.php';
29 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-errors.php';
30 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-settings.php';
31 require_once HOSTINGER_ABSPATH . 'includes/requests/class-hostinger-requests-client.php';
32
33 if ( ! empty( Hostinger_Helper::get_api_token() ) ) {
34 require_once HOSTINGER_ABSPATH . 'includes/amplitude/class-hostinger-amplitude-actions.php';
35 require_once HOSTINGER_ABSPATH . 'includes/amplitude/class-hostinger-amplitude.php';
36 require_once HOSTINGER_ABSPATH . 'includes/surveys/class-hostinger-surveys-questions.php';
37 require_once HOSTINGER_ABSPATH . 'includes/surveys/Rest/class-hostinger-surveys-rest.php';
38 require_once HOSTINGER_ABSPATH . 'includes/surveys/class-hostinger-surveys.php';
39 }
40
41 $this->load_onboarding_dependencies();
42 $this->load_public_dependencies();
43
44 if ( is_admin() ) {
45 $this->load_admin_dependencies();
46 if ( ! empty( Hostinger_Helper::get_api_token() ) ) {
47 $this->define_admin_surveys();
48 }
49 }
50
51 if ( defined( 'WP_CLI' ) && WP_CLI ) {
52 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-cli.php';
53 }
54
55 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-i18n.php';
56
57 if ( get_option( 'hostinger_maintenance_mode', 0 ) ) {
58 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-coming-soon.php';
59 }
60 }
61
62 private function set_locale() {
63
64 $plugin_i18n = new Hostinger_i18n();
65 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
66 }
67
68 private function load_admin_dependencies(): void {
69 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-assets.php';
70 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-hooks.php';
71 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-menu.php';
72 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-ajax.php';
73 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-redirect.php';
74 }
75
76 private function define_admin_surveys(): void {
77 $settings = new Hostinger_Settings();
78 $helper = new Hostinger_Helper();
79 $config_handler = new Hostinger_Config();
80 $survey_questions = new Hostinger_Surveys_Questions();
81 $client = new Hostinger_Requests_Client(
82 $config_handler->get_config_value( 'base_rest_uri', HOSTINGER_REST_URI ),
83 array(
84 Hostinger_Config::TOKEN_HEADER => $helper::get_api_token(),
85 Hostinger_Config::DOMAIN_HEADER => $helper->get_host_info(),
86 )
87 );
88 $rest = new Hostinger_Surveys_Rest( $client );
89 $surveys = new Hostinger_Surveys( $settings, $helper, $config_handler, $survey_questions, $rest );
90
91 switch ( true ) {
92 case $surveys->is_woocommerce_survey_enabled():
93 $survey_function = 'customer_csat_survey';
94 break;
95
96 case $surveys->is_ai_onboarding_survey_enabled():
97 $survey_function = 'customer_ai_csat_survey';
98 break;
99
100 case $surveys->is_content_generation_survey_enabled():
101 $survey_function = 'ai_plugin_survey';
102 break;
103
104 case $surveys->is_affiliate_survey_enabled():
105 $survey_function = 'affiliate_plugin_survey';
106 break;
107
108 default:
109 return; // No survey enabled
110 }
111
112 $this->loader->add_action( 'admin_footer', $surveys, $survey_function, 10 );
113 }
114
115 private function load_public_dependencies(): void {
116 require_once HOSTINGER_ABSPATH . 'includes/public/class-hostinger-public-assets.php';
117 }
118
119 private function load_onboarding_dependencies(): void {
120 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-actions.php';
121 require_once HOSTINGER_ABSPATH . 'includes/admin/onboarding/class-hostinger-onboarding-settings.php';
122
123 if ( ! Hostinger_Onboarding_Settings::all_steps_completed() ) {
124 require_once HOSTINGER_ABSPATH . 'includes/admin/onboarding/class-hostinger-autocomplete-steps.php';
125 }
126 }
127 }
128