223 lines
11 KiB
PHP
223 lines
11 KiB
PHP
<?php
|
|
defined('ABSPATH') || exit;
|
|
|
|
</button>
|
|
<?php else : ?>
|
|
<a href="<?php echo esc_url( aksrt_get_login_url( $public_home_url ) ); ?>" class="btn-outline btn-sm aksrt-user-home__follow-btn">
|
|
<i class="far fa-heart" aria-hidden="true"></i>
|
|
<span><?php esc_html_e( '登录后关注', 'aksrt' ); ?></span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
<?php if ( $show_report_button ) : ?>
|
|
<?php if ( is_user_logged_in() ) : ?>
|
|
<button type="button" class="btn-ghost btn-sm aksrt-user-home__report-btn" data-aksrt-report='{"target_type":"user","target_id":<?php echo (int) $user_id; ?>}' title="<?php esc_attr_e( '举报该用户', 'aksrt' ); ?>">
|
|
<i class="far fa-flag" aria-hidden="true"></i>
|
|
<span><?php esc_html_e( '举报', 'aksrt' ); ?></span>
|
|
</button>
|
|
<?php else : ?>
|
|
<a href="<?php echo esc_url( aksrt_get_login_url( $public_home_url ) ); ?>" class="btn-ghost btn-sm aksrt-user-home__report-btn">
|
|
<i class="far fa-flag" aria-hidden="true"></i>
|
|
<span><?php esc_html_e( '登录后举报', 'aksrt' ); ?></span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<?php if ( ! empty( $profile_notice ) ) : ?>
|
|
<div class="aksrt-user-home__notice aksrt-user-home__notice--<?php echo esc_attr( $profile_notice['state'] ); ?>">
|
|
<i class="fas fa-exclamation-circle" aria-hidden="true"></i>
|
|
<span><?php echo esc_html( $profile_notice['text'] ); ?></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="dashboard dashboard--public" data-default-tab="<?php echo esc_attr( $public_default_tab ); ?>">
|
|
<div class="dashboard-tabs" role="tablist">
|
|
<?php foreach ( $public_tab_keys as $public_tab_key ) : ?>
|
|
<button type="button" class="<?php echo $public_active_tab === $public_tab_key ? 'is-active' : ''; ?>" data-tab="<?php echo esc_attr( $public_tab_key ); ?>" role="tab">
|
|
<?php echo esc_html( $public_tab_labels[ $public_tab_key ] ?? ucfirst( $public_tab_key ) ); ?>
|
|
<span class="dashboard-tabs__count"><?php echo esc_html( (string) ( $public_tab_counts[ $public_tab_key ] ?? 0 ) ); ?></span>
|
|
</button>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php if ( in_array( 'posts', $public_tab_keys, true ) ) : ?>
|
|
<div id="panel-posts" class="dashboard-panel<?php echo 'posts' === $public_active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'posts' !== $public_active_tab ? ' hidden' : ''; ?>>
|
|
<?php
|
|
$author_posts = new WP_Query( [
|
|
'author' => $user_id,
|
|
'posts_per_page' => $per_page,
|
|
'post_status' => 'publish',
|
|
'paged' => $posts_page,
|
|
'no_found_rows' => false,
|
|
'update_post_meta_cache' => false,
|
|
] );
|
|
if ( $author_posts->have_posts() ) : ?>
|
|
<div class="profile-list">
|
|
<?php while ( $author_posts->have_posts() ) : $author_posts->the_post();
|
|
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' );
|
|
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; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( in_array( 'comments', $public_tab_keys, true ) ) : ?>
|
|
<div id="panel-comments" class="dashboard-panel<?php echo 'comments' === $public_active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'comments' !== $public_active_tab ? ' hidden' : ''; ?>>
|
|
<?php
|
|
$user_comments = get_comments( [
|
|
'user_id' => $user_id,
|
|
'status' => 'approve',
|
|
'number' => $per_page,
|
|
'offset' => ( $comments_page - 1 ) * $per_page,
|
|
'type' => 'comment',
|
|
'update_comment_meta_cache' => false,
|
|
] );
|
|
if ( $user_comments ) : ?>
|
|
<div class="profile-comment-list">
|
|
<?php foreach ( $user_comments as $c ) :
|
|
set_query_var( 'aksrt_profile_comment', $c );
|
|
get_template_part( 'templates/parts/content', 'profile-comment-item' );
|
|
endforeach;
|
|
set_query_var( 'aksrt_profile_comment', null ); ?>
|
|
</div>
|
|
<?php
|
|
$cm_total_pages = (int) ceil( $comment_count / $per_page );
|
|
aksrt_render_profile_pagination( $cm_total_pages, $comments_page, 'comments_page' );
|
|
?>
|
|
<?php else :
|
|
aksrt_render_profile_empty( $svg_empty_comment, __( 'TA 还没有发表评论', 'aksrt' ) );
|
|
endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if ( in_array( 'favorites', $public_tab_keys, true ) ) : ?>
|
|
<div id="panel-favorites" class="dashboard-panel<?php echo 'favorites' === $public_active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'favorites' !== $public_active_tab ? ' hidden' : ''; ?>>
|
|
<?php
|
|
if ( ! empty( $favorite_post_ids ) ) {
|
|
$favorite_query = new WP_Query( [
|
|
'post_type' => 'post',
|
|
'post__in' => $favorite_post_ids,
|
|
'orderby' => 'post__in',
|
|
'posts_per_page' => $per_page,
|
|
'paged' => $favorites_page,
|
|
'no_found_rows' => false,
|
|
'update_post_meta_cache' => false,
|
|
] );
|
|
} else {
|
|
$favorite_query = null;
|
|
}
|
|
|
|
if ( $favorite_query && $favorite_query->have_posts() ) :
|
|
?>
|
|
<div class="profile-list">
|
|
<?php while ( $favorite_query->have_posts() ) : $favorite_query->the_post();
|
|
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' );
|
|
endwhile; ?>
|
|
</div>
|
|
<?php
|
|
aksrt_render_profile_pagination( (int) $favorite_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; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if ( $is_own_profile ) : ?>
|
|
<!-- 配置对象:供 user-center.js 使用 -->
|
|
<script>window.aksrtUserCenter = {
|
|
ajaxUrl: <?php echo wp_json_encode( admin_url( 'admin-ajax.php' ) ); ?>,
|
|
publicNonce: <?php echo wp_json_encode( wp_create_nonce( 'aksrt_public_nonce' ) ); ?>,
|
|
settingsNonce: <?php echo wp_json_encode( wp_create_nonce( 'aksrt_account_settings' ) ); ?>,
|
|
userId: <?php echo (int) $user_id; ?>,
|
|
defaultTab: <?php echo wp_json_encode( $default_dashboard_tab ); ?>,
|
|
i18n: {
|
|
contactUrlPlaceholder: <?php echo wp_json_encode( __( '链接 URL', 'aksrt' ) ); ?>,
|
|
deleteLabel: <?php echo wp_json_encode( __( '删除', 'aksrt' ) ); ?>,
|
|
saving: <?php echo wp_json_encode( __( '保存中…', 'aksrt' ) ); ?>,
|
|
saveBtn: <?php echo wp_json_encode( __( '保存修改', 'aksrt' ) ); ?>,
|
|
saved: <?php echo wp_json_encode( __( '已保存', 'aksrt' ) ); ?>,
|
|
saveFailed: <?php echo wp_json_encode( __( '保存失败', 'aksrt' ) ); ?>,
|
|
networkError: <?php echo wp_json_encode( __( '网络错误,请重试', 'aksrt' ) ); ?>,
|
|
confirmUnfavorite: <?php echo wp_json_encode( __( '确定取消收藏这篇文章?', 'aksrt' ) ); ?>,
|
|
unfavorited: <?php echo wp_json_encode( __( '已取消收藏', 'aksrt' ) ); ?>,
|
|
operationFailed: <?php echo wp_json_encode( __( '操作失败', 'aksrt' ) ); ?>,
|
|
markedRead: <?php echo wp_json_encode( __( '已标记为已读', 'aksrt' ) ); ?>,
|
|
notificationDeleted: <?php echo wp_json_encode( __( '已删除通知', 'aksrt' ) ); ?>,
|
|
allMarkedRead: <?php echo wp_json_encode( __( '已全部标记为已读', 'aksrt' ) ); ?>,
|
|
selectNotifications: <?php echo wp_json_encode( __( '请先选择要标记的通知', 'aksrt' ) ); ?>,
|
|
selectedMarkedRead: <?php echo wp_json_encode( __( '已标记所选通知为已读', 'aksrt' ) ); ?>,
|
|
confirmDeleteNotification: <?php echo wp_json_encode( __( '确定删除这条通知?', 'aksrt' ) ); ?>,
|
|
confirmBatchDelete: <?php echo wp_json_encode( __( '确定批量删除所选通知?', 'aksrt' ) ); ?>,
|
|
batchDeleted: <?php echo wp_json_encode( __( '已删除所选通知', 'aksrt' ) ); ?>,
|
|
sendToCurrentEmail: <?php echo wp_json_encode( __( '发送到当前邮箱', 'aksrt' ) ); ?>,
|
|
sendToNewEmail: <?php echo wp_json_encode( __( '发送到新邮箱', 'aksrt' ) ); ?>,
|
|
sendCode: <?php echo wp_json_encode( __( '发送验证码', 'aksrt' ) ); ?>,
|
|
sending: <?php echo wp_json_encode( __( '发送中...', 'aksrt' ) ); ?>,
|
|
codeSent: <?php echo wp_json_encode( __( '验证码已发送', 'aksrt' ) ); ?>,
|
|
sendFailed: <?php echo wp_json_encode( __( '发送失败', 'aksrt' ) ); ?>,
|
|
fillRequired: <?php echo wp_json_encode( __( '请填写必填项', 'aksrt' ) ); ?>,
|
|
passwordMismatch: <?php echo wp_json_encode( __( '两次输入的新密码不一致', 'aksrt' ) ); ?>,
|
|
submitting: <?php echo wp_json_encode( __( '提交中...', 'aksrt' ) ); ?>,
|
|
confirmUnbind: <?php echo wp_json_encode( __( '确定解除绑定?', 'aksrt' ) ); ?>,
|
|
unbinding: <?php echo wp_json_encode( __( '解除中...', 'aksrt' ) ); ?>,
|
|
unbindSuccess: <?php echo wp_json_encode( __( '解除成功', 'aksrt' ) ); ?>,
|
|
unbindFailed: <?php echo wp_json_encode( __( '解除失败', 'aksrt' ) ); ?>,
|
|
unbind: <?php echo wp_json_encode( __( '解除', 'aksrt' ) ); ?>
|
|
}
|
|
};</script>
|
|
|
|
<?php if ( $allow_bg_upload ) : ?>
|
|
<script>
|
|
window.aksrtAuthorPage = Object.assign({}, window.aksrtAuthorPage || {}, {
|
|
coverUpload: {
|
|
enabled: true,
|
|
restUrl: <?php echo wp_json_encode( rest_url( 'aksrt/v1/user/background' ) ); ?>,
|
|
restNonce: <?php echo wp_json_encode( wp_create_nonce( 'wp_rest' ) ); ?>,
|
|
buttonId: 'aksrt-upload-bg-btn',
|
|
inputId: 'aksrt-bg-file-input',
|
|
imageId: 'aksrt-cover-img',
|
|
fieldName: 'background',
|
|
maxSize: 2097152,
|
|
fallbackImage: <?php echo wp_json_encode( AKSRT_URI . '/assets/img/person_background.png' ); ?>,
|
|
idleText: <?php echo wp_json_encode( __( '编辑', 'aksrt' ) ); ?>,
|
|
loadingText: <?php echo wp_json_encode( __( '上传中…', 'aksrt' ) ); ?>,
|
|
tooLargeText: <?php echo wp_json_encode( __( '图片大小不能超过 2MB', 'aksrt' ) ); ?>,
|
|
successText: <?php echo wp_json_encode( __( '背景图已更新', 'aksrt' ) ); ?>,
|
|
errorText: <?php echo wp_json_encode( __( '上传失败', 'aksrt' ) ); ?>,
|
|
networkErrorText: <?php echo wp_json_encode( __( '网络错误,请重试', 'aksrt' ) ); ?>
|
|
}
|
|
});
|
|
</script>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</main>
|
|
|
|
<?php
|
|
get_footer();
|