Merge pull request 'Worktree ux depth batch25 27' (#237) from worktree-ux-depth-batch25-27 into main
Reviewed-on: CYL/wordpress-theme-aksrt#237
This commit is contained in:
@@ -2379,3 +2379,38 @@ a.main-color > .icon-cover-card:hover,
|
||||
|
||||
.aksrt-ftag-list { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.aksrt-ftag-item.is-card { min-width: 120px; justify-content: space-between; }
|
||||
|
||||
|
||||
/* batch25-27 residual */
|
||||
.aksrt-forum-widget__list.is-mini .forum-posts.mini { border-bottom: 1px solid var(--color-line-soft, #f0f1f3); }
|
||||
.aksrt-forum-widget__list.is-mini .forum-posts.mini:last-child { border-bottom: 0; }
|
||||
.aksrt-forum-widget__rank-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid var(--color-line-soft, #f0f1f3);
|
||||
}
|
||||
.aksrt-forum-widget__rank-row:last-child { border-bottom: 0; }
|
||||
.aksrt-forum-widget__rank-row .forum-posts.mini {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.aksrt-forum-widget__rank {
|
||||
flex: 0 0 24px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin-top: 4px;
|
||||
border-radius: 6px;
|
||||
background: var(--surface-2, #f3f4f6);
|
||||
color: var(--muted-2-color, #999);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.aksrt-forum-widget__rank-row badge.img-badge { position: static; flex: 0 0 auto; margin-top: 4px; }
|
||||
.aksrt-stats__item[data-aksrt-animate] { will-change: transform, opacity; }
|
||||
|
||||
@@ -38,7 +38,7 @@ class CategoryTabsWidget extends \WP_Widget {
|
||||
$tabs = $this->resolve_tabs($instance);
|
||||
|
||||
echo $args['before_widget'];
|
||||
echo '<section class="aksrt-home-widget aksrt-home-widget--tabs widget-tab-posts" data-aksrt-home-cat-tabs>';
|
||||
echo '<section class="aksrt-home-widget aksrt-home-widget--tabs widget-tab-posts" data-aksrt-home-cat-tabs data-aksrt-tabs="1">';
|
||||
|
||||
if (empty($tabs)) {
|
||||
echo function_exists('aksrt_get_widget_null') ? aksrt_get_widget_null(__('暂无可用分类', 'aksrt')) : '<p class="widget-empty">' . esc_html__('暂无可用分类', 'aksrt') . '</p>';
|
||||
|
||||
@@ -20,7 +20,14 @@ class NoticeWidget extends \WP_Widget {
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
$items = $this->normalize_items($instance);
|
||||
if (!$items) {
|
||||
if (!$items) {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('请添加至少一条公告', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<p class="widget-empty">' . esc_html__('请添加至少一条公告', 'aksrt') . '</p>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,9 @@ class WidgetFaq extends \WP_Widget {
|
||||
if (!$faqs) {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="c-red muted-box mb20"><b>' . esc_html__('常见问题解答:', 'aksrt') . '</b>' .
|
||||
esc_html__('请添加至少一条问题', 'aksrt') . '</div>';
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('请添加至少一条问题', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<div class="c-red muted-box mb20"><b>' . esc_html__('常见问题解答:', 'aksrt') . '</b>' . esc_html__('请添加至少一条问题', 'aksrt') . '</div>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Forum hot / recent topic widgets with shared AJAX payload.
|
||||
* Forum hot topics with shared mini renderer + ajax pager.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -15,20 +15,26 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
parent::__construct(
|
||||
'aksrt_forum_hot_topics',
|
||||
__('论坛 - 热门话题', 'aksrt'),
|
||||
['description' => __('显示论坛热门话题列表。', 'aksrt')]
|
||||
[
|
||||
'description' => __('显示论坛热门话题列表(头像/身份/阅读)。', 'aksrt'),
|
||||
'classname' => 'widget_aksrt_forum_hot_topics',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public static function build_query_args(array $instance, int $paged = 1): array {
|
||||
$count = max(1, min(20, (int) ($instance['count'] ?? 5)));
|
||||
$period = sanitize_key((string) ($instance['period'] ?? 'week'));
|
||||
$count = max(1, min(20, (int) ($instance['count'] ?? 5)));
|
||||
$period = sanitize_key((string) ($instance['period'] ?? 'week'));
|
||||
$orderby = sanitize_key((string) ($instance['orderby'] ?? 'views'));
|
||||
$plate = max(0, (int) ($instance['plate'] ?? $instance['plate_id'] ?? 0));
|
||||
|
||||
$date_query = [];
|
||||
if ($period === 'week') {
|
||||
$date_query = [['after' => '7 days ago']];
|
||||
} elseif ($period === 'month') {
|
||||
$date_query = [['after' => '30 days ago']];
|
||||
}
|
||||
|
||||
$query = [
|
||||
'post_type' => 'aksrt_forum_topic',
|
||||
'posts_per_page' => $count,
|
||||
@@ -36,38 +42,80 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
'post_status' => 'publish',
|
||||
'date_query' => $date_query,
|
||||
];
|
||||
|
||||
if ($orderby === 'comments') {
|
||||
$query['orderby'] = 'comment_count';
|
||||
$query['order'] = 'DESC';
|
||||
$query['order'] = 'DESC';
|
||||
} elseif ($orderby === 'date') {
|
||||
$query['orderby'] = 'date';
|
||||
$query['order'] = 'DESC';
|
||||
$query['order'] = 'DESC';
|
||||
} elseif ($orderby === 'essence') {
|
||||
$query['meta_query'] = [[
|
||||
'key' => '_aksrt_essence',
|
||||
'value' => '1',
|
||||
]];
|
||||
$query['orderby'] = 'date';
|
||||
$query['order'] = 'DESC';
|
||||
} else {
|
||||
$query['meta_key'] = '_aksrt_views';
|
||||
$query['orderby'] = 'meta_value_num';
|
||||
$query['order'] = 'DESC';
|
||||
$query['orderby'] = 'meta_value_num';
|
||||
$query['order'] = 'DESC';
|
||||
}
|
||||
|
||||
if ($plate > 0) {
|
||||
$mq = isset($query['meta_query']) ? $query['meta_query'] : [];
|
||||
$mq[] = [
|
||||
'key' => '_aksrt_plate_id',
|
||||
'value' => $plate,
|
||||
];
|
||||
$query['meta_query'] = array_values($mq);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
public static function render_items_html(\WP_Query $query, int $start = 0): string {
|
||||
public static function render_items_html(\WP_Query $query, int $start = 0, string $style = 'mini'): string {
|
||||
if (!$query->have_posts()) {
|
||||
return '';
|
||||
}
|
||||
$style = $style === 'rank' ? 'rank' : 'mini';
|
||||
ob_start();
|
||||
if ($style === 'rank') {
|
||||
echo '<div class="forum-posts-lists aksrt-forum-widget__list is-rank">';
|
||||
} else {
|
||||
echo '<div class="forum-posts-lists aksrt-forum-widget__list is-mini">';
|
||||
}
|
||||
$i = $start;
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
$i++;
|
||||
$views = (int) get_post_meta(get_the_ID(), '_aksrt_views', true);
|
||||
echo '<li class="aksrt-forum-widget__item ajax-item">';
|
||||
echo '<span class="aksrt-forum-widget__rank">' . esc_html((string) $i) . '</span>';
|
||||
echo '<a href="' . esc_url(get_permalink()) . '" class="aksrt-forum-widget__link">';
|
||||
echo esc_html(get_the_title());
|
||||
echo '</a>';
|
||||
echo '<span class="aksrt-forum-widget__views"><i class="fas fa-eye"></i> ' . esc_html((string) $views) . '</span>';
|
||||
echo '</li>';
|
||||
if ($style === 'rank') {
|
||||
$tone = $i === 1 ? 'jb-red' : ($i === 2 ? 'jb-yellow' : ($i === 3 ? 'b-gray' : ''));
|
||||
echo '<div class="aksrt-forum-widget__rank-row relative ajax-item">';
|
||||
if ($i <= 3 && $tone !== '') {
|
||||
echo '<badge class="img-badge left hot ' . esc_attr($tone) . '"><i>TOP' . (int) $i . '</i></badge>';
|
||||
} else {
|
||||
echo '<span class="aksrt-forum-widget__rank">' . esc_html((string) $i) . '</span>';
|
||||
}
|
||||
if (function_exists('aksrt_render_forum_topic_mini')) {
|
||||
echo aksrt_render_forum_topic_mini(null, 'ajax-item is-rank-item', true); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
$views = (int) get_post_meta(get_the_ID(), '_aksrt_views', true);
|
||||
echo '<a href="' . esc_url(get_permalink()) . '" class="aksrt-forum-widget__link">' . esc_html(get_the_title()) . '</a>';
|
||||
echo '<span class="aksrt-forum-widget__views"><i class="fa fa-eye" aria-hidden="true"></i> ' . esc_html((string) $views) . '</span>';
|
||||
}
|
||||
echo '</div>';
|
||||
} elseif (function_exists('aksrt_render_forum_topic_mini')) {
|
||||
echo aksrt_render_forum_topic_mini(null, 'ajax-item', true); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
} else {
|
||||
$views = (int) get_post_meta(get_the_ID(), '_aksrt_views', true);
|
||||
echo '<div class="aksrt-forum-widget__item ajax-item">';
|
||||
echo '<a href="' . esc_url(get_permalink()) . '" class="aksrt-forum-widget__link">' . esc_html(get_the_title()) . '</a>';
|
||||
echo '<span class="aksrt-forum-widget__views"><i class="fa fa-eye" aria-hidden="true"></i> ' . esc_html((string) $views) . '</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
wp_reset_postdata();
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
@@ -76,18 +124,23 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
* @return array{html:string,paginate_html:string,has_more:bool,page:int,max_pages:int,total:int}
|
||||
*/
|
||||
public static function query_payload(array $instance, int $page = 1): array {
|
||||
$page = max(1, $page);
|
||||
$count = max(1, min(20, (int) ($instance['count'] ?? 5)));
|
||||
$page = max(1, $page);
|
||||
$count = max(1, min(20, (int) ($instance['count'] ?? 5)));
|
||||
$paginate = sanitize_key((string) ($instance['paginate'] ?? 'ajax'));
|
||||
$q = new \WP_Query(self::build_query_args($instance, $page));
|
||||
$items = self::render_items_html($q, ($page - 1) * $count);
|
||||
$html = $items !== '' ? '<ul class="aksrt-forum-widget__list">' . $items . '</ul>' : '';
|
||||
$style = sanitize_key((string) ($instance['style'] ?? 'mini'));
|
||||
if (!in_array($style, ['mini', 'rank'], true)) {
|
||||
$style = 'mini';
|
||||
}
|
||||
$q = new \WP_Query(self::build_query_args($instance, $page));
|
||||
$html = self::render_items_html($q, ($page - 1) * $count, $style);
|
||||
if ($html === '' && $page === 1) {
|
||||
$html = function_exists('aksrt_get_ajax_null') ? aksrt_get_ajax_null(__('暂无话题', 'aksrt')) : '<p class="aksrt-forum-widget__empty ajax-item">' . esc_html__('暂无话题', 'aksrt') . '</p>';
|
||||
$html = function_exists('aksrt_get_ajax_null')
|
||||
? aksrt_get_ajax_null(__('暂无话题', 'aksrt'))
|
||||
: '<p class="aksrt-forum-widget__empty ajax-item">' . esc_html__('暂无话题', 'aksrt') . '</p>';
|
||||
}
|
||||
$max_pages = max(1, (int) $q->max_num_pages);
|
||||
$total = (int) $q->found_posts;
|
||||
$has_more = $page < $max_pages;
|
||||
$total = (int) $q->found_posts;
|
||||
$has_more = $page < $max_pages;
|
||||
$paginate_html = '';
|
||||
if ($paginate === 'ajax' && $has_more) {
|
||||
$next = add_query_arg([
|
||||
@@ -95,6 +148,8 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
'count' => $count,
|
||||
'period' => sanitize_key((string) ($instance['period'] ?? 'week')),
|
||||
'orderby' => sanitize_key((string) ($instance['orderby'] ?? 'views')),
|
||||
'style' => $style,
|
||||
'plate' => max(0, (int) ($instance['plate'] ?? 0)),
|
||||
'paginate' => 'ajax',
|
||||
], rest_url('aksrt/v1/widgets/forum-topics'));
|
||||
$paginate_html = function_exists('aksrt_get_ajax_next_paginate')
|
||||
@@ -107,6 +162,9 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
}
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
if (!post_type_exists('aksrt_forum_topic')) {
|
||||
return;
|
||||
}
|
||||
$title = !empty($instance['title']) ? $instance['title'] : __('热门话题', 'aksrt');
|
||||
$instance['paginate'] = sanitize_key((string) ($instance['paginate'] ?? 'ajax'));
|
||||
$payload = self::query_payload($instance, 1);
|
||||
@@ -126,6 +184,9 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
$title = !empty($instance['title']) ? $instance['title'] : __('热门话题', 'aksrt');
|
||||
$count = !empty($instance['count']) ? (int) $instance['count'] : 5;
|
||||
$period = !empty($instance['period']) ? $instance['period'] : 'week';
|
||||
$orderby = !empty($instance['orderby']) ? $instance['orderby'] : 'views';
|
||||
$style = !empty($instance['style']) ? $instance['style'] : 'mini';
|
||||
$plate = (int) ($instance['plate'] ?? 0);
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('标题:', 'aksrt'); ?></label>
|
||||
@@ -143,6 +204,29 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
<option value="month" <?php selected($period, 'month'); ?>><?php esc_html_e('最近一月', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('排序', 'aksrt'); ?>
|
||||
<select name="<?php echo esc_attr($this->get_field_name('orderby')); ?>">
|
||||
<option value="views" <?php selected($orderby, 'views'); ?>><?php esc_html_e('热门浏览', 'aksrt'); ?></option>
|
||||
<option value="comments" <?php selected($orderby, 'comments'); ?>><?php esc_html_e('评论数', 'aksrt'); ?></option>
|
||||
<option value="date" <?php selected($orderby, 'date'); ?>><?php esc_html_e('最新', 'aksrt'); ?></option>
|
||||
<option value="essence" <?php selected($orderby, 'essence'); ?>><?php esc_html_e('精华', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('样式', 'aksrt'); ?>
|
||||
<select name="<?php echo esc_attr($this->get_field_name('style')); ?>">
|
||||
<option value="mini" <?php selected($style, 'mini'); ?>><?php esc_html_e('迷你信息行', 'aksrt'); ?></option>
|
||||
<option value="rank" <?php selected($style, 'rank'); ?>><?php esc_html_e('排行榜', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('版块 ID(可选)', 'aksrt'); ?>
|
||||
<input class="tiny-text" type="number" min="0" name="<?php echo esc_attr($this->get_field_name('plate')); ?>" value="<?php echo esc_attr((string) $plate); ?>">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('分页', 'aksrt'); ?>
|
||||
<select name="<?php echo esc_attr($this->get_field_name('paginate')); ?>">
|
||||
@@ -155,10 +239,21 @@ class WidgetForumHotTopics extends \WP_Widget {
|
||||
}
|
||||
|
||||
public function update($new_instance, $old_instance): array {
|
||||
$orderby = sanitize_key((string) ($new_instance['orderby'] ?? 'views'));
|
||||
if (!in_array($orderby, ['views', 'comments', 'date', 'essence'], true)) {
|
||||
$orderby = 'views';
|
||||
}
|
||||
$style = sanitize_key((string) ($new_instance['style'] ?? 'mini'));
|
||||
if (!in_array($style, ['mini', 'rank'], true)) {
|
||||
$style = 'mini';
|
||||
}
|
||||
return [
|
||||
'title' => sanitize_text_field($new_instance['title'] ?? ''),
|
||||
'count' => max(1, min(20, (int) ($new_instance['count'] ?? 5))),
|
||||
'period' => in_array($new_instance['period'] ?? '', ['all', 'week', 'month'], true) ? $new_instance['period'] : 'week',
|
||||
'orderby' => $orderby,
|
||||
'style' => $style,
|
||||
'plate' => max(0, (int) ($new_instance['plate'] ?? 0)),
|
||||
'paginate' => sanitize_key((string) ($new_instance['paginate'] ?? 'ajax')) === 'none' ? 'none' : 'ajax',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -15,15 +15,26 @@ class WidgetForumRecentTopics extends \WP_Widget {
|
||||
parent::__construct(
|
||||
'aksrt_forum_recent_topics',
|
||||
__('论坛 - 最新话题', 'aksrt'),
|
||||
['description' => __('显示论坛最新话题列表。', 'aksrt')]
|
||||
[
|
||||
'description' => __('显示论坛最新话题列表(共享迷你行渲染)。', 'aksrt'),
|
||||
'classname' => 'widget_aksrt_forum_recent_topics',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
if (!post_type_exists('aksrt_forum_topic')) {
|
||||
return;
|
||||
}
|
||||
$title = !empty($instance['title']) ? $instance['title'] : __('最新话题', 'aksrt');
|
||||
$instance['orderby'] = 'date';
|
||||
$instance['period'] = 'all';
|
||||
$instance['orderby'] = 'date';
|
||||
$instance['period'] = 'all';
|
||||
$instance['style'] = sanitize_key((string) ($instance['style'] ?? 'mini'));
|
||||
if (!in_array($instance['style'], ['mini', 'rank'], true)) {
|
||||
$instance['style'] = 'mini';
|
||||
}
|
||||
$instance['paginate'] = sanitize_key((string) ($instance['paginate'] ?? 'ajax'));
|
||||
$instance['plate'] = max(0, (int) ($instance['plate'] ?? 0));
|
||||
$payload = WidgetForumHotTopics::query_payload($instance, 1);
|
||||
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
@@ -40,7 +51,8 @@ class WidgetForumRecentTopics extends \WP_Widget {
|
||||
public function form($instance): void {
|
||||
$title = !empty($instance['title']) ? $instance['title'] : __('最新话题', 'aksrt');
|
||||
$count = !empty($instance['count']) ? (int) $instance['count'] : 5;
|
||||
$plate = (int) ($instance['plate'] ?? 0);
|
||||
$plate = (int) ($instance['plate'] ?? 0);
|
||||
$style = !empty($instance['style']) ? $instance['style'] : 'mini';
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('标题:', 'aksrt'); ?></label>
|
||||
@@ -50,6 +62,19 @@ class WidgetForumRecentTopics extends \WP_Widget {
|
||||
<label for="<?php echo esc_attr($this->get_field_id('count')); ?>"><?php esc_html_e('数量:', 'aksrt'); ?></label>
|
||||
<input class="tiny-text" id="<?php echo esc_attr($this->get_field_id('count')); ?>" name="<?php echo esc_attr($this->get_field_name('count')); ?>" type="number" value="<?php echo esc_attr((string) $count); ?>" min="1" max="20">
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('版块 ID(可选)', 'aksrt'); ?>
|
||||
<input class="tiny-text" type="number" min="0" name="<?php echo esc_attr($this->get_field_name('plate')); ?>" value="<?php echo esc_attr((string) $plate); ?>">
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('样式', 'aksrt'); ?>
|
||||
<select name="<?php echo esc_attr($this->get_field_name('style')); ?>">
|
||||
<option value="mini" <?php selected($style, 'mini'); ?>><?php esc_html_e('迷你信息行', 'aksrt'); ?></option>
|
||||
<option value="rank" <?php selected($style, 'rank'); ?>><?php esc_html_e('排行榜', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label><?php esc_html_e('分页', 'aksrt'); ?>
|
||||
<select name="<?php echo esc_attr($this->get_field_name('paginate')); ?>">
|
||||
@@ -62,9 +87,15 @@ class WidgetForumRecentTopics extends \WP_Widget {
|
||||
}
|
||||
|
||||
public function update($new_instance, $old_instance): array {
|
||||
$style = sanitize_key((string) ($new_instance['style'] ?? 'mini'));
|
||||
if (!in_array($style, ['mini', 'rank'], true)) {
|
||||
$style = 'mini';
|
||||
}
|
||||
return [
|
||||
'title' => sanitize_text_field($new_instance['title'] ?? ''),
|
||||
'count' => max(1, min(20, (int) ($new_instance['count'] ?? 5))),
|
||||
'plate' => max(0, (int) ($new_instance['plate'] ?? 0)),
|
||||
'style' => $style,
|
||||
'paginate' => sanitize_key((string) ($new_instance['paginate'] ?? 'ajax')) === 'none' ? 'none' : 'ajax',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -110,13 +110,14 @@ class WidgetProductList extends \WP_Widget {
|
||||
'show_sales' => true,
|
||||
]);
|
||||
} else {
|
||||
// Fallback mini card.
|
||||
// Fallback mini card (lazy thumbs).
|
||||
$price = (float) ($card['price'] ?? 0);
|
||||
$image = (string) ($card['image'] ?? '');
|
||||
$ph = get_template_directory_uri() . '/assets/img/placeholder.svg';
|
||||
echo '<div class="aksrt-product-widget__item ajax-item">';
|
||||
if ($image !== '') {
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="aksrt-product-widget__thumb">';
|
||||
echo '<img src="' . esc_url($image) . '" alt="' . esc_attr(get_the_title($pid)) . '" loading="lazy">';
|
||||
echo '<img class="aksrt-lazy lazyload" data-src="' . esc_url($image) . '" src="' . esc_url($ph) . '" alt="' . esc_attr(get_the_title($pid)) . '" loading="lazy">';
|
||||
echo '</a>';
|
||||
}
|
||||
echo '<div class="aksrt-product-widget__info">';
|
||||
|
||||
@@ -27,8 +27,9 @@ class WidgetSlider extends \WP_Widget {
|
||||
if (!$slides) {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="c-red muted-box mb20"><b>' . esc_html__('幻灯片模块:', 'aksrt') . '</b>' .
|
||||
esc_html__('当前配置下没有可显示的内容,请正确配置或移出该模块', 'aksrt') . '</div>';
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('当前配置下没有可显示的内容', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<div class="c-red muted-box mb20"><b>' . esc_html__('幻灯片模块:', 'aksrt') . '</b>' . esc_html__('当前配置下没有可显示的内容,请正确配置或移出该模块', 'aksrt') . '</div>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -24,7 +24,14 @@ class WidgetStats extends \WP_Widget {
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
$stats = $this->normalize_stats($instance['stats'] ?? []);
|
||||
if (!$stats) {
|
||||
if (!$stats) {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('请配置至少一项统计数据', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<p class="widget-empty">' . esc_html__('请配置至少一项统计数据', 'aksrt') . '</p>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
}
|
||||
$cols = max(1, min(4, (int) ($instance['columns'] ?? 4)));
|
||||
@@ -59,7 +66,7 @@ class WidgetStats extends \WP_Widget {
|
||||
$color = $palette[$i % count($palette)];
|
||||
}
|
||||
$i++;
|
||||
echo '<div class="aksrt-stats__item color-' . esc_attr($color) . '">';
|
||||
echo '<div class="aksrt-stats__item color-' . esc_attr($color) . '" data-aksrt-animate="fade-up">';
|
||||
if ($s['icon'] !== '') {
|
||||
echo '<div class="aksrt-stats__icon"><i class="' . esc_attr($s['icon']) . '" aria-hidden="true"></i></div>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user