Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/hostinge.../includes/Admin
File: Assets.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Hostinger\Admin;
[2] Fix | Delete
[3] Fix | Delete
use Hostinger\Admin\Menu;
[4] Fix | Delete
use Hostinger\LlmsTxtGenerator\LlmsTxtFileHelper;
[5] Fix | Delete
use Hostinger\WpMenuManager\Menus;
[6] Fix | Delete
use Hostinger\Helper;
[7] Fix | Delete
use Hostinger\WpHelper\Utils;
[8] Fix | Delete
[9] Fix | Delete
defined( 'ABSPATH' ) || exit;
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Class Hostinger_Admin_Assets
[13] Fix | Delete
*
[14] Fix | Delete
* Handles the enqueueing of styles and scripts for the Hostinger admin pages.
[15] Fix | Delete
*/
[16] Fix | Delete
class Assets {
[17] Fix | Delete
/**
[18] Fix | Delete
* @var Helper Instance of the Hostinger_Helper class.
[19] Fix | Delete
*/
[20] Fix | Delete
private Helper $helper;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* @var LlmsTxtFileHelper
[24] Fix | Delete
*/
[25] Fix | Delete
private LlmsTxtFileHelper $llms_txt_file_helper;
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* @var Utils
[29] Fix | Delete
*/
[30] Fix | Delete
private Utils $utils;
[31] Fix | Delete
[32] Fix | Delete
public function __construct() {
[33] Fix | Delete
$this->llms_txt_file_helper = new LlmsTxtFileHelper();
[34] Fix | Delete
$this->helper = new Helper();
[35] Fix | Delete
$this->utils = new Utils();
[36] Fix | Delete
$admin_path = parse_url( admin_url(), PHP_URL_PATH );
[37] Fix | Delete
[38] Fix | Delete
// Load assets only on Hostinger admin pages.
[39] Fix | Delete
if ( $this->utils->isThisPage( $admin_path . 'admin.php?page=' . Menu::MENU_SLUG ) || $this->utils->isThisPage( $admin_path . 'admin.php?page=' . Menus::MENU_SLUG ) ) {
[40] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) );
[41] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
[42] Fix | Delete
}
[43] Fix | Delete
if ( is_admin() ) {
[44] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'global_styles' ) );
[45] Fix | Delete
add_action( 'admin_enqueue_scripts', array( $this, 'global_scripts' ) );
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Enqueues styles for the Hostinger admin pages.
[51] Fix | Delete
*/
[52] Fix | Delete
public function admin_styles(): void {
[53] Fix | Delete
// Vue frontend styles.
[54] Fix | Delete
wp_enqueue_style(
[55] Fix | Delete
'hostinger_tools_styles',
[56] Fix | Delete
HOSTINGER_VUE_ASSETS_URL . '/main.min.css',
[57] Fix | Delete
array(),
[58] Fix | Delete
HOSTINGER_VERSION
[59] Fix | Delete
);
[60] Fix | Delete
[61] Fix | Delete
// Plugin rating styles.
[62] Fix | Delete
wp_enqueue_style(
[63] Fix | Delete
'hostinger_rating_styles',
[64] Fix | Delete
HOSTINGER_ASSETS_URL . '/css/plugin-rating.min.css',
[65] Fix | Delete
array(),
[66] Fix | Delete
HOSTINGER_VERSION
[67] Fix | Delete
);
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
public function global_styles(): void {
[71] Fix | Delete
wp_enqueue_style(
[72] Fix | Delete
'hostinger_tools_global_styles',
[73] Fix | Delete
HOSTINGER_ASSETS_URL . 'css/hostinger-global.min.css',
[74] Fix | Delete
array(),
[75] Fix | Delete
HOSTINGER_VERSION
[76] Fix | Delete
);
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
public function global_scripts(): void {
[80] Fix | Delete
wp_enqueue_script(
[81] Fix | Delete
'hostinger_tools_global_scripts',
[82] Fix | Delete
HOSTINGER_ASSETS_URL . 'js/hostinger-global-scripts.min.js',
[83] Fix | Delete
array(),
[84] Fix | Delete
HOSTINGER_VERSION,
[85] Fix | Delete
array(
[86] Fix | Delete
'in_footer' => true,
[87] Fix | Delete
)
[88] Fix | Delete
);
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
/**
[92] Fix | Delete
* Enqueues scripts for the Hostinger admin pages.
[93] Fix | Delete
*/
[94] Fix | Delete
public function admin_scripts(): void {
[95] Fix | Delete
global $wp_version;
[96] Fix | Delete
[97] Fix | Delete
wp_enqueue_script(
[98] Fix | Delete
'hostinger_tools_main_scripts',
[99] Fix | Delete
HOSTINGER_VUE_ASSETS_URL . '/main.min.js',
[100] Fix | Delete
array(
[101] Fix | Delete
'jquery',
[102] Fix | Delete
'wp-i18n',
[103] Fix | Delete
),
[104] Fix | Delete
HOSTINGER_VERSION,
[105] Fix | Delete
false
[106] Fix | Delete
);
[107] Fix | Delete
[108] Fix | Delete
wp_localize_script(
[109] Fix | Delete
'hostinger_tools_main_scripts',
[110] Fix | Delete
'hostinger_tools_data',
[111] Fix | Delete
array(
[112] Fix | Delete
'home_url' => home_url(),
[113] Fix | Delete
'site_url' => get_site_url(),
[114] Fix | Delete
'plugin_url' => $this->helper->get_hostinger_plugin_url(),
[115] Fix | Delete
'asset_url' => HOSTINGER_PLUGIN_URL,
[116] Fix | Delete
'hplatform' => ! empty( $_SERVER['H_PLATFORM'] ) ? 1 : 0,
[117] Fix | Delete
'plugin_split_notice' => $this->helper->should_plugin_split_notice_shown() ? 1 : 0,
[118] Fix | Delete
'hts_close_plugin_split_nonce' => wp_create_nonce( 'hts_close_plugin_split' ),
[119] Fix | Delete
'edit_site_url' => $this->helper->get_edit_site_url(),
[120] Fix | Delete
'llmstxt_file_url' => $this->llms_txt_file_helper->get_llmstxt_file_url(),
[121] Fix | Delete
'llmstxt_file_user_generated' => $this->llms_txt_file_helper->is_user_generated_file(),
[122] Fix | Delete
'translations' => array(
[123] Fix | Delete
'routes_tools' => __( 'Tools', 'hostinger' ),
[124] Fix | Delete
'hostinger_tools_open_guide' => __( 'Open guide', 'hostinger' ),
[125] Fix | Delete
'hostinger_tools_preview_site' => __( 'Preview site', 'hostinger' ),
[126] Fix | Delete
'hostinger_tools_edit_site' => __( 'Edit site', 'hostinger' ),
[127] Fix | Delete
'hostinger_tools_disable_public_access' => __( 'Disable public access to the site (WordPress admins will still be able to access)', 'hostinger' ),
[128] Fix | Delete
'hostinger_tools_skip_link_maintenance_mode' => __( 'Skip-link that bypasses the maintenance mode', 'hostinger' ),
[129] Fix | Delete
'hostinger_tools_reset_link' => __( 'Reset link', 'hostinger' ),
[130] Fix | Delete
'hostinger_tools_disable_xml_rpc' => __( 'Disable XML-RPC', 'hostinger' ),
[131] Fix | Delete
'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' ),
[132] Fix | Delete
'hostinger_tools_disable_authentication_password' => __( 'Disable application passwords', 'hostinger' ),
[133] Fix | Delete
'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' ),
[134] Fix | Delete
[135] Fix | Delete
'hostinger_tools_force_https' => __( 'Force HTTPS', 'hostinger' ),
[136] Fix | Delete
'hostinger_tools_force_https_description' => __( 'Redirects all HTTP URLs to HTTPS sites', 'hostinger' ),
[137] Fix | Delete
'hostinger_tools_force_www' => __( 'Force WWW', 'hostinger' ),
[138] Fix | Delete
'hostinger_tools_force_www_description' => __( 'Redirects all WWW URLs to non-WWW ones', 'hostinger' ),
[139] Fix | Delete
'hostinger_tools_force_www_description_not_available' => __( 'WWW and non-WWW domain records are not pointing to the same host. Redirect not possible.', 'hostinger' ),
[140] Fix | Delete
'hostinger_tools_php_version' => __( 'PHP version', 'hostinger' ),
[141] Fix | Delete
'hostinger_tools_wordpress_version' => __( 'WordPress version', 'hostinger' ),
[142] Fix | Delete
'hostinger_tools_php_version_description' => __( 'Various updates and fixes available in the newest version.', 'hostinger' ),
[143] Fix | Delete
'hostinger_tools_running_latest_version' => __( 'Running the latest version', 'hostinger' ),
[144] Fix | Delete
'hostinger_tools_update' => __( 'Update', 'hostinger' ),
[145] Fix | Delete
'hostinger_tools_update_to' => __( 'Update to', 'hostinger' ),
[146] Fix | Delete
'hostinger_tools_update_to_recommended' => __( 'is recommended', 'hostinger' ),
[147] Fix | Delete
'hostinger_tools_update_to_wordpress_version_description' => __( 'For improved security, ensure you use the latest version of WordPress', 'hostinger' ),
[148] Fix | Delete
'hostinger_tools_maintenance' => __( 'Maintenance', 'hostinger' ),
[149] Fix | Delete
'hostinger_tools_preview_my_website' => __( 'Preview my website', 'hostinger' ),
[150] Fix | Delete
'hostinger_tools_security' => __( 'Security', 'hostinger' ),
[151] Fix | Delete
'hostinger_tools_redirects' => __( 'Redirects', 'hostinger' ),
[152] Fix | Delete
'hostinger_tools_ai' => __( 'AI Tools', 'hostinger' ),
[153] Fix | Delete
'hostinger_tools_llms' => __( 'LLM Optimization', 'hostinger' ),
[154] Fix | Delete
'hostinger_tools_enable_llms_txt' => __( 'Create LLMs.txt file', 'hostinger' ),
[155] Fix | Delete
'hostinger_tools_llms_txt_description' => __( 'Let AI explore, understand, and interact with your WordPress site.', 'hostinger' ),
[156] Fix | Delete
'hostinger_tools_optin_mcp' => __( 'Web 2 Agent', 'hostinger' ),
[157] Fix | Delete
'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' ),
[158] Fix | Delete
'hostinger_tools_llms_txt_learn_more' => __( 'Learn more', 'hostinger' ),
[159] Fix | Delete
'hostinger_tools_llms_txt_check_validity' => __( 'Check validity', 'hostinger' ),
[160] Fix | Delete
'hostinger_tools_llms_txt_llmstxt' => __( 'LLMS.txt', 'hostinger' ),
[161] Fix | Delete
'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' ),
[162] Fix | Delete
'hostinger_tools_llms_txt_modal_title' => __( 'Create new LLMs.txt file?', 'hostinger' ),
[163] Fix | Delete
'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' ),
[164] Fix | Delete
'hostinger_tools_llms_txt_modal_cancel' => __( 'Cancel', 'hostinger' ),
[165] Fix | Delete
'hostinger_tools_llms_txt_modal_create_file' => __( 'Create file', 'hostinger' ),
[166] Fix | Delete
'hostinger_tools_maintenance_mode' => __( 'Maintenance mode', 'hostinger' ),
[167] Fix | Delete
'hostinger_tools_bypass_link' => __( 'Bypass link', 'hostinger' ),
[168] Fix | Delete
'hostinger_tools_split_title' => __( 'We’re splitting Hostinger plugin into two: Hostinger Tools and Hostinger Easy Onboarding', 'hostinger' ),
[169] Fix | Delete
'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' ),
[170] Fix | Delete
'hostinger_tools_split_got_it' => __( 'Got it', 'hostinger' ),
[171] Fix | Delete
'xml_security_modal_description' => __( ' Turning on XML-RPC might make your site less secure. Do you want to proceed?', 'hostinger' ),
[172] Fix | Delete
'xml_security_modal_title' => __( 'Disclaimer', 'hostinger' ),
[173] Fix | Delete
'xml_security_modal_cancel' => __( 'Cancel', 'hostinger' ),
[174] Fix | Delete
'xml_security_modal_proceed_anyway' => __( 'Proceed anyway', 'hostinger' ),
[175] Fix | Delete
'bypass_link_reset_modal_title' => __( 'Bypass link reset', 'hostinger' ),
[176] Fix | Delete
'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' ),
[177] Fix | Delete
'bypass_link_reset_modal_cancel' => __( 'Cancel', 'hostinger' ),
[178] Fix | Delete
'bypass_link_reset_modal_reset_link' => __( 'Reset link', 'hostinger' ),
[179] Fix | Delete
'bypass_link_reset_success' => __( 'Link has been reset', 'hostinger' ),
[180] Fix | Delete
'hostinger_tools_settings_updated' => __( 'Your settings have been updated', 'hostinger' ),
[181] Fix | Delete
'hostinger_tools_settings_error' => __( 'It was an error updating your settings', 'hostinger' ),
[182] Fix | Delete
'hostinger_tools_mcp_choice' => __( 'Allow Kodee to manage your site', 'hostinger' ),
[183] Fix | Delete
'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' ),
[184] Fix | Delete
),
[185] Fix | Delete
'rest_base_url' => esc_url_raw( rest_url() ),
[186] Fix | Delete
'nonce' => wp_create_nonce( 'wp_rest' ),
[187] Fix | Delete
'wp_version' => $wp_version,
[188] Fix | Delete
'php_version' => phpversion(),
[189] Fix | Delete
'recommended_php_version' => $this->helper->get_recommended_php_version(),
[190] Fix | Delete
'mcp_choice' => get_option( 'hostinger_mcp_choice', 0 ),
[191] Fix | Delete
'ai_plugin_compatibility' => $this->check_ai_mcp_compatibility(),
[192] Fix | Delete
)
[193] Fix | Delete
);
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
public function check_ai_mcp_compatibility(): bool {
[197] Fix | Delete
if ( ! function_exists( 'is_plugin_active' ) ) {
[198] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/plugin.php';
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
$plugin_path = 'hostinger-ai-assistant/hostinger-ai-assistant.php';
[202] Fix | Delete
$required_version = '3.0.0';
[203] Fix | Delete
[204] Fix | Delete
if ( is_plugin_active( $plugin_path ) ) {
[205] Fix | Delete
$plugin_file = WP_PLUGIN_DIR . '/' . $plugin_path;
[206] Fix | Delete
if ( file_exists( $plugin_file ) ) {
[207] Fix | Delete
$plugin_data = get_plugin_data( $plugin_file, false, false );
[208] Fix | Delete
$active_version = isset( $plugin_data['Version'] ) ? $plugin_data['Version'] : '';
[209] Fix | Delete
[210] Fix | Delete
if ( $active_version && version_compare( $active_version, $required_version, '>=' ) ) {
[211] Fix | Delete
return true;
[212] Fix | Delete
}
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
return false;
[217] Fix | Delete
}
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function