| @@ -12,11 +12,18 @@ | ||
| 12 | 12 | |
| 13 | 13 | public function run(): void { |
| 14 | 14 | $this->load_dependencies(); |
| 15 | 15 | $this->set_locale(); |
| 16 | + $this->session_actions(); | |
| 16 | 17 | $this->loader->run(); |
| 17 | 18 | } |
| 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 | + | |
| 19 | 26 | private function load_dependencies(): void { |
| 20 | 27 | require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-config.php'; |
| 21 | 28 | require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-helper.php'; |
| 22 | 29 | require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-errors.php'; |
| @@ -55,31 +62,59 @@ | ||
| 55 | 62 | private function set_locale() { |
| 56 | 63 | |
| 57 | 64 | $plugin_i18n = new Hostinger_i18n(); |
| 58 | 65 | $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
| 59 | - | |
| 60 | 66 | } |
| 61 | 67 | |
| 62 | 68 | private function load_admin_dependencies(): void { |
| 63 | 69 | require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-assets.php'; |
| 70 | + require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-hooks.php'; | |
| 64 | 71 | require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-menu.php'; |
| 65 | 72 | require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-ajax.php'; |
| 66 | 73 | require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-redirect.php'; |
| 67 | 74 | } |
| 68 | 75 | |
| 69 | - private function load_public_dependencies(): void { | |
| 70 | - require_once HOSTINGER_ABSPATH . 'includes/public/class-hostinger-public-assets.php'; | |
| 71 | - } | |
| 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 ); | |
| 72 | 90 | |
| 73 | - private function define_admin_surveys(): void { | |
| 74 | - $surveys = new Hostinger_Surveys(); | |
| 75 | - if ( $surveys->is_woocommerce_survey_enabled() ) { | |
| 76 | - $this->loader->add_action( 'admin_footer', $surveys, 'customer_csat_survey', 10 ); | |
| 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 | |
| 77 | 110 | } |
| 78 | 111 | |
| 79 | - if ( $surveys->is_ai_onboarding_survey_enabled() ) { | |
| 80 | - $this->loader->add_action( 'admin_footer', $surveys, 'customer_ai_csat_survey', 10 ); | |
| 81 | - } | |
| 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'; | |
| 82 | 117 | } |
| 83 | 118 | |
| 84 | 119 | private function load_onboarding_dependencies(): void { |
| 85 | 120 | require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-actions.php'; |