PluginProbe
Hostinger Tools / 2.2.1
Hostinger Tools v2.2.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 / Admin / Assets.php

Assets.php in Hostinger Tools 2.2.1, at includes/Admin/Assets.php

108 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hostinger\Admin;
4
5 use Hostinger\Helper;
6
7 defined( 'ABSPATH' ) || exit;
8
9 /**
10 * Class Hostinger_Admin_Assets
11 *
12 * Handles the enqueueing of styles and scripts for the Hostinger admin pages.
13 */
14 class Assets {
15 /**
16 * @var Helper Instance of the Hostinger_Helper class.
17 */
18 private Helper $helper;
19
20 public function __construct() {
21 $this->helper = new Helper();
22 add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
23 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
24 }
25
26 /**
27 * Enqueues styles for the Hostinger admin pages.
28 */
29 public function admin_styles(): void {
30 if ( $this->helper->is_hostinger_admin_page() ) {
31 wp_enqueue_style( 'hostinger_main_styles', HOSTINGER_ASSETS_URL . '/css/main.css', array(), HOSTINGER_VERSION );
32
33 if ( Helper::show_woocommerce_onboarding() ) {
34 wp_enqueue_style( 'hostinger_woo_onboarding', HOSTINGER_ASSETS_URL . '/css/woo-onboarding.css', array(), HOSTINGER_VERSION );
35 }
36 }
37
38 wp_enqueue_style( 'hostinger_global_styles', HOSTINGER_ASSETS_URL . '/css/global.css', array(), HOSTINGER_VERSION );
39
40 if ( $this->helper->is_preview_domain() && is_user_logged_in() ) {
41 wp_enqueue_style( 'hostinger-preview-styles', HOSTINGER_ASSETS_URL . '/css/hts-preview.css', array(), HOSTINGER_VERSION );
42 }
43 }
44
45 /**
46 * Enqueues scripts for the Hostinger admin pages.
47 */
48 public function admin_scripts(): void {
49 if ( $this->helper->is_hostinger_admin_page() ) {
50 wp_enqueue_script(
51 'hostinger_main_scripts',
52 HOSTINGER_ASSETS_URL . '/js/main.js',
53 array(
54 'jquery',
55 'wp-i18n',
56 ),
57 HOSTINGER_VERSION,
58 false
59 );
60
61 if ( Helper::show_woocommerce_onboarding() ) {
62 wp_enqueue_script(
63 'hostinger_woo_onboarding',
64 HOSTINGER_ASSETS_URL . '/js/woo-onboarding.js',
65 array(
66 'jquery',
67 'wp-i18n',
68 ),
69 HOSTINGER_VERSION,
70 false
71 );
72 }
73 }
74
75 wp_enqueue_script(
76 'hostinger_global_scripts',
77 HOSTINGER_ASSETS_URL . '/js/global-scripts.js',
78 array(
79 'jquery',
80 'wp-i18n',
81 ),
82 HOSTINGER_VERSION,
83 false
84 );
85
86 if ( ! empty( Helper::get_api_token() ) ) {
87 wp_enqueue_script(
88 'hostinger_requests_scripts',
89 HOSTINGER_ASSETS_URL . '/js/requests.js',
90 array(
91 'jquery',
92 'wp-i18n',
93 ),
94 HOSTINGER_VERSION,
95 array( 'strategy' => 'defer' )
96 );
97 wp_localize_script(
98 'hostinger_requests_scripts',
99 'hostingerContainer',
100 array(
101 'url' => admin_url( 'admin-ajax.php' ),
102 'nonce' => wp_create_nonce( 'hts-ajax-nonce' ),
103 )
104 );
105 }
106 }
107 }
108