| @@ -15,114 +15,123 @@ | ||
| 15 | 15 | * |
| 16 | 16 | * Handles the enqueueing of styles and scripts for the Hostinger admin pages. |
| 17 | 17 | */ |
| 18 | 18 | class Assets { |
| 19 | - /** | |
| 20 | - * @var Helper Instance of the Hostinger_Helper class. | |
| 21 | - */ | |
| 22 | - private Helper $helper; | |
| 19 | + /** | |
| 20 | + * @var Helper Instance of the Hostinger_Helper class. | |
| 21 | + */ | |
| 22 | + private Helper $helper; | |
| 23 | 23 | |
| 24 | - /** | |
| 25 | - * @var LlmsTxtFileHelper | |
| 26 | - */ | |
| 27 | - private LlmsTxtFileHelper $llms_txt_file_helper; | |
| 24 | + /** | |
| 25 | + * @var LlmsTxtFileHelper | |
| 26 | + */ | |
| 27 | + private LlmsTxtFileHelper $llms_txt_file_helper; | |
| 28 | 28 | |
| 29 | - /** | |
| 30 | - * @var Utils | |
| 31 | - */ | |
| 32 | - private Utils $utils; | |
| 29 | + /** | |
| 30 | + * @var Utils | |
| 31 | + */ | |
| 32 | + private Utils $utils; | |
| 33 | 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 ); | |
| 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 | 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' ) ); | |
| 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 | + } | |
| 47 | 50 | |
| 48 | - } | |
| 49 | - } | |
| 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 | + ); | |
| 50 | 62 | |
| 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.css', | |
| 59 | - array(), | |
| 60 | - HOSTINGER_WORDPRESS_PLUGIN_VERSION | |
| 61 | - ); | |
| 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 | + } | |
| 62 | 71 | |
| 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_WORDPRESS_PLUGIN_VERSION | |
| 69 | - ); | |
| 70 | - } | |
| 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 | + } | |
| 71 | 80 | |
| 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_WORDPRESS_PLUGIN_VERSION | |
| 78 | - ); | |
| 79 | - } | |
| 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 | + } | |
| 80 | 92 | |
| 93 | + /** | |
| 94 | + * Enqueues scripts for the Hostinger admin pages. | |
| 95 | + */ | |
| 96 | + public function admin_scripts(): void { | |
| 97 | + global $wp_version; | |
| 81 | 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 | + ); | |
| 82 | 109 | |
| 83 | - /** | |
| 84 | - * Enqueues scripts for the Hostinger admin pages. | |
| 85 | - */ | |
| 86 | - public function admin_scripts(): void { | |
| 87 | - global $wp_version; | |
| 110 | + wp_localize_script( 'hostinger_tools_main_scripts', 'hostinger_tools_data', array( | |
| 111 | + 'home_url' => home_url(), | |
| 112 | + 'site_url' => get_site_url(), | |
| 113 | + 'plugin_url' => $this->helper->get_hostinger_plugin_url(), | |
| 114 | + 'asset_url' => HOSTINGER_PLUGIN_URL, | |
| 115 | + 'hplatform' => ! empty( $_SERVER['H_PLATFORM'] ) ? 1 : 0, | |
| 116 | + 'plugin_split_notice' => $this->helper->should_plugin_split_notice_shown() ? 1 : 0, | |
| 117 | + 'hts_close_plugin_split_nonce' => wp_create_nonce( 'hts_close_plugin_split' ), | |
| 118 | + 'edit_site_url' => $this->helper->get_edit_site_url(), | |
| 119 | + 'llmstxt_file_url' => $this->llms_txt_file_helper->get_llmstxt_file_url(), | |
| 120 | + 'llmstxt_file_user_generated' => $this->llms_txt_file_helper->is_user_generated_file(), | |
| 121 | + 'translations' => array( | |
| 122 | + 'routes_tools' => __( 'Tools', 'hostinger' ), | |
| 123 | + 'hostinger_tools_open_guide' => __( 'Open guide', 'hostinger' ), | |
| 124 | + 'hostinger_tools_preview_site' => __( 'Preview site', 'hostinger' ), | |
| 125 | + 'hostinger_tools_edit_site' => __( 'Edit site', 'hostinger' ), | |
| 126 | + 'hostinger_tools_disable_public_access' => __( 'Disable public access to the site (WordPress admins will still be able to access)', 'hostinger' ), | |
| 127 | + 'hostinger_tools_skip_link_maintenance_mode' => __( 'Skip-link that bypasses the maintenance mode', 'hostinger' ), | |
| 128 | + 'hostinger_tools_reset_link' => __( 'Reset link', 'hostinger' ), | |
| 129 | + 'hostinger_tools_disable_xml_rpc' => __( 'Disable XML-RPC', 'hostinger' ), | |
| 130 | + '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' ), | |
| 131 | + 'hostinger_tools_disable_authentication_password' => __( 'Disable application passwords', 'hostinger' ), | |
| 132 | + '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' ), | |
| 88 | 133 | |
| 89 | - wp_enqueue_script( | |
| 90 | - 'hostinger_tools_main_scripts', | |
| 91 | - HOSTINGER_VUE_ASSETS_URL . '/main.js', | |
| 92 | - array( | |
| 93 | - 'jquery', | |
| 94 | - 'wp-i18n', | |
| 95 | - ), | |
| 96 | - HOSTINGER_WORDPRESS_PLUGIN_VERSION, | |
| 97 | - false | |
| 98 | - ); | |
| 99 | - | |
| 100 | - wp_localize_script( | |
| 101 | - 'hostinger_tools_main_scripts', | |
| 102 | - 'hostinger_tools_data', | |
| 103 | - array( | |
| 104 | - 'home_url' => home_url(), | |
| 105 | - 'site_url' => get_site_url(), | |
| 106 | - 'plugin_url' => $this->helper->get_hostinger_plugin_url(), | |
| 107 | - 'asset_url' => HOSTINGER_PLUGIN_URL, | |
| 108 | - 'hplatform' => ! empty( $_SERVER['H_PLATFORM'] ) ? 1 : 0, | |
| 109 | - 'edit_site_url' => $this->helper->get_edit_site_url(), | |
| 110 | - 'llmstxt_file_url' => $this->llms_txt_file_helper->get_llmstxt_file_url(), | |
| 111 | - 'llmstxt_file_user_generated' => $this->llms_txt_file_helper->is_user_generated_file(), | |
| 112 | - 'translations' => array( | |
| 113 | - 'routes_tools' => __( 'Tools', 'hostinger' ), | |
| 114 | - 'hostinger_tools_open_guide' => __( 'Open guide', 'hostinger' ), | |
| 115 | - 'hostinger_tools_preview_site' => __( 'Preview site', 'hostinger' ), | |
| 116 | - 'hostinger_tools_edit_site' => __( 'Edit site', 'hostinger' ), | |
| 117 | - 'hostinger_tools_disable_public_access' => __( 'Disable public access to the site (WordPress admins will still be able to access)', 'hostinger' ), | |
| 118 | - 'hostinger_tools_skip_link_maintenance_mode' => __( 'Skip-link that bypasses the maintenance mode', 'hostinger' ), | |
| 119 | - 'hostinger_tools_reset_link' => __( 'Reset link', 'hostinger' ), | |
| 120 | - 'hostinger_tools_disable_xml_rpc' => __( 'Disable XML-RPC', 'hostinger' ), | |
| 121 | - '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' ), | |
| 122 | - 'hostinger_tools_disable_authentication_password' => __( 'Disable application passwords', 'hostinger' ), | |
| 123 | - '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' ), | |
| 124 | - | |
| 125 | 134 | 'hostinger_tools_force_https' => __( 'Force HTTPS', 'hostinger' ), |
| 126 | 135 | 'hostinger_tools_force_https_description' => __( 'Redirects all HTTP URLs to HTTPS sites', 'hostinger' ), |
| 127 | 136 | 'hostinger_tools_force_www' => __( 'Force WWW', 'hostinger' ), |
| 128 | 137 | 'hostinger_tools_force_www_description' => __( 'Redirects all WWW URLs to non-WWW ones', 'hostinger' ), |
| @@ -138,14 +147,11 @@ | ||
| 138 | 147 | 'hostinger_tools_maintenance' => __( 'Maintenance', 'hostinger' ), |
| 139 | 148 | 'hostinger_tools_preview_my_website' => __( 'Preview my website', 'hostinger' ), |
| 140 | 149 | 'hostinger_tools_security' => __( 'Security', 'hostinger' ), |
| 141 | 150 | 'hostinger_tools_redirects' => __( 'Redirects', 'hostinger' ), |
| 142 | - 'hostinger_tools_ai' => __( 'AI Tools', 'hostinger' ), | |
| 143 | 151 | 'hostinger_tools_llms' => __( 'LLM Optimization', 'hostinger' ), |
| 144 | 152 | 'hostinger_tools_enable_llms_txt' => __( 'Create LLMs.txt file', 'hostinger' ), |
| 145 | - 'hostinger_tools_llms_txt_description' => __( 'Let AI explore, understand, and interact with your WordPress site.', 'hostinger' ), | |
| 146 | - 'hostinger_tools_optin_mcp' => __( 'Web2Agent', 'hostinger' ), | |
| 147 | - 'hostinger_tools_optin_mcp_description' => __( 'Make your website easier for AI tools to understand. Website content updates will be tracked to keep the AI discovery service up to date.', 'hostinger' ), | |
| 153 | + 'hostinger_tools_llms_txt_description' => __( 'Let AI explore, understand, and interact with your WordPress site', 'hostinger' ), | |
| 148 | 154 | 'hostinger_tools_llms_txt_learn_more' => __( 'Learn more', 'hostinger' ), |
| 149 | 155 | 'hostinger_tools_llms_txt_check_validity' => __( 'Check validity', 'hostinger' ), |
| 150 | 156 | 'hostinger_tools_llms_txt_llmstxt' => __( 'LLMS.txt', 'hostinger' ), |
| 151 | 157 | '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' ), |
| @@ -154,8 +160,11 @@ | ||
| 154 | 160 | 'hostinger_tools_llms_txt_modal_cancel' => __( 'Cancel', 'hostinger' ), |
| 155 | 161 | 'hostinger_tools_llms_txt_modal_create_file' => __( 'Create file', 'hostinger' ), |
| 156 | 162 | 'hostinger_tools_maintenance_mode' => __( 'Maintenance mode', 'hostinger' ), |
| 157 | 163 | 'hostinger_tools_bypass_link' => __( 'Bypass link', 'hostinger' ), |
| 164 | + 'hostinger_tools_split_title' => __( 'We’re splitting Hostinger plugin into two: Hostinger Tools and Hostinger Easy Onboarding', 'hostinger' ), | |
| 165 | + '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' ), | |
| 166 | + 'hostinger_tools_split_got_it' => __( 'Got it', 'hostinger' ), | |
| 158 | 167 | 'xml_security_modal_description' => __( ' Turning on XML-RPC might make your site less secure. Do you want to proceed?', 'hostinger' ), |
| 159 | 168 | 'xml_security_modal_title' => __( 'Disclaimer', 'hostinger' ), |
| 160 | 169 | 'xml_security_modal_cancel' => __( 'Cancel', 'hostinger' ), |
| 161 | 170 | 'xml_security_modal_proceed_anyway' => __( 'Proceed anyway', 'hostinger' ), |
| @@ -163,22 +172,13 @@ | ||
| 163 | 172 | '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' ), |
| 164 | 173 | 'bypass_link_reset_modal_cancel' => __( 'Cancel', 'hostinger' ), |
| 165 | 174 | 'bypass_link_reset_modal_reset_link' => __( 'Reset link', 'hostinger' ), |
| 166 | 175 | 'bypass_link_reset_success' => __( 'Link has been reset', 'hostinger' ), |
| 167 | - 'hostinger_tools_settings_updated' => __( 'Your settings have been updated', 'hostinger' ), | |
| 168 | - 'hostinger_tools_settings_error' => __( 'It was an error updating your settings', 'hostinger' ), | |
| 169 | - 'hostinger_tools_mcp_description' => __( 'Let Kodee manage your site on your behalf. This allows Kodee to perform actions like creating pages or updating settings. We will install and pre-configure the WordPress MCP plugin for you.', 'hostinger' ), | |
| 170 | - 'hostinger_tools_copied_successfully' => __( 'Copied successfully', 'hostinger' ), | |
| 171 | - 'hostinger_tools_text_copied_successfully' => __( 'Text has been copied successfully', 'hostinger' ), | |
| 172 | - 'hostinger_tools_free_domain_llm_unavailable' => __( 'LLM optimization features are not available for temporary subdomains. Connect a domain to unlock these features.', 'hostinger' ), | |
| 173 | - 'hostinger_tools_connect_domain_cta' => __( 'Connect domain', 'hostinger' ), | |
| 174 | - 'hostinger_tools_copy_agent_url' => __( 'Copy agent url', 'hostinger' ), | |
| 175 | 176 | ), |
| 176 | - 'rest_base_url' => esc_url_raw( rest_url() ), | |
| 177 | - 'nonce' => wp_create_nonce( 'wp_rest' ), | |
| 178 | - 'wp_version' => $wp_version, | |
| 179 | - 'php_version' => phpversion(), | |
| 180 | - 'recommended_php_version' => $this->helper->get_recommended_php_version(), | |
| 181 | - ) | |
| 182 | - ); | |
| 183 | - } | |
| 177 | + 'rest_base_url' => esc_url_raw( rest_url() ), | |
| 178 | + 'nonce' => wp_create_nonce( 'wp_rest' ), | |
| 179 | + 'wp_version' => $wp_version, | |
| 180 | + 'php_version' => phpversion(), | |
| 181 | + 'recommended_php_version' => $this->helper->get_recommended_php_version(), | |
| 182 | + ) ); | |
| 183 | + } | |
| 184 | 184 | } |