用户中心减层:收敛本人入口与 panel 契约
This commit is contained in:
1 parent
31c95c3bc6
commit
dec33ea15a
33 files changed
+1585
-1488
No files matched your search
+44
-1389
File diff suppressed because it is too large.
Load diff
@@ -174,20 +174,19 @@ $home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url
|
||||
<div class="profile-list">
|
||||
<?php while ($author_posts->have_posts()) : $author_posts->the_post(); ?>
|
||||
<?php
|
||||
set_query_var('aksrt_profile_item_action', [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
]);
|
||||
set_query_var('aksrt_profile_item_status', '');
|
||||
get_template_part('templates/parts/content', 'profile-list-item');
|
||||
get_template_part('templates/parts/content', 'profile-list-item', [
|
||||
'action' => [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
],
|
||||
]);
|
||||
?>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination((int) $author_posts->max_num_pages, $posts_page, 'posts_page');
|
||||
wp_reset_postdata();
|
||||
set_query_var('aksrt_profile_item_action', []);
|
||||
else :
|
||||
aksrt_render_profile_empty($svg_empty_post, __('TA 还没有发布文章', 'aksrt'));
|
||||
endif;
|
||||
@@ -211,11 +210,9 @@ $home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url
|
||||
<div class="profile-comment-list">
|
||||
<?php foreach ($user_comments as $c) : ?>
|
||||
<?php
|
||||
set_query_var('aksrt_profile_comment', $c);
|
||||
get_template_part('templates/parts/content', 'profile-comment-item');
|
||||
get_template_part('templates/parts/content', 'profile-comment-item', ['comment' => $c]);
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
<?php set_query_var('aksrt_profile_comment', null); ?>
|
||||
</div>
|
||||
<?php
|
||||
$cm_total_pages = (int) ceil($comment_count / $per_page);
|
||||
@@ -247,20 +244,19 @@ $home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url
|
||||
<div class="profile-list">
|
||||
<?php while ($favorites_query->have_posts()) : $favorites_query->the_post(); ?>
|
||||
<?php
|
||||
set_query_var('aksrt_profile_item_action', [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
get_template_part('templates/parts/content', 'profile-list-item', [
|
||||
'action' => [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __('阅读', 'aksrt'),
|
||||
],
|
||||
]);
|
||||
set_query_var('aksrt_profile_item_status', '');
|
||||
get_template_part('templates/parts/content', 'profile-list-item');
|
||||
?>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination((int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page');
|
||||
wp_reset_postdata();
|
||||
set_query_var('aksrt_profile_item_action', []);
|
||||
else :
|
||||
aksrt_render_profile_empty($svg_empty_favorite, __('TA 还没有收藏文章', 'aksrt'));
|
||||
endif;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Profile Comment List Item — image-less comment row for user center.
|
||||
*
|
||||
* 通过 set_query_var() 接收:
|
||||
* 通过 get_template_part() 的 $args 接收(保留 query var 兼容):
|
||||
* - aksrt_profile_comment: WP_Comment 对象
|
||||
*
|
||||
* @package AKSRT
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$comment = get_query_var('aksrt_profile_comment');
|
||||
$comment = $args['comment'] ?? get_query_var('aksrt_profile_comment');
|
||||
if (!$comment instanceof WP_Comment) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 用于:
|
||||
* - 我的文章 / 我的收藏 / 公开主页文章列表
|
||||
*
|
||||
* 通过 set_query_var() 接收以下参数(可选):
|
||||
* 通过 get_template_part() 的 $args 接收以下参数(保留 query var 兼容):
|
||||
* - aksrt_profile_item_action: ['type'=>'edit'|'view'|'unfavorite', 'url'=>'...', 'label'=>'...']
|
||||
* - aksrt_profile_item_status: 文章状态徽章文本(如 "草稿" / "私密")
|
||||
*
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$action = get_query_var('aksrt_profile_item_action', []);
|
||||
$action = isset($args['action']) ? $args['action'] : get_query_var('aksrt_profile_item_action', []);
|
||||
if (!is_array($action)) {
|
||||
$action = [];
|
||||
}
|
||||
@@ -22,7 +22,7 @@ $action_type = isset($action['type']) ? (string) $action['type'] : '';
|
||||
$action_url = isset($action['url']) ? (string) $action['url'] : '';
|
||||
$action_label = isset($action['label']) ? (string) $action['label'] : '';
|
||||
|
||||
$status_label = (string) get_query_var('aksrt_profile_item_status', '');
|
||||
$status_label = isset($args['status']) ? (string) $args['status'] : (string) get_query_var('aksrt_profile_item_status', '');
|
||||
|
||||
$post_id = get_the_ID();
|
||||
$permalink = get_permalink();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/** User center account modals. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
echo $context['account_modals_html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/** User center header. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
echo $context['header_html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/** User center mobile tabs. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
?>
|
||||
<div class="dashboard-tabs uc-mobile-tabs" role="tablist">
|
||||
<?php foreach (($context['mobile_tabs'] ?? []) as $tab) : ?>
|
||||
<a class="<?php echo !empty($tab['is_active']) ? 'is-active' : ''; ?>" href="<?php echo esc_url($tab['url']); ?>" data-tab="<?php echo esc_attr($tab['key']); ?>" role="tab" aria-selected="<?php echo !empty($tab['is_active']) ? 'true' : 'false'; ?>"><?php echo esc_html($tab['label']); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** User center comments panel. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$panel = is_array($args['panel'] ?? null) ? $args['panel'] : [];
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel['key'] ?? 'comments'); ?>" class="dashboard-panel<?php echo !empty($panel['is_active']) ? ' is-active' : ''; ?>" role="tabpanel"<?php echo empty($panel['is_active']) ? ' hidden' : ''; ?> data-panel-loaded="<?php echo !empty($panel['is_loaded']) ? 'true' : 'false'; ?>" data-tab-url="<?php echo esc_url($panel['url'] ?? ''); ?>">
|
||||
<?php echo $panel['html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** User center credits panel. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$panel = is_array($args['panel'] ?? null) ? $args['panel'] : [];
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel['key'] ?? 'credits'); ?>" class="dashboard-panel<?php echo !empty($panel['is_active']) ? ' is-active' : ''; ?>" role="tabpanel"<?php echo empty($panel['is_active']) ? ' hidden' : ''; ?> data-panel-loaded="<?php echo !empty($panel['is_loaded']) ? 'true' : 'false'; ?>" data-tab-url="<?php echo esc_url($panel['url'] ?? ''); ?>">
|
||||
<?php echo $panel['html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** User center favorites panel. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$panel = is_array($args['panel'] ?? null) ? $args['panel'] : [];
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel['key'] ?? 'favorites'); ?>" class="dashboard-panel<?php echo !empty($panel['is_active']) ? ' is-active' : ''; ?>" role="tabpanel"<?php echo empty($panel['is_active']) ? ' hidden' : ''; ?> data-panel-loaded="<?php echo !empty($panel['is_loaded']) ? 'true' : 'false'; ?>" data-tab-url="<?php echo esc_url($panel['url'] ?? ''); ?>">
|
||||
<?php echo $panel['html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** User center posts panel. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$panel = is_array($args['panel'] ?? null) ? $args['panel'] : [];
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel['key'] ?? 'posts'); ?>" class="dashboard-panel<?php echo !empty($panel['is_active']) ? ' is-active' : ''; ?>" role="tabpanel"<?php echo empty($panel['is_active']) ? ' hidden' : ''; ?> data-panel-loaded="<?php echo !empty($panel['is_loaded']) ? 'true' : 'false'; ?>" data-tab-url="<?php echo esc_url($panel['url'] ?? ''); ?>">
|
||||
<?php echo $panel['html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** User center profile panel. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$panel = is_array($args['panel'] ?? null) ? $args['panel'] : [];
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel['key'] ?? 'profile'); ?>" class="dashboard-panel<?php echo !empty($panel['is_active']) ? ' is-active' : ''; ?>" role="tabpanel"<?php echo empty($panel['is_active']) ? ' hidden' : ''; ?> data-panel-loaded="<?php echo !empty($panel['is_loaded']) ? 'true' : 'false'; ?>" data-tab-url="<?php echo esc_url($panel['url'] ?? ''); ?>">
|
||||
<?php echo $panel['html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
/** User center settings panel. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$panel = is_array($args['panel'] ?? null) ? $args['panel'] : [];
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel['key'] ?? 'settings'); ?>" class="dashboard-panel<?php echo !empty($panel['is_active']) ? ' is-active' : ''; ?>" role="tabpanel"<?php echo empty($panel['is_active']) ? ' hidden' : ''; ?> data-panel-loaded="<?php echo !empty($panel['is_loaded']) ? 'true' : 'false'; ?>" data-tab-url="<?php echo esc_url($panel['url'] ?? ''); ?>">
|
||||
<?php echo $panel['html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Generic user-center panel wrapper for registered extensions.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$panel = is_array($args['panel'] ?? null) ? $args['panel'] : [];
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel['key'] ?? 'custom'); ?>" class="dashboard-panel<?php echo !empty($panel['is_active']) ? ' is-active' : ''; ?>" role="tabpanel"<?php echo empty($panel['is_active']) ? ' hidden' : ''; ?> data-panel-loaded="<?php echo !empty($panel['is_loaded']) ? 'true' : 'false'; ?>" data-tab-url="<?php echo esc_url($panel['url'] ?? ''); ?>">
|
||||
<?php echo $panel['html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/** User center runtime configuration. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
?>
|
||||
<script>window.aksrtUserCenter=<?php echo wp_json_encode($context['runtime_config'] ?? []); ?>;</script>
|
||||
<?php if (!empty($context['cover_upload_config'])) : ?>
|
||||
<script>window.aksrtAuthorPage=Object.assign({},window.aksrtAuthorPage||{},{coverUpload:<?php echo wp_json_encode($context['cover_upload_config']); ?>});</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/** User center sidebar. @package AKSRT */
|
||||
defined('ABSPATH') || exit;
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
echo $context['sidebar_html'] ?? ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
Reference in new issue
Block a user