| @@ -43,9 +43,9 @@ | ||
| 43 | 43 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
| 44 | 44 | } |
| 45 | 45 | if ( is_admin() ) { |
| 46 | 46 | add_action( 'admin_enqueue_scripts', array( $this, 'global_styles' ) ); |
| 47 | - | |
| 47 | + add_action( 'admin_enqueue_scripts', array( $this, 'global_scripts' ) ); | |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| @@ -56,9 +56,9 @@ | ||
| 56 | 56 | wp_enqueue_style( |
| 57 | 57 | 'hostinger_tools_styles', |
| 58 | 58 | HOSTINGER_VUE_ASSETS_URL . '/main.css', |
| 59 | 59 | array(), |
| 60 | - HOSTINGER_WORDPRESS_PLUGIN_VERSION | |
| 60 | + HOSTINGER_VERSION | |
| 61 | 61 | ); |
| 62 | 62 | |
| 63 | 63 | // Plugin rating styles. |
| 64 | 64 | wp_enqueue_style( |
| @@ -64,9 +64,9 @@ | ||
| 64 | 64 | wp_enqueue_style( |
| 65 | 65 | 'hostinger_rating_styles', |
| 66 | 66 | HOSTINGER_ASSETS_URL . '/css/plugin-rating.min.css', |
| 67 | 67 | array(), |
| 68 | - HOSTINGER_WORDPRESS_PLUGIN_VERSION | |
| 68 | + HOSTINGER_VERSION | |
| 69 | 69 | ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function global_styles(): void { |
| @@ -73,14 +73,24 @@ | ||
| 73 | 73 | wp_enqueue_style( |
| 74 | 74 | 'hostinger_tools_global_styles', |
| 75 | 75 | HOSTINGER_ASSETS_URL . 'css/hostinger-global.min.css', |
| 76 | 76 | array(), |
| 77 | - HOSTINGER_WORDPRESS_PLUGIN_VERSION | |
| 77 | + HOSTINGER_VERSION | |
| 78 | 78 | ); |
| 79 | 79 | } |
| 80 | 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 | + } | |
| 81 | 92 | |
| 82 | - | |
| 83 | 93 | /** |
| 84 | 94 | * Enqueues scripts for the Hostinger admin pages. |
| 85 | 95 | */ |
| 86 | 96 | public function admin_scripts(): void { |
| @@ -92,9 +102,9 @@ | ||
| 92 | 102 | array( |
| 93 | 103 | 'jquery', |
| 94 | 104 | 'wp-i18n', |
| 95 | 105 | ), |
| 96 | - HOSTINGER_WORDPRESS_PLUGIN_VERSION, | |
| 106 | + HOSTINGER_VERSION, | |
| 97 | 107 | false |
| 98 | 108 | ); |
| 99 | 109 | |
| 100 | 110 | wp_localize_script( |
| @@ -100,17 +110,19 @@ | ||
| 100 | 110 | wp_localize_script( |
| 101 | 111 | 'hostinger_tools_main_scripts', |
| 102 | 112 | 'hostinger_tools_data', |
| 103 | 113 | 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( | |
| 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( | |
| 113 | 125 | 'routes_tools' => __( 'Tools', 'hostinger' ), |
| 114 | 126 | 'hostinger_tools_open_guide' => __( 'Open guide', 'hostinger' ), |
| 115 | 127 | 'hostinger_tools_preview_site' => __( 'Preview site', 'hostinger' ), |
| 116 | 128 | 'hostinger_tools_edit_site' => __( 'Edit site', 'hostinger' ), |
| @@ -154,8 +166,11 @@ | ||
| 154 | 166 | 'hostinger_tools_llms_txt_modal_cancel' => __( 'Cancel', 'hostinger' ), |
| 155 | 167 | 'hostinger_tools_llms_txt_modal_create_file' => __( 'Create file', 'hostinger' ), |
| 156 | 168 | 'hostinger_tools_maintenance_mode' => __( 'Maintenance mode', 'hostinger' ), |
| 157 | 169 | 'hostinger_tools_bypass_link' => __( 'Bypass link', 'hostinger' ), |
| 170 | + 'hostinger_tools_split_title' => __( 'We’re splitting Hostinger plugin into two: Hostinger Tools and Hostinger Easy Onboarding', 'hostinger' ), | |
| 171 | + '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' ), | |
| 172 | + 'hostinger_tools_split_got_it' => __( 'Got it', 'hostinger' ), | |
| 158 | 173 | 'xml_security_modal_description' => __( ' Turning on XML-RPC might make your site less secure. Do you want to proceed?', 'hostinger' ), |
| 159 | 174 | 'xml_security_modal_title' => __( 'Disclaimer', 'hostinger' ), |
| 160 | 175 | 'xml_security_modal_cancel' => __( 'Cancel', 'hostinger' ), |
| 161 | 176 | 'xml_security_modal_proceed_anyway' => __( 'Proceed anyway', 'hostinger' ), |
| @@ -165,20 +180,45 @@ | ||
| 165 | 180 | 'bypass_link_reset_modal_reset_link' => __( 'Reset link', 'hostinger' ), |
| 166 | 181 | 'bypass_link_reset_success' => __( 'Link has been reset', 'hostinger' ), |
| 167 | 182 | 'hostinger_tools_settings_updated' => __( 'Your settings have been updated', 'hostinger' ), |
| 168 | 183 | 'hostinger_tools_settings_error' => __( 'It was an error updating your settings', 'hostinger' ), |
| 169 | - 'hostinger_tools_mcp_description' => __( 'Let Hostinger Agent manage your site on your behalf. This allows Hostinger Agent to perform actions like creating pages or updating settings. We will install and pre-configure the WordPress MCP plugin for you.', 'hostinger' ), | |
| 184 | + 'hostinger_tools_mcp_choice' => __( 'Allow Kodee to manage your site', 'hostinger' ), | |
| 185 | + '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 | 186 | 'hostinger_tools_copied_successfully' => __( 'Copied successfully', 'hostinger' ), |
| 171 | 187 | 'hostinger_tools_text_copied_successfully' => __( 'Text has been copied successfully', 'hostinger' ), |
| 172 | 188 | 'hostinger_tools_free_domain_llm_unavailable' => __( 'LLM optimization features are not available for temporary subdomains. Connect a domain to unlock these features.', 'hostinger' ), |
| 173 | 189 | 'hostinger_tools_connect_domain_cta' => __( 'Connect domain', 'hostinger' ), |
| 174 | - 'hostinger_tools_copy_agent_url' => __( 'Copy agent url', 'hostinger' ), | |
| 175 | 190 | ), |
| 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(), | |
| 191 | + 'rest_base_url' => esc_url_raw( rest_url() ), | |
| 192 | + 'nonce' => wp_create_nonce( 'wp_rest' ), | |
| 193 | + 'wp_version' => $wp_version, | |
| 194 | + 'php_version' => phpversion(), | |
| 195 | + 'recommended_php_version' => $this->helper->get_recommended_php_version(), | |
| 196 | + 'mcp_choice' => get_option( 'hostinger_mcp_choice', 0 ), | |
| 197 | + 'ai_plugin_compatibility' => $this->check_ai_mcp_compatibility(), | |
| 181 | 198 | ) |
| 182 | 199 | ); |
| 200 | + } | |
| 201 | + | |
| 202 | + public function check_ai_mcp_compatibility(): bool { | |
| 203 | + if ( ! function_exists( 'is_plugin_active' ) ) { | |
| 204 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; | |
| 205 | + } | |
| 206 | + | |
| 207 | + $plugin_path = 'hostinger-ai-assistant/hostinger-ai-assistant.php'; | |
| 208 | + $required_version = '3.0.0'; | |
| 209 | + | |
| 210 | + if ( is_plugin_active( $plugin_path ) ) { | |
| 211 | + $plugin_file = WP_PLUGIN_DIR . '/' . $plugin_path; | |
| 212 | + if ( file_exists( $plugin_file ) ) { | |
| 213 | + $plugin_data = get_plugin_data( $plugin_file, false, false ); | |
| 214 | + $active_version = isset( $plugin_data['Version'] ) ? $plugin_data['Version'] : ''; | |
| 215 | + | |
| 216 | + if ( $active_version && version_compare( $active_version, $required_version, '>=' ) ) { | |
| 217 | + return true; | |
| 218 | + } | |
| 219 | + } | |
| 220 | + } | |
| 221 | + | |
| 222 | + return false; | |
| 183 | 223 | } |
| 184 | 224 | } |