Files
kate522 f76d4650e5 用户域一次性收口:统一公开主页资源归属并折叠作者页双路径
把 uh-forum 样式收进 user-home 路由、author.php 收成 301 回退、公开主页脚本以 author.js 为唯一实现,并去掉 enqueue/body class 中的 is_author 分叉。
2026-07-10 22:11:44 +08:00

32 lines
796 B
PHP

<?php
/**
* Author archive fallback.
*
* Canonical public profile is /user/{nicename}/ (page-user-home.php).
* class-aksrt-user.php already 301-redirects is_author() there; this file
* remains only as a last-resort template if rewrite/redirect is bypassed.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$author_id = (int) get_queried_object_id();
if (!$author_id) {
$author_id = (int) get_query_var('author');
}
$user = $author_id ? get_userdata($author_id) : null;
if ($user instanceof WP_User && function_exists('aksrt_get_user_home_url')) {
wp_safe_redirect(aksrt_get_user_home_url($user), 301);
exit;
}
if ($user instanceof WP_User) {
wp_safe_redirect(home_url('/user/' . trailingslashit($user->user_nicename)), 301);
exit;
}
wp_safe_redirect(home_url('/'), 302);
exit;