PluginProbe
Hostinger Tools / 2.0.6
Hostinger Tools v2.0.6
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 / class-hostinger-admin-assets.php

class-hostinger-admin-assets.php in Hostinger Tools 2.0.6, at includes/admin/class-hostinger-admin-assets.php

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