PluginProbe
Hostinger Tools / 3.0.41
Hostinger Tools v3.0.41
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 3.0.41, at includes/Admin/Assets.php

191 lines 12.0 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\Admin\Menu;
6 use Hostinger\LlmsTxtGenerator\LlmsTxtFileHelper;
7 use Hostinger\WpMenuManager\Menus;
8 use Hostinger\Helper;
9 use Hostinger\WpHelper\Utils;
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Class Hostinger_Admin_Assets
15 *
16 * Handles the enqueueing of styles and scripts for the Hostinger admin pages.
17 */
18 class Assets {
19 /**
20 * @var Helper Instance of the Hostinger_Helper class.
21 */
22 private Helper $helper;
23
24 /**
25 * @var LlmsTxtFileHelper
26 */
27 private LlmsTxtFileHelper $llms_txt_file_helper;
28
29 /**
30 * @var Utils
31 */
32 private Utils $utils;
33
34 public function __construct() {
35 $this->llms_txt_file_helper = new LlmsTxtFileHelper();
36 $this->helper = new Helper();
37 $this->utils = new Utils();
38 $admin_path = parse_url( admin_url(), PHP_URL_PATH );
39
40 // Load assets only on Hostinger admin pages.
41 if ( $this->utils->isThisPage( $admin_path . 'admin.php?page=' . Menu::MENU_SLUG ) || $this->utils->isThisPage( $admin_path . 'admin.php?page=' . Menus::MENU_SLUG ) ) {
42 add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
43 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
44 }
45 if ( is_admin() ) {
46 add_action( 'admin_enqueue_scripts', array( $this, 'global_styles' ) );
47 add_action( 'admin_enqueue_scripts', array( $this, 'global_scripts' ) );
48 }
49 }
50
51 /**
52 * Enqueues styles for the Hostinger admin pages.
53 */
54 public function admin_styles(): void {
55 // Vue frontend styles.
56 wp_enqueue_style(
57 'hostinger_tools_styles',
58 HOSTINGER_VUE_ASSETS_URL . '/main.min.css',
59 array(),
60 HOSTINGER_VERSION
61 );
62
63 // Plugin rating styles.
64 wp_enqueue_style(
65 'hostinger_rating_styles',
66 HOSTINGER_ASSETS_URL . '/css/plugin-rating.min.css',
67 array(),
68 HOSTINGER_VERSION
69 );
70 }
71
72 public function global_styles(): void {
73 wp_enqueue_style(
74 'hostinger_tools_global_styles',
75 HOSTINGER_ASSETS_URL . 'css/hostinger-global.min.css',
76 array(),
77 HOSTINGER_VERSION
78 );
79 }
80
81 public function global_scripts(): void {
82 wp_enqueue_script(
83 'hostinger_tools_global_scripts',
84 HOSTINGER_ASSETS_URL . 'js/hostinger-global-scripts.min.js',
85 array(),
86 HOSTINGER_VERSION,
87 array(
88 'in_footer' => true,
89 )
90 );
91 }
92
93 /**
94 * Enqueues scripts for the Hostinger admin pages.
95 */
96 public function admin_scripts(): void {
97 global $wp_version;
98
99 wp_enqueue_script(
100 'hostinger_tools_main_scripts',
101 HOSTINGER_VUE_ASSETS_URL . '/main.min.js',
102 array(
103 'jquery',
104 'wp-i18n',
105 ),
106 HOSTINGER_VERSION,
107 false
108 );
109
110 wp_localize_script(
111 'hostinger_tools_main_scripts',
112 'hostinger_tools_data',
113 array(
114 'home_url' => home_url(),
115 'site_url' => get_site_url(),
116 'plugin_url' => $this->helper->get_hostinger_plugin_url(),
117 'asset_url' => HOSTINGER_PLUGIN_URL,
118 'hplatform' => ! empty( $_SERVER['H_PLATFORM'] ) ? 1 : 0,
119 'plugin_split_notice' => $this->helper->should_plugin_split_notice_shown() ? 1 : 0,
120 'hts_close_plugin_split_nonce' => wp_create_nonce( 'hts_close_plugin_split' ),
121 'edit_site_url' => $this->helper->get_edit_site_url(),
122 'llmstxt_file_url' => $this->llms_txt_file_helper->get_llmstxt_file_url(),
123 'llmstxt_file_user_generated' => $this->llms_txt_file_helper->is_user_generated_file(),
124 'translations' => array(
125 'routes_tools' => __( 'Tools', 'hostinger' ),
126 'hostinger_tools_open_guide' => __( 'Open guide', 'hostinger' ),
127 'hostinger_tools_preview_site' => __( 'Preview site', 'hostinger' ),
128 'hostinger_tools_edit_site' => __( 'Edit site', 'hostinger' ),
129 'hostinger_tools_disable_public_access' => __( 'Disable public access to the site (WordPress admins will still be able to access)', 'hostinger' ),
130 'hostinger_tools_skip_link_maintenance_mode' => __( 'Skip-link that bypasses the maintenance mode', 'hostinger' ),
131 'hostinger_tools_reset_link' => __( 'Reset link', 'hostinger' ),
132 'hostinger_tools_disable_xml_rpc' => __( 'Disable XML-RPC', 'hostinger' ),
133 'hostinger_tools_xml_rpc_description' => __( 'XML-RPC allows apps to connect to your WordPress site, but might expose your site\'s security. Disable this feature if you don\'t need it', 'hostinger' ),
134 'hostinger_tools_disable_authentication_password' => __( 'Disable application passwords', 'hostinger' ),
135 'hostinger_tools_authentication_password_description' => __( 'WordPress application passwords allow users to authenticate API requests without using their main login credentials, allowing for third-party integrations.', 'hostinger' ),
136
137 'hostinger_tools_force_https' => __( 'Force HTTPS', 'hostinger' ),
138 'hostinger_tools_force_https_description' => __( 'Redirects all HTTP URLs to HTTPS sites', 'hostinger' ),
139 'hostinger_tools_force_www' => __( 'Force WWW', 'hostinger' ),
140 'hostinger_tools_force_www_description' => __( 'Redirects all WWW URLs to non-WWW ones', 'hostinger' ),
141 'hostinger_tools_force_www_description_not_available' => __( 'WWW and non-WWW domain records are not pointing to the same host. Redirect not possible.', 'hostinger' ),
142 'hostinger_tools_php_version' => __( 'PHP version', 'hostinger' ),
143 'hostinger_tools_wordpress_version' => __( 'WordPress version', 'hostinger' ),
144 'hostinger_tools_php_version_description' => __( 'Various updates and fixes available in the newest version.', 'hostinger' ),
145 'hostinger_tools_running_latest_version' => __( 'Running the latest version', 'hostinger' ),
146 'hostinger_tools_update' => __( 'Update', 'hostinger' ),
147 'hostinger_tools_update_to' => __( 'Update to', 'hostinger' ),
148 'hostinger_tools_update_to_recommended' => __( 'is recommended', 'hostinger' ),
149 'hostinger_tools_update_to_wordpress_version_description' => __( 'For improved security, ensure you use the latest version of WordPress', 'hostinger' ),
150 'hostinger_tools_maintenance' => __( 'Maintenance', 'hostinger' ),
151 'hostinger_tools_preview_my_website' => __( 'Preview my website', 'hostinger' ),
152 'hostinger_tools_security' => __( 'Security', 'hostinger' ),
153 'hostinger_tools_redirects' => __( 'Redirects', 'hostinger' ),
154 'hostinger_tools_llms' => __( 'LLM Optimization', 'hostinger' ),
155 'hostinger_tools_enable_llms_txt' => __( 'Create LLMs.txt file', 'hostinger' ),
156 'hostinger_tools_llms_txt_description' => __( 'Let AI explore, understand, and interact with your WordPress site', 'hostinger' ),
157 'hostinger_tools_llms_txt_learn_more' => __( 'Learn more', 'hostinger' ),
158 'hostinger_tools_llms_txt_check_validity' => __( 'Check validity', 'hostinger' ),
159 'hostinger_tools_llms_txt_llmstxt' => __( 'LLMS.txt', 'hostinger' ),
160 'hostinger_tools_llms_txt_external_file_found' => __( 'An external LLMs.txt file was found. Switching on the toggle will replace it with a new one.', 'hostinger' ),
161 'hostinger_tools_llms_txt_modal_title' => __( 'Create new LLMs.txt file?', 'hostinger' ),
162 'hostinger_tools_llms_txt_modal_description' => __( 'This will replace the existing LLMs.txt file with a new one by Hostinger Tools. The original file can’t be restored.', 'hostinger' ),
163 'hostinger_tools_llms_txt_modal_cancel' => __( 'Cancel', 'hostinger' ),
164 'hostinger_tools_llms_txt_modal_create_file' => __( 'Create file', 'hostinger' ),
165 'hostinger_tools_maintenance_mode' => __( 'Maintenance mode', 'hostinger' ),
166 'hostinger_tools_bypass_link' => __( 'Bypass link', 'hostinger' ),
167 'hostinger_tools_split_title' => __( 'We’re splitting Hostinger plugin into two: Hostinger Tools and Hostinger Easy Onboarding', 'hostinger' ),
168 'hostinger_tools_split_body' => __( 'Hostinger Tools will offer new tools to simplify your site management. And Hostinger Easy Onboarding will guide you through the steps of building a website.', 'hostinger' ),
169 'hostinger_tools_split_got_it' => __( 'Got it', 'hostinger' ),
170 'xml_security_modal_description' => __( ' Turning on XML-RPC might make your site less secure. Do you want to proceed?', 'hostinger' ),
171 'xml_security_modal_title' => __( 'Disclaimer', 'hostinger' ),
172 'xml_security_modal_cancel' => __( 'Cancel', 'hostinger' ),
173 'xml_security_modal_proceed_anyway' => __( 'Proceed anyway', 'hostinger' ),
174 'bypass_link_reset_modal_title' => __( 'Bypass link reset', 'hostinger' ),
175 'bypass_link_reset_modal_description' => __( 'This will invalidate the currently generated link in use. This action cannot be undone, are you sure you want to proceed?', 'hostinger' ),
176 'bypass_link_reset_modal_cancel' => __( 'Cancel', 'hostinger' ),
177 'bypass_link_reset_modal_reset_link' => __( 'Reset link', 'hostinger' ),
178 'bypass_link_reset_success' => __( 'Link has been reset', 'hostinger' ),
179 'hostinger_tools_settings_updated' => __( 'Your settings have been updated', 'hostinger' ),
180 'hostinger_tools_settings_error' => __( 'It was an error updating your settings', 'hostinger' ),
181 ),
182 'rest_base_url' => esc_url_raw( rest_url() ),
183 'nonce' => wp_create_nonce( 'wp_rest' ),
184 'wp_version' => $wp_version,
185 'php_version' => phpversion(),
186 'recommended_php_version' => $this->helper->get_recommended_php_version(),
187 )
188 );
189 }
190 }
191