把 uh-forum 样式收进 user-home 路由、author.php 收成 301 回退、公开主页脚本以 author.js 为唯一实现,并去掉 enqueue/body class 中的 is_author 分叉。
32 lines
796 B
PHP
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;
|