diff --git a/src/AKSRT/Widgets/HotPostsWidget.php b/src/AKSRT/Widgets/HotPostsWidget.php
index 430635bd..8d452688 100644
--- a/src/AKSRT/Widgets/HotPostsWidget.php
+++ b/src/AKSRT/Widgets/HotPostsWidget.php
@@ -70,48 +70,83 @@ class HotPostsWidget extends \WP_Widget {
if (!$query->have_posts()) {
return '';
}
- $show_thumb = !empty($instance['show_thumb']);
- $order_by = sanitize_key((string) ($instance['order_by'] ?? 'views'));
- $placeholder = get_template_directory_uri() . '/assets/img/placeholder.svg';
+ $show_thumb = !isset($instance['show_thumb']) || !empty($instance['show_thumb']);
+ $order_by = sanitize_key((string) ($instance['order_by'] ?? 'views'));
+ $placeholder = get_template_directory_uri() . '/assets/img/placeholder.svg';
+ $top_tones = ['jb-red', 'jb-yellow', 'b-gray'];
ob_start();
$index = $start;
while ($query->have_posts()) {
$query->the_post();
$index++;
- $rank_class = $index <= 3 ? ' rank-top' : '';
- $pid = get_the_ID();
- if ($order_by === 'comments') {
- $metric = (int) get_comments_number($pid);
- $metric_icon = 'fa-comment-o';
- } elseif ($order_by === 'likes') {
- $metric = function_exists('aksrt_get_post_likes') ? (int) aksrt_get_post_likes($pid) : (int) get_post_meta($pid, '_aksrt_like_count', true);
- $metric_icon = 'fa-heart';
- } elseif ($order_by === 'favorites') {
- $metric = (int) get_post_meta($pid, '_aksrt_favorite_count', true);
- $metric_icon = 'fa-star';
- } elseif ($order_by === 'downloads') {
- $metric = (int) get_post_meta($pid, '_aksrt_res_download_count', true);
- $metric_icon = 'fa-download';
- } else {
- $metric = (int) get_post_meta($pid, 'aksrt_post_views', true);
- $metric_icon = 'fa-eye';
+ $pid = (int) get_the_ID();
+ if ($order_by === 'comments') {
+ $metric = (int) get_comments_number($pid);
+ $metric_icon = 'fa-comment-o';
+ $metric_label = __('条评论', 'aksrt');
+ } elseif ($order_by === 'likes') {
+ $metric = function_exists('aksrt_get_post_likes') ? (int) aksrt_get_post_likes($pid) : (int) get_post_meta($pid, '_aksrt_like_count', true);
+ $metric_icon = 'fa-heart';
+ $metric_label = __('人点赞', 'aksrt');
+ } elseif ($order_by === 'favorites') {
+ $metric = (int) get_post_meta($pid, '_aksrt_favorite_count', true);
+ $metric_icon = 'fa-star';
+ $metric_label = __('人收藏', 'aksrt');
+ } elseif ($order_by === 'downloads') {
+ $metric = (int) get_post_meta($pid, '_aksrt_res_download_count', true);
+ $metric_icon = 'fa-download';
+ $metric_label = __('次下载', 'aksrt');
+ } else {
+ $metric = (int) get_post_meta($pid, 'aksrt_post_views', true);
+ $metric_icon = 'fa-eye';
+ $metric_label = __('次阅读', 'aksrt');
+ }
+ $metric_txt = function_exists('aksrt_format_number') ? aksrt_format_number($metric) : (string) $metric;
+ $tone = $top_tones[$index - 1] ?? 'b-gray';
+ $top_badge = '
+ +
++ +
sanitize_text_field((string) ($new_instance['title'] ?? '')), 'count' => max(1, min(20, (int) ($new_instance['count'] ?? 6))), - 'orderby' => $orderby, + 'orderby' => $orderby, + 'cat' => max(0, (int) ($new_instance['cat'] ?? 0)), + 'limit_day' => max(0, (int) ($new_instance['limit_day'] ?? 0)), 'paginate' => sanitize_key((string) ($new_instance['paginate'] ?? 'ajax')) === 'none' ? 'none' : 'ajax', ]; }