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.
This commit is contained in:
@@ -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 */ }
|
||||
|
||||
@@ -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 = '<div class="avatar-img"><img class="avatar" src="' . esc_url($avatar_url) . '" alt="" width="36" height="36" loading="lazy" /></div>';
|
||||
$ph = get_template_directory_uri() . '/assets/img/placeholder.svg';
|
||||
$avatar = '<div class="avatar-img"><img class="avatar aksrt-lazy lazyload" data-src="' . esc_url($avatar_url) . '" src="' . esc_url($ph) . '" alt="" width="36" height="36" loading="lazy" /></div>';
|
||||
}
|
||||
|
||||
$like = function_exists('aksrt_get_comment_like_html')
|
||||
|
||||
@@ -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 '<div class="' . esc_attr($wrap) . '">';
|
||||
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 ? '<span class="em09 tag-count"> (' . (int) $tag->count . ')</span>' : '';
|
||||
echo '<a href="' . esc_url($url) . '" class="text-ellipsis ' . esc_attr(trim($cls)) . '"' . $tgt . '>' . esc_html($tag->name) . $count . '</a>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
$count_html = $show_count ? '<span class="em09 tag-count"> (' . (int) $tag->count . ')</span>' : '';
|
||||
$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 '<a href="' . esc_url($url) . '" class="text-ellipsis ' . esc_attr(trim($cls)) . '"' . $tgt . $style_attr . '>' . esc_html($tag->name) . $count_html . '</a>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
echo '</div>';
|
||||
return (string) ob_get_clean();
|
||||
|
||||
@@ -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 {
|
||||
<input class="tiny-text" type="number" min="0" name="<?php echo esc_attr($this->get_field_name('limit_day')); ?>" value="<?php echo esc_attr((string) ((int) ($instance['limit_day'] ?? 0))); ?>">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('专题 topics ID(逗号)', 'aksrt'); ?>
|
||||
<input class="widefat" type="text" name="<?php echo esc_attr($this->get_field_name('topics')); ?>" value="<?php echo esc_attr((string) ($instance['topics'] ?? '')); ?>">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('付费类型', 'aksrt'); ?>
|
||||
<select name="<?php echo esc_attr($this->get_field_name('pay_type')); ?>">
|
||||
<option value="" <?php selected(($instance['pay_type'] ?? ''), ''); ?>><?php esc_html_e('不限', 'aksrt'); ?></option>
|
||||
<option value="paid" <?php selected(($instance['pay_type'] ?? ''), 'paid'); ?>><?php esc_html_e('任意付费', 'aksrt'); ?></option>
|
||||
<option value="reading" <?php selected(($instance['pay_type'] ?? ''), 'reading'); ?>><?php esc_html_e('付费阅读', 'aksrt'); ?></option>
|
||||
<option value="download" <?php selected(($instance['pay_type'] ?? ''), 'download'); ?>><?php esc_html_e('付费下载', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -236,6 +275,8 @@ class WidgetOnelinePosts extends \WP_Widget {
|
||||
'orderby' => $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'] ?? '')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user