fix: 支持无.git环境的版本信息显示
- 新增 version.json 文件存储版本信息 - argon_get_git_info() 优先从 version.json 读取 - 解决服务器无法推送 .git 目录导致版本号不更新的问题
This commit is contained in:
@@ -4057,6 +4057,15 @@ add_action('wp_enqueue_scripts', 'argon_enqueue_qrcode_script');
|
|||||||
function argon_get_git_info() {
|
function argon_get_git_info() {
|
||||||
$theme_dir = get_template_directory();
|
$theme_dir = get_template_directory();
|
||||||
$git_dir = $theme_dir . '/.git';
|
$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 目录
|
// 检查是否存在 .git 目录
|
||||||
if (!is_dir($git_dir)) {
|
if (!is_dir($git_dir)) {
|
||||||
|
|||||||
4
version.json
Normal file
4
version.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"branch": "master",
|
||||||
|
"commit": "5ecbacb"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user