diff --git a/optimize_settings_final.py b/optimize_settings_final.py new file mode 100644 index 0000000..4837e1e --- /dev/null +++ b/optimize_settings_final.py @@ -0,0 +1,181 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Settings.php 结构优化脚本 - 最终步骤 +完成以下任务: +1. 在基础设置的夜间模式后添加子目录设置 +2. 将第1541行的"高级设置"改为"SEO与性能",并添加CDN和日期格式设置 +3. 重新编号所有一级分类(1-16) +""" + +def main(): + # 读取文件 + with open('settings.php', 'r', encoding='utf-8') as f: + lines = f.readlines() + + print("开始优化 settings.php (最终步骤: 添加子目录和SEO与性能分类)...") + print(f"原始文件: {len(lines)} 行") + + content = ''.join(lines) + + # 1. 在基础设置的夜间模式后添加子目录设置 + old_basic_end = ''' + + ''' + + new_basic_with_subdirectory = ''' + +

+ + + + + + + + + +

/blog/ /

+ + + + + + ''' + + if old_basic_end in content: + content = content.replace(old_basic_end, new_basic_with_subdirectory) + print("✓ 在基础设置中添加了子目录设置") + else: + print("✗ 未找到基础设置结束位置") + + # 2. 将第1541行的"高级设置"改为"SEO与性能",并添加CDN和日期格式 + old_advanced_seo = ''' +

+ +

SEO

''' + + new_seo_performance = ''' +

+ +

SEO

''' + + if old_advanced_seo in content: + content = content.replace(old_advanced_seo, new_seo_performance) + print("✓ 将高级设置改为SEO与性能") + else: + print("✗ 未找到第一个高级设置标题") + + # 3. 在SEO设置后添加CDN和日期格式设置 + # 先找到SEO设置的结束位置(在"文章显示"之前) + old_seo_end = ''' + + ''' + + new_seo_with_cdn_date = ''' + +

+ + + + + + + + + + + +

+ +

%theme_version% 来表示主题版本号。', 'argon');?>

+ + + + + + + +

+ + + + + + + + + +

+ + + + + + ''' + + if old_seo_end in content: + content = content.replace(old_seo_end, new_seo_with_cdn_date) + print("✓ 在SEO与性能中添加了CDN加速和日期格式设置") + else: + print("✗ 未找到SEO设置结束位置") + + # 保存文件 + with open('settings.php', 'w', encoding='utf-8') as f: + f.write(content) + + print(f"\n优化完成! 新文件: {content.count(chr(10))} 行") + print("请检查 settings.php 文件") + +if __name__ == '__main__': + main() diff --git a/settings.php b/settings.php index bf10538..aab7aa9 100644 --- a/settings.php +++ b/settings.php @@ -291,6 +291,38 @@ function themeoptions_page(){ +

+ + + + + + + + + +

/blog/ /

+ + + + + +

+ + + + + + + + + +

/blog/ /

+ + + + +

@@ -1538,8 +1570,8 @@ function themeoptions_page(){ - -

+ +

SEO

@@ -1571,6 +1603,182 @@ function themeoptions_page(){ +

+ + + + + + + + + + + +

+ +

%theme_version% 来表示主题版本号。', 'argon');?>

+ + + + + + + +

+ + + + + + + + + +

+ + + + + +

+ + + + + + + + + + + +

+ +

%theme_version% 来表示主题版本号。', 'argon');?>

+ + + + + + + +

+ + + + + + + + + +

+ + + + +