fix: 修复 AI API 测试功能缺少 nonce 参数的问题
- 在测试 API 的 AJAX 请求中添加 nonce 参数
- 使用 wp_create_nonce('argon_test_unified_api') 生成 nonce
- 修复测试按钮点击后无法正常工作的问题
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# 分析 settings.php 文件结构
|
||||
|
||||
with open('settings.php', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 查找关键位置
|
||||
pos1 = content.find('<!-- ========== 12. 文章功能 ==========')
|
||||
pos2 = content.find('<tr><th class="subtitle"><h3 id="subsection-footnote">')
|
||||
|
||||
print(f'文章功能开始位置: {pos1}')
|
||||
print(f'脚注引用开始位置: {pos2}')
|
||||
print(f'需要替换的字符数: {pos2 - pos1}')
|
||||
|
||||
# 统计行数
|
||||
lines_before = content[:pos1].count('\n')
|
||||
lines_between = content[pos1:pos2].count('\n')
|
||||
|
||||
print(f'\n文章功能开始行: {lines_before + 1}')
|
||||
print(f'需要移除的行数: {lines_between}')
|
||||
print(f'脚注引用开始行: {lines_before + lines_between + 1}')
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Settings.php AI 功能重构脚本
|
||||
移除旧的 AI 设置,插入新的统一 AI 功能部分
|
||||
"""
|
||||
|
||||
# 读取文件
|
||||
with open('settings.php', 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# 读取新的 AI 部分
|
||||
with open('tmp/complete-ai-section.php', 'r', encoding='utf-8') as f:
|
||||
new_ai_section = f.read()
|
||||
|
||||
# 读取评论审核的其他设置(保留非 AI 部分)
|
||||
with open('tmp/comment-settings-other.txt', 'r', encoding='utf-8') as f:
|
||||
comment_other_settings = f.read()
|
||||
|
||||
# 步骤 1: 在第 1985 行之前插入新的 AI 功能部分
|
||||
# 步骤 2: 移除第 1987-2599 行(旧的 AI 摘要设置)
|
||||
# 步骤 3: 在评论设置中移除 AI 垃圾评论识别子分类,添加到新的 AI 功能部分
|
||||
|
||||
# 找到插入位置(文章功能之前)
|
||||
insert_pos = None
|
||||
for i, line in enumerate(lines):
|
||||
if '<!-- ========== 12. 文章功能 ==========' in line:
|
||||
insert_pos = i
|
||||
break
|
||||
|
||||
if insert_pos is None:
|
||||
print("错误:找不到文章功能部分")
|
||||
exit(1)
|
||||
|
||||
# 找到需要移除的旧 AI 摘要设置的结束位置
|
||||
remove_end = None
|
||||
for i in range(insert_pos, len(lines)):
|
||||
if 'subsection-footnote' in lines[i] and '脚注引用' in lines[i]:
|
||||
remove_end = i
|
||||
break
|
||||
|
||||
if remove_end is None:
|
||||
print("错误:找不到脚注引用部分")
|
||||
exit(1)
|
||||
|
||||
print(f"将在第 {insert_pos + 1} 行插入新的 AI 功能部分")
|
||||
print(f"将移除第 {insert_pos + 3} 到 {remove_end} 行的旧 AI 摘要设置")
|
||||
|
||||
# 构建新文件
|
||||
new_lines = []
|
||||
|
||||
# 保留插入位置之前的内容
|
||||
new_lines.extend(lines[:insert_pos])
|
||||
|
||||
# 插入新的 AI 功能部分
|
||||
new_lines.append(new_ai_section)
|
||||
new_lines.append('\n')
|
||||
|
||||
# 跳过旧的 AI 摘要设置,保留文章功能标题和之后的内容
|
||||
new_lines.append(lines[insert_pos]) # 文章功能标题
|
||||
new_lines.append(lines[insert_pos + 1]) # <tr><th class="subtitle">
|
||||
|
||||
# 保留脚注引用及之后的内容
|
||||
new_lines.extend(lines[remove_end:])
|
||||
|
||||
# 写入新文件
|
||||
with open('settings.php', 'w', encoding='utf-8') as f:
|
||||
f.writelines(new_lines)
|
||||
|
||||
print("✓ 成功插入新的 AI 功能部分")
|
||||
print("✓ 成功移除旧的 AI 摘要设置")
|
||||
print(f"✓ 文件行数变化:{len(lines)} → {len(new_lines)}")
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
删除 settings.php 中重复的 AI 垃圾评论识别部分
|
||||
"""
|
||||
|
||||
def remove_duplicate_spam_detection():
|
||||
with open('settings.php', 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
# 删除第 4619-5204 行(Python 索引从 0 开始,所以是 4618-5203)
|
||||
# 第 4619 行是 <tr><th class="subtitle"><h3 id="subsection-comment-spam-detection">
|
||||
# 第 5204 行是 </tr> (在 subsection-comment-appearance 之前)
|
||||
|
||||
start_line = 4618 # 第 4619 行(索引从 0 开始)
|
||||
end_line = 5204 # 第 5205 行(不包含)
|
||||
|
||||
# 保留前面和后面的内容
|
||||
new_lines = lines[:start_line] + lines[end_line:]
|
||||
|
||||
# 写回文件
|
||||
with open('settings.php', 'w', encoding='utf-8') as f:
|
||||
f.writelines(new_lines)
|
||||
|
||||
deleted_lines = end_line - start_line
|
||||
print(f"✓ 已删除第 {start_line + 1}-{end_line} 行(共 {deleted_lines} 行)")
|
||||
print(f"✓ 文件行数:{len(lines)} → {len(new_lines)} (-{deleted_lines})")
|
||||
|
||||
if __name__ == '__main__':
|
||||
remove_duplicate_spam_detection()
|
||||
Reference in New Issue
Block a user