From 75d0e3e88718c9fa597eb35e819359c11df6ce44 Mon Sep 17 00:00:00 2001 From: Yaosanqi137 Date: Wed, 4 Mar 2026 15:04:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E4=BD=93=E3=80=81?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=E5=88=B7=E6=96=B0=E7=9E=AC=E9=97=B4=E2=80=9C?= =?UTF-8?q?=E9=97=AA=E7=83=81=E2=80=9D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/lang-toggle.js | 4 ++++ functions.php | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/assets/js/lang-toggle.js b/assets/js/lang-toggle.js index 713b265..ae29729 100644 --- a/assets/js/lang-toggle.js +++ b/assets/js/lang-toggle.js @@ -2,6 +2,10 @@ const langToggle = document.querySelector('.lang-toggle'); const body = document.body; function getPreferredLang() { + if (window.__ITSTUDIO_LANG__ === 'zh' || window.__ITSTUDIO_LANG__ === 'en') { + return window.__ITSTUDIO_LANG__; + } + const savedLang = localStorage.getItem('language'); if (savedLang === 'zh' || savedLang === 'en') { return savedLang; diff --git a/functions.php b/functions.php index 0430834..5a57975 100644 --- a/functions.php +++ b/functions.php @@ -78,12 +78,24 @@ function itstudio_output_favicon() { echo '' . "\n"; echo '' . "\n"; } + +function itstudio_output_theme_bootstrap_script() { + echo '' . "\n"; + echo '' . "\n"; +} + +function itstudio_output_lang_bootstrap_script() { + echo '' . "\n"; + echo '' . "\n"; +} function itstudio_disable_default_site_icon() { remove_action('wp_head', 'wp_site_icon', 99); remove_action('admin_head', 'wp_site_icon', 99); remove_action('login_head', 'wp_site_icon', 99); } add_action('init', 'itstudio_disable_default_site_icon'); +add_action('wp_head', 'itstudio_output_theme_bootstrap_script', 0); +add_action('wp_head', 'itstudio_output_lang_bootstrap_script', 1); add_action('wp_head', 'itstudio_output_favicon', 1); add_action('admin_head', 'itstudio_output_favicon', 1); add_action('login_head', 'itstudio_output_favicon', 1);