Files
wordpress-theme-aksrt/templates/parts/user-home/panel-comments.php
T

40 lines
1.2 KiB
PHP

<?php
/**
* Public user home — comments tab panel body.
*
* Rendered inside the #panel-comments wrapper on the public user home and via
* the aksrt/v1 user-home panel REST fragment. Pagination is button-driven
* (aksrt_render_user_home_pagination) and never touches the URL.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$args = is_array($args ?? null) ? $args : [];
extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
$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) : ?>
<?php
get_template_part('templates/parts/content', 'profile-comment-item', ['comment' => $c]);
?>
<?php endforeach; ?>
</div>
<?php
aksrt_render_user_home_pagination((int) ceil($comment_count / max(1, $per_page)), (int) $comments_page);
else :
aksrt_render_profile_empty($svg_empty_comment, __('TA 还没有发表评论', 'aksrt'));
endif;