feat: 添加 AI 查询页面固定链接支持
- 注册 /ai-query 和 /ai-query/{CODE} 路由
- 支持 URL 路径参数传递识别码
- 更新所有识别码链接为固定链接格式
- 与友链、反馈页面保持一致的实现方式
This commit is contained in:
@@ -4482,12 +4482,20 @@ function argon_feedback_rewrite() {
|
||||
add_rewrite_rule('^feedback/?$', 'index.php?argon_feedback_view=1', 'top');
|
||||
}
|
||||
|
||||
// AI 查询页面 URL 重写
|
||||
add_action('init', 'argon_ai_query_rewrite');
|
||||
function argon_ai_query_rewrite() {
|
||||
add_rewrite_rule('^ai-query/?$', 'index.php?argon_ai_query=1', 'top');
|
||||
add_rewrite_rule('^ai-query/([A-Z0-9]{8})/?$', 'index.php?argon_ai_query=1&code=$matches[1]', 'top');
|
||||
}
|
||||
|
||||
// 主题激活或更新时刷新重写规则
|
||||
add_action('after_switch_theme', 'argon_flush_rewrite_rules');
|
||||
add_action('upgrader_process_complete', 'argon_flush_rewrite_rules');
|
||||
function argon_flush_rewrite_rules() {
|
||||
argon_friend_links_rewrite();
|
||||
argon_feedback_rewrite();
|
||||
argon_ai_query_rewrite();
|
||||
flush_rewrite_rules();
|
||||
}
|
||||
|
||||
@@ -4495,6 +4503,7 @@ add_filter('query_vars', 'argon_friend_links_query_vars');
|
||||
function argon_friend_links_query_vars($vars) {
|
||||
$vars[] = 'argon_friend_links';
|
||||
$vars[] = 'argon_feedback_view';
|
||||
$vars[] = 'argon_ai_query';
|
||||
return $vars;
|
||||
}
|
||||
|
||||
@@ -4515,6 +4524,15 @@ function argon_feedback_template() {
|
||||
}
|
||||
}
|
||||
|
||||
// AI 查询页面路由
|
||||
add_action('template_redirect', 'argon_ai_query_template');
|
||||
function argon_ai_query_template() {
|
||||
if (get_query_var('argon_ai_query')) {
|
||||
include(get_template_directory() . '/ai-summary-query.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//隐藏 admin 管理条
|
||||
//show_admin_bar(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user