From 14edc7051200f51772abd256dfc4cca7c79fa325 Mon Sep 17 00:00:00 2001 From: nanhaoluo <3075912108@qq.com> Date: Thu, 15 Jan 2026 17:06:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E6=97=A0.git=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E7=9A=84=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 version.json 文件存储版本信息 - argon_get_git_info() 优先从 version.json 读取 - 解决服务器无法推送 .git 目录导致版本号不更新的问题 --- functions.php | 9 +++++++++ version.json | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 version.json diff --git a/functions.php b/functions.php index ba9618d..3251715 100644 --- a/functions.php +++ b/functions.php @@ -4057,6 +4057,15 @@ add_action('wp_enqueue_scripts', 'argon_enqueue_qrcode_script'); function argon_get_git_info() { $theme_dir = get_template_directory(); $git_dir = $theme_dir . '/.git'; + $version_file = $theme_dir . '/version.json'; + + // 优先从 version.json 读取(用于没有 .git 的服务器环境) + if (file_exists($version_file)) { + $version_data = json_decode(file_get_contents($version_file), true); + if ($version_data && isset($version_data['branch']) && isset($version_data['commit'])) { + return $version_data; + } + } // 检查是否存在 .git 目录 if (!is_dir($git_dir)) { diff --git a/version.json b/version.json new file mode 100644 index 0000000..0e64f13 --- /dev/null +++ b/version.json @@ -0,0 +1,4 @@ +{ + "branch": "master", + "commit": "5ecbacb" +}