70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* User center profile favorites part.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
|
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
|
?>
|
|
<div class="widget-card">
|
|
<div class="profile-list-header">
|
|
<h3 class="widget-title widget-title--inline">
|
|
<?php printf(esc_html__('我的收藏(%d 篇)', 'aksrt'), $favorite_count); ?>
|
|
</h3>
|
|
</div>
|
|
<?php if (!empty($favorite_post_ids)) :
|
|
$favorites_query = new WP_Query([
|
|
'post_type' => 'post',
|
|
'post_status' => 'publish',
|
|
'post__in' => $favorite_post_ids,
|
|
'orderby' => 'post__in',
|
|
'posts_per_page' => $per_page,
|
|
'paged' => $favorites_page,
|
|
'ignore_sticky_posts' => true,
|
|
'no_found_rows' => false,
|
|
'update_post_meta_cache' => false,
|
|
]);
|
|
if ($favorites_query->have_posts()) :
|
|
?>
|
|
<div class="profile-list" data-list="favorites">
|
|
<?php
|
|
while ($favorites_query->have_posts()) :
|
|
$favorites_query->the_post();
|
|
get_template_part('templates/parts/content', 'profile-list-item', [
|
|
'action' => [
|
|
'type' => 'unfavorite',
|
|
'url' => '#',
|
|
'label' => __('取消收藏', 'aksrt'),
|
|
],
|
|
]);
|
|
endwhile;
|
|
?>
|
|
</div>
|
|
<?php
|
|
aksrt_render_profile_pagination((int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page');
|
|
wp_reset_postdata();
|
|
else :
|
|
aksrt_render_profile_empty(
|
|
$svg_empty_favorite,
|
|
__('收藏列表为空', 'aksrt'),
|
|
__('点击文章页面的星标收藏喜欢的内容。', 'aksrt'),
|
|
home_url('/'),
|
|
__('去发现好文', 'aksrt')
|
|
);
|
|
endif;
|
|
else :
|
|
aksrt_render_profile_empty(
|
|
$svg_empty_favorite,
|
|
__('收藏列表为空', 'aksrt'),
|
|
__('点击文章页面的星标收藏喜欢的内容。', 'aksrt'),
|
|
home_url('/'),
|
|
__('去发现好文', 'aksrt')
|
|
);
|
|
endif;
|
|
?>
|
|
</div>
|