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