From a8b2997f765ac7c990d645d260d8b9cdfabde08f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 10 Jul 2026 13:55:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=B8=BB=E9=A1=B5/=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E9=A1=B5=E5=AF=B9=E9=BD=90=20content-shell=20?= =?UTF-8?q?=E4=B8=8E=20author-hero=20=E5=A5=91=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去掉 author-hero query-var 传参,统一 content-wrap 壳层, 作者页侧栏改为 page-owned,不再 patch generic sidebar。 --- author.php | 32 ++++-- templates/pages/page-user-home.php | 162 ++++++++++++++------------- templates/parts/user/author-hero.php | 49 ++++---- 3 files changed, 130 insertions(+), 113 deletions(-) diff --git a/author.php b/author.php index fda9ff30..c4cf50fb 100644 --- a/author.php +++ b/author.php @@ -44,19 +44,18 @@ $user_home_settings = class_exists('AKSRT_Settings') require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php'; ?> -
+
-
+
$author, + 'dashboard' => $dashboard, + 'user_home_settings' => $user_home_settings, + 'is_author_page' => true, + ]); ?> @@ -109,7 +108,20 @@ require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
- +
diff --git a/templates/pages/page-user-home.php b/templates/pages/page-user-home.php index f69cd8eb..08d67b0b 100644 --- a/templates/pages/page-user-home.php +++ b/templates/pages/page-user-home.php @@ -129,17 +129,18 @@ $svg_empty_favorite = ' -
-
- +
+
+
+
+ $user, + 'dashboard' => $dashboard, + 'user_home_settings' => $user_home_settings, + 'is_author_page' => false, + ]); + ?>
@@ -483,80 +484,81 @@ $home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url
-
diff --git a/templates/parts/user/author-hero.php b/templates/parts/user/author-hero.php index 463b498f..82da9357 100644 --- a/templates/parts/user/author-hero.php +++ b/templates/parts/user/author-hero.php @@ -2,39 +2,42 @@ /** * Author Hero — shared hero section for author archive and public user homepage. * - * Expected variables (passed via get_template_part or set_query_var): - * $user (WP_User) Target user object. - * $dashboard (array) Data from aksrt_get_user_dashboard_view(). - * $user_home_settings (array) User home display settings. - * $is_author_page (bool) True when rendering on author.php (archive context). + * Contract: get_template_part(..., null, $args) + * user WP_User + * dashboard array from aksrt_get_user_dashboard_view() + * user_home_settings array + * is_author_page bool * * @package AKSRT */ defined('ABSPATH') || exit; -if (empty($user) || !($user instanceof WP_User)) { - return; +$args = is_array($args ?? null) ? $args : []; +$user = $args['user'] ?? null; +$dashboard = is_array($args['dashboard'] ?? null) ? $args['dashboard'] : []; +$settings = is_array($args['user_home_settings'] ?? null) ? $args['user_home_settings'] : []; +$is_author = !empty($args['is_author_page']); + +if (!($user instanceof WP_User)) { + return; } -$user_id = (int) $user->ID; -$dashboard = $dashboard ?? []; -$settings = $user_home_settings ?? []; -$is_author = !empty($is_author_page); -$home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user) : home_url('/'); -$show_cover = !empty($settings['cover']); -$show_follow = !empty($settings['follow']); +$user_id = (int) $user->ID; +$home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user) : home_url('/'); +$show_cover = !empty($settings['cover']); +$show_follow = !empty($settings['follow']); -$post_count = (int) ($dashboard['post_count'] ?? 0); -$comment_count = (int) ($dashboard['comment_count'] ?? 0); +$post_count = (int) ($dashboard['post_count'] ?? 0); +$comment_count = (int) ($dashboard['comment_count'] ?? 0); $favorite_count = (int) ($dashboard['favorite_count'] ?? 0); -$contacts = $dashboard['user_contacts'] ?? []; -$social_on = !empty($dashboard['social_links_on']); -$signals = $dashboard['profile_signals'] ?? []; -$notice = $dashboard['profile_notice'] ?? null; -$show_report = !empty($dashboard['show_report']); -$bg_url = $dashboard['background_url'] ?? ''; -$is_own = !empty($dashboard['is_own_profile']); +$contacts = $dashboard['user_contacts'] ?? []; +$social_on = !empty($dashboard['social_links_on']); +$signals = $dashboard['profile_signals'] ?? []; +$notice = $dashboard['profile_notice'] ?? null; +$show_report = !empty($dashboard['show_report']); +$bg_url = $dashboard['background_url'] ?? ''; +$is_own = !empty($dashboard['is_own_profile']); ?>