PluginProbe
Hostinger Tools / 2.0.7
Hostinger Tools v2.0.7
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
← All changes | includes/class-hostinger-bootstrap.php +45 -1 2.0.42.0.7 View file →
@@ -25,8 +25,11 @@
25 25
26 26 if ( ! empty( Hostinger_Helper::get_api_token() ) ) {
27 27 require_once HOSTINGER_ABSPATH . 'includes/amplitude/class-hostinger-amplitude-actions.php';
28 28 require_once HOSTINGER_ABSPATH . 'includes/amplitude/class-hostinger-amplitude.php';
29 + require_once HOSTINGER_ABSPATH . 'includes/surveys/class-hostinger-surveys-questions.php';
30 + require_once HOSTINGER_ABSPATH . 'includes/surveys/Rest/class-hostinger-surveys-rest.php';
31 + require_once HOSTINGER_ABSPATH . 'includes/surveys/class-hostinger-surveys.php';
29 32 }
30 33
31 34 $this->load_onboarding_dependencies();
32 35 $this->load_public_dependencies();
@@ -32,8 +35,11 @@
32 35 $this->load_public_dependencies();
33 36
34 37 if ( is_admin() ) {
35 38 $this->load_admin_dependencies();
39 + if ( ! empty( Hostinger_Helper::get_api_token() ) ) {
40 + $this->define_admin_surveys();
41 + }
36 42 }
37 43
38 44 if ( defined( 'WP_CLI' ) && WP_CLI ) {
39 45 require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-cli.php';
@@ -49,9 +55,8 @@
49 55 private function set_locale() {
50 56
51 57 $plugin_i18n = new Hostinger_i18n();
52 58 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
53 -
54 59 }
55 60
56 61 private function load_admin_dependencies(): void {
57 62 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-assets.php';
@@ -58,8 +63,47 @@
58 63 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-hooks.php';
59 64 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-menu.php';
60 65 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-ajax.php';
61 66 require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-redirect.php';
67 + }
68 +
69 + private function define_admin_surveys(): void {
70 + $settings = new Hostinger_Settings();
71 + $helper = new Hostinger_Helper();
72 + $config_handler = new Hostinger_Config();
73 + $survey_questions = new Hostinger_Surveys_Questions();
74 + $client = new Hostinger_Requests_Client(
75 + $config_handler->get_config_value( 'base_rest_uri', HOSTINGER_REST_URI ),
76 + array(
77 + Hostinger_Config::TOKEN_HEADER => $helper::get_api_token(),
78 + Hostinger_Config::DOMAIN_HEADER => $helper->get_host_info(),
79 + )
80 + );
81 + $rest = new Hostinger_Surveys_Rest( $client );
82 + $surveys = new Hostinger_Surveys( $settings, $helper, $config_handler, $survey_questions, $rest );
83 +
84 + switch (true) {
85 + case $surveys->is_woocommerce_survey_enabled():
86 + $survey_function = 'customer_csat_survey';
87 + break;
88 +
89 + case $surveys->is_ai_onboarding_survey_enabled():
90 + $survey_function = 'customer_ai_csat_survey';
91 + break;
92 +
93 + case $surveys->is_content_generation_survey_enabled():
94 + $survey_function = 'ai_plugin_survey';
95 + break;
96 +
97 + case $surveys->is_affiliate_survey_enabled():
98 + $survey_function = 'affiliate_plugin_survey';
99 + break;
100 +
101 + default:
102 + return; // No survey enabled
103 + }
104 +
105 + $this->loader->add_action('admin_footer', $surveys, $survey_function, 10);
62 106 }
63 107
64 108 private function load_public_dependencies(): void {
65 109 require_once HOSTINGER_ABSPATH . 'includes/public/class-hostinger-public-assets.php';