| 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->loader->run(); |
| 17 |
} |
| 18 |
|
| 19 |
private function load_dependencies(): void { |
| 20 |
require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-config.php'; |
| 21 |
require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-helper.php'; |
| 22 |
require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-errors.php'; |
| 23 |
require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-settings.php'; |
| 24 |
require_once HOSTINGER_ABSPATH . 'includes/requests/class-hostinger-requests-client.php'; |
| 25 |
|
| 26 |
if ( ! empty( Hostinger_Helper::get_api_token() ) ) { |
| 27 |
require_once HOSTINGER_ABSPATH . 'includes/amplitude/class-hostinger-amplitude-actions.php'; |
| 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'; |
| 32 |
} |
| 33 |
|
| 34 |
$this->load_onboarding_dependencies(); |
| 35 |
$this->load_public_dependencies(); |
| 36 |
|
| 37 |
if ( is_admin() ) { |
| 38 |
$this->load_admin_dependencies(); |
| 39 |
if ( ! empty( Hostinger_Helper::get_api_token() ) ) { |
| 40 |
$this->define_admin_surveys(); |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 45 |
require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-cli.php'; |
| 46 |
} |
| 47 |
|
| 48 |
require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-i18n.php'; |
| 49 |
|
| 50 |
if ( get_option( 'hostinger_maintenance_mode', 0 ) ) { |
| 51 |
require_once HOSTINGER_ABSPATH . 'includes/class-hostinger-coming-soon.php'; |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
private function set_locale() { |
| 56 |
|
| 57 |
$plugin_i18n = new Hostinger_i18n(); |
| 58 |
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
private function load_admin_dependencies(): void { |
| 63 |
require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-assets.php'; |
| 64 |
require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-menu.php'; |
| 65 |
require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-ajax.php'; |
| 66 |
require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-redirect.php'; |
| 67 |
} |
| 68 |
|
| 69 |
private function load_public_dependencies(): void { |
| 70 |
require_once HOSTINGER_ABSPATH . 'includes/public/class-hostinger-public-assets.php'; |
| 71 |
} |
| 72 |
|
| 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 ); |
| 77 |
} |
| 78 |
|
| 79 |
if ( $surveys->is_ai_onboarding_survey_enabled() ) { |
| 80 |
$this->loader->add_action( 'admin_footer', $surveys, 'customer_ai_csat_survey', 10 ); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
private function load_onboarding_dependencies(): void { |
| 85 |
require_once HOSTINGER_ABSPATH . 'includes/admin/class-hostinger-admin-actions.php'; |
| 86 |
require_once HOSTINGER_ABSPATH . 'includes/admin/onboarding/class-hostinger-onboarding-settings.php'; |
| 87 |
|
| 88 |
if ( ! Hostinger_Onboarding_Settings::all_steps_completed() ) { |
| 89 |
require_once HOSTINGER_ABSPATH . 'includes/admin/onboarding/class-hostinger-autocomplete-steps.php'; |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|