From a770ff2591ea4c2a415aa2186f4401e571d87534 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jul 2026 12:16:57 +0800 Subject: [PATCH] feat(widgets): comments CPT, tag scale, oneline filters + CSS RecentComments uses aksrt_forum_topic/product + lazy avatars; TagCloud scale works; OnelinePosts topics/pay_type; batch34-36 residual CSS. --- assets/css/frontend/widget-batch5.css | 48 ++++++++++++++++++++++ src/AKSRT/Widgets/RecentCommentsWidget.php | 13 ++++-- src/AKSRT/Widgets/TagCloudWidget.php | 23 +++++++++-- src/AKSRT/Widgets/WidgetOnelinePosts.php | 41 ++++++++++++++++++ 4 files changed, 119 insertions(+), 6 deletions(-) diff --git a/assets/css/frontend/widget-batch5.css b/assets/css/frontend/widget-batch5.css index 530b4817..ddc37d63 100644 --- a/assets/css/frontend/widget-batch5.css +++ b/assets/css/frontend/widget-batch5.css @@ -2431,3 +2431,51 @@ a.main-color > .icon-cover-card:hover, /* batch31-33 residual */ .aksrt-fi__img.aksrt-lazy { width: 100%; height: 100%; object-fit: cover; display: block; position: absolute; inset: 0; } .aksrt-fi__video { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; } + + +/* batch34-36 residual */ +.widget-hot-posts--graphic .hot-posts-graphic { margin-bottom: 12px; border-radius: 8px; overflow: hidden; } +.widget-hot-posts--graphic .hot-posts-graphic .graphic { position: relative; overflow: hidden; border-radius: 8px; background: var(--surface-2, #f3f4f6); } +.widget-hot-posts--graphic .hot-posts-graphic img.fit-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; } +.widget-hot-posts--graphic .linear-mask { + position: absolute; inset: 0; + background: linear-gradient(to top, rgba(0,0,0,.62), transparent 55%); + pointer-events: none; +} +.widget-hot-posts--graphic .abs-center.left-bottom { position: absolute; left: 0; right: 0; bottom: 0; color: #fff; } +.widget-hot-posts--graphic .hot-posts-graphic__title { font-weight: 600; line-height: 1.35; } +.widget-hot-posts--graphic .hot-post-item { position: relative; align-items: flex-start; gap: 0; } +.widget-hot-posts--graphic .hot-post-item__thumb { + flex: 0 0 72px; width: 72px; height: 54px; border-radius: 8px; overflow: hidden; + position: relative; background: var(--surface-2, #f3f4f6); +} +.widget-hot-posts--graphic .hot-post-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; } +.widget-hot-posts--graphic badge.img-badge.left.hot { + position: absolute; top: 6px; left: 6px; z-index: 2; + padding: 2px 6px; border-radius: 4px; font-size: 11px; line-height: 1.2; color: #fff; +} +.widget-hot-posts--graphic badge.img-badge.jb-red { background: #f04438; } +.widget-hot-posts--graphic badge.img-badge.jb-yellow { background: #f79009; color: #111; } +.widget-hot-posts--graphic badge.img-badge.b-gray { background: #667085; } +.widget-hot-posts--graphic badge.img-badge.em12 { font-size: 12px; } +.pagenav.ajax-pag { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; margin-top: 12px; } +.pagenav.ajax-pag .page-numbers { + display: inline-flex; min-width: 32px; height: 32px; padding: 0 8px; + align-items: center; justify-content: center; border-radius: 8px; + background: var(--surface-2, #f3f4f6); color: inherit; text-decoration: none; font-size: 13px; +} +.pagenav.ajax-pag .page-numbers.current { background: var(--theme-color, #f04494); color: #fff; } +.pagenav.ajax-pag .page-numbers.dots { background: transparent; min-width: auto; } +.widget-tab-posts__skeleton .placeholder-row { + display: flex; gap: 10px; align-items: center; padding: 8px 0; +} +.widget-tab-posts__skeleton .thumb-placeholder { + width: 56px; height: 42px; border-radius: 6px; background: var(--surface-2, #eee); +} +.widget-tab-posts__skeleton .placeholder.k1, +.widget-tab-posts__skeleton .placeholder.s1 { + height: 12px; border-radius: 4px; background: var(--surface-2, #eee); +} +.widget-tab-posts__skeleton .placeholder.k1 { width: 80%; } +.widget-tab-posts__skeleton .placeholder.s1 { width: 48%; } +.posts-mini-lists.aksrt-main-posts { /* zibll mini outer */ } diff --git a/src/AKSRT/Widgets/RecentCommentsWidget.php b/src/AKSRT/Widgets/RecentCommentsWidget.php index 34a49134..b7c8dd05 100644 --- a/src/AKSRT/Widgets/RecentCommentsWidget.php +++ b/src/AKSRT/Widgets/RecentCommentsWidget.php @@ -56,10 +56,16 @@ class RecentCommentsWidget extends \WP_Widget { 'orderby' => 'comment_date_gmt', 'order' => 'DESC', ]; - // Include forum topics when forum is active. - if (post_type_exists('forum_topic') || post_type_exists('forum_post')) { + // Include forum topics / products when active. + if (post_type_exists('aksrt_forum_topic')) { + $query['post_type'][] = 'aksrt_forum_topic'; + } elseif (post_type_exists('forum_topic') || post_type_exists('forum_post')) { + // Legacy CPT names. $query['post_type'][] = post_type_exists('forum_topic') ? 'forum_topic' : 'forum_post'; } + if (post_type_exists('aksrt_product')) { + $query['post_type'][] = 'aksrt_product'; + } if ($post_not_in) { $query['post__not_in'] = $post_not_in; } @@ -126,7 +132,8 @@ class RecentCommentsWidget extends \WP_Widget { $avatar_url = $user_id > 0 && function_exists('aksrt_get_avatar_url') ? aksrt_get_avatar_url($user_id, ['size' => 42]) : get_avatar_url($comment, ['size' => 42]); - $avatar = '
'; + $ph = get_template_directory_uri() . '/assets/img/placeholder.svg'; + $avatar = '
'; } $like = function_exists('aksrt_get_comment_like_html') diff --git a/src/AKSRT/Widgets/TagCloudWidget.php b/src/AKSRT/Widgets/TagCloudWidget.php index 862a7341..07ce035c 100644 --- a/src/AKSRT/Widgets/TagCloudWidget.php +++ b/src/AKSRT/Widgets/TagCloudWidget.php @@ -52,7 +52,17 @@ class TagCloudWidget extends \WP_Widget { $palette = ['c-blue', 'c-yellow', 'c-green', 'c-purple', 'c-red', '', 'c-blue-2', 'c-yellow-2', 'c-green-2', 'c-purple-2', 'c-red-2', '']; $i = random_int(0, 10); - $wrap = 'tag-cloud aksrt-tag-cloud author-tag ajax-item' . ($fixed_width ? ' fixed-width' : ''); + $scale = !empty($instance['scale']); + $min_c = null; + $max_c = null; + if ($scale) { + foreach ($tags as $t0) { + $c0 = (int) $t0->count; + $min_c = $min_c === null ? $c0 : min($min_c, $c0); + $max_c = $max_c === null ? $c0 : max($max_c, $c0); + } + } + $wrap = 'zib-widget widget-tag-cloud tag-cloud aksrt-tag-cloud author-tag ajax-item' . ($fixed_width ? ' fixed-width' : ''); ob_start(); echo '
'; foreach ($tags as $tag) { @@ -71,8 +81,15 @@ class TagCloudWidget extends \WP_Widget { $cls .= ' ' . $color; } $tgt = $blank ? ' target="_blank" rel="noopener noreferrer"' : ''; - $count = $show_count ? ' (' . (int) $tag->count . ')' : ''; - echo '' . esc_html($tag->name) . $count . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + $count_html = $show_count ? ' (' . (int) $tag->count . ')' : ''; + $style_attr = ''; + if ($scale && $max_c !== null && $min_c !== null) { + $span = max(1, $max_c - $min_c); + $ratio = ((int) $tag->count - $min_c) / $span; + $em = round(0.85 + ($ratio * 0.4), 3); + $style_attr = ' style="font-size:' . esc_attr((string) $em) . 'em;--tag-scale:' . esc_attr((string) $em) . ';"'; + } + echo '' . esc_html($tag->name) . $count_html . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo '
'; return (string) ob_get_clean(); diff --git a/src/AKSRT/Widgets/WidgetOnelinePosts.php b/src/AKSRT/Widgets/WidgetOnelinePosts.php index e942f9bb..68a3f343 100644 --- a/src/AKSRT/Widgets/WidgetOnelinePosts.php +++ b/src/AKSRT/Widgets/WidgetOnelinePosts.php @@ -63,6 +63,30 @@ class WidgetOnelinePosts extends \WP_Widget { $query['orderby'] = 'date'; $query['order'] = 'DESC'; } + $topics_raw = trim((string) ($instance['topics'] ?? '')); + if ($topics_raw !== '' && taxonomy_exists('topics')) { + $topic_ids = array_values(array_filter(array_map('intval', preg_split('/[,,\s]+/', $topics_raw) ?: []))); + if ($topic_ids) { + $query['tax_query'] = [[ + 'taxonomy' => 'topics', + 'field' => 'term_id', + 'terms' => $topic_ids, + ]]; + } + } + $pay_type = sanitize_key((string) ($instance['pay_type'] ?? '')); + if ($pay_type !== '' && $pay_type !== '0' && $pay_type !== 'no') { + if ($pay_type === 'any' || $pay_type === 'paid') { + $query['meta_query'] = [ + 'relation' => 'OR', + ['key' => '_aksrt_pay_price', 'value' => 0, 'compare' => '>', 'type' => 'NUMERIC'], + ['key' => '_aksrt_pay_type', 'value' => ['reading', 'download', 'gallery', 'video', 'vip'], 'compare' => 'IN'], + ['key' => '_aksrt_visibility', 'value' => ['pay', 'credits'], 'compare' => 'IN'], + ]; + } else { + $query['meta_query'] = [['key' => '_aksrt_pay_type', 'value' => $pay_type]]; + } + } return $query; } @@ -212,6 +236,21 @@ class WidgetOnelinePosts extends \WP_Widget {

+

+ +

+

+ +

$orderby, 'cat' => max(0, (int) ($new_instance['cat'] ?? 0)), 'limit_day' => max(0, (int) ($new_instance['limit_day'] ?? 0)), + 'topics' => sanitize_text_field((string) ($new_instance['topics'] ?? '')), + 'pay_type' => sanitize_key((string) ($new_instance['pay_type'] ?? '')), ]; } }