feat(widgets): product list vs mini DOM + admin empty polish
Differentiate product list/mini row sizes; custom HTML and posts-navs admin empty states via aksrt_get_widget_null.
This commit is contained in:
@@ -38,7 +38,9 @@ class CustomHtmlGapWidget extends \WP_Widget {
|
||||
if (trim(wp_strip_all_tags($content)) === '' && trim($content) === '') {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="c-red muted-box mb10"><b>' . esc_html__('自定义 HTML:', 'aksrt') . '</b>' . esc_html__('请填写内容或切换为间距模式', 'aksrt') . '</div>';
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('请填写 HTML 内容或切换为间距模式', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<div class="c-red muted-box mb10"><b>' . esc_html__('自定义 HTML:', 'aksrt') . '</b>' . esc_html__('请填写内容或切换为间距模式', 'aksrt') . '</div>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -27,6 +27,13 @@ class WidgetPostsNavs extends \WP_Widget {
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
if (!is_singular(['post', 'page', 'aksrt_forum_topic', 'aksrt_product'])) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ class WidgetProductList extends \WP_Widget {
|
||||
return '';
|
||||
}
|
||||
$oneline = $style === 'oneline';
|
||||
$mini = $style === 'mini' || $style === 'list';
|
||||
$mini = $style === 'mini';
|
||||
$list = $style === 'list';
|
||||
ob_start();
|
||||
while ($products->have_posts()) {
|
||||
$products->the_post();
|
||||
@@ -108,16 +109,18 @@ class WidgetProductList extends \WP_Widget {
|
||||
if ($oneline) {
|
||||
echo '<div class="swiper-slide ajax-item">';
|
||||
}
|
||||
if ($mini) {
|
||||
// Compact row: thumb + title + price (zibll mini shop row lite).
|
||||
echo '<div class="aksrt-product-widget__item aksrt-product-widget__item--mini ajax-item flex ac">';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="aksrt-product-widget__thumb mini">';
|
||||
if ($mini || $list) {
|
||||
$row_cls = $list ? 'aksrt-product-widget__item aksrt-product-widget__item--list ajax-item flex ac' : 'aksrt-product-widget__item aksrt-product-widget__item--mini ajax-item flex ac';
|
||||
$thumb_cls = $list ? 'aksrt-product-widget__thumb list' : 'aksrt-product-widget__thumb mini';
|
||||
$wh = $list ? 80 : 56;
|
||||
echo '<div class="' . esc_attr($row_cls) . '">';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="' . esc_attr($thumb_cls) . '">';
|
||||
if ($image !== '') {
|
||||
echo '<img class="aksrt-lazy lazyload fit-cover" data-src="' . esc_url($image) . '" src="' . esc_url($ph) . '" alt="' . esc_attr(get_the_title($pid)) . '" loading="lazy" width="56" height="56">';
|
||||
echo '<img class="aksrt-lazy lazyload fit-cover" data-src="' . esc_url($image) . '" src="' . esc_url($ph) . '" alt="' . esc_attr(get_the_title($pid)) . '" loading="lazy" width="' . (int) $wh . '" height="' . (int) $wh . '">';
|
||||
}
|
||||
echo '</a>';
|
||||
echo '<div class="aksrt-product-widget__info flex1 min-w0">';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="aksrt-product-widget__title text-ellipsis">' . esc_html(get_the_title($pid)) . '</a>';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="aksrt-product-widget__title' . ($mini ? ' text-ellipsis' : ' text-ellipsis-2') . '">' . esc_html(get_the_title($pid)) . '</a>';
|
||||
echo '<div class="aksrt-product-widget__meta flex jsb ac">';
|
||||
echo '<span class="aksrt-product-widget__price c-red">¥' . esc_html(number_format_i18n($price, 2)) . '</span>';
|
||||
if (!empty($card['sales'])) {
|
||||
|
||||
Reference in New Issue
Block a user