fix: 支持无.git环境的版本信息显示

- 新增 version.json 文件存储版本信息
- argon_get_git_info() 优先从 version.json 读取
- 解决服务器无法推送 .git 目录导致版本号不更新的问题
This commit is contained in:
2026-01-15 17:06:48 +08:00
parent 5ecbacb691
commit 14edc70512
2 changed files with 13 additions and 0 deletions

View File

@@ -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)) {