diff --git a/src/AKSRT/Widgets/WidgetForumPlateInfo.php b/src/AKSRT/Widgets/WidgetForumPlateInfo.php index 0a1a2957..f8f78952 100644 --- a/src/AKSRT/Widgets/WidgetForumPlateInfo.php +++ b/src/AKSRT/Widgets/WidgetForumPlateInfo.php @@ -54,11 +54,12 @@ class WidgetForumPlateInfo extends \WP_Widget { : home_url('/'); ob_start(); - echo '
暂无内容
'; + panel.innerHTML=html||'' . esc_html__('暂无排行数据', 'aksrt') . '
'; + echo '' . esc_html__('暂无排行数据', 'aksrt') . '
'; - echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - return; - } + $ph = get_template_directory_uri() . '/assets/img/placeholder.svg'; + $rank = 0; + foreach ($users as $user) { + $rank++; + $uid = (int) $user['id']; + $user_url = function_exists('aksrt_get_user_home_url') + ? aksrt_get_user_home_url($uid) + : get_author_posts_url($uid); - $top_badge = !empty($instance['top_badge']); + $top_bagd = ''; + if ($top_badge && $rank <= 3) { + $tone = $rank === 1 ? 'jb-red' : ($rank === 2 ? 'jb-yellow' : 'b-gray'); + $top_bagd = '+ + +
++ + +
++ + +
++ +
++ + +
++ +
++ +
+ user_registered)) { - $days = max(0, (int) floor((time() - strtotime($user->user_registered)) / DAY_IN_SECONDS)); - return sprintf(__('加入 %d 天', 'aksrt'), $days); - } - return ''; - case 'last_login': - $t = (string) get_user_meta($user_id, 'aksrt_last_login', true); - if ($t === '') { - $t = (string) get_user_meta($user_id, 'last_login', true); - } - return $t !== '' ? sprintf(__('最近登录 %s', 'aksrt'), $t) : ''; - case 'last_checkin': - $t = (string) get_user_meta($user_id, 'aksrt_last_checkin', true); - if ($t === '') { - $t = (string) get_user_meta($user_id, 'last_checkin', true); - } - return $t !== '' ? sprintf(__('最近签到 %s', 'aksrt'), $t) : ''; - case 'desc': - default: - $bio = get_user_meta($user_id, 'description', true); - if (!is_string($bio) || $bio === '') { - $bio = $user ? (string) $user->description : ''; - } - return $bio !== '' ? wp_trim_words($bio, 12) : ''; - } - } - - public function form($instance): void { - $title = !empty($instance['title']) ? $instance['title'] : __('排行榜', 'aksrt'); - $rank_by = !empty($instance['rank_by']) ? $instance['rank_by'] : 'credits'; - $count = !empty($instance['count']) ? (int) $instance['count'] : 5; - $show_avatar = !empty($instance['show_avatar']); - ?> -- - -
-- - -
-- - -
-- -
-- - -
-- -
-- -
-