From 8ad0558a3656c2f6ade9e11a4dc756bc16454cc3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jul 2026 14:36:01 +0800 Subject: [PATCH] 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. --- src/AKSRT/Widgets/CustomHtmlGapWidget.php | 4 +++- src/AKSRT/Widgets/WidgetPostsNavs.php | 7 +++++++ src/AKSRT/Widgets/WidgetProductList.php | 17 ++++++++++------- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/AKSRT/Widgets/CustomHtmlGapWidget.php b/src/AKSRT/Widgets/CustomHtmlGapWidget.php index 154493d9..55ab4486 100644 --- a/src/AKSRT/Widgets/CustomHtmlGapWidget.php +++ b/src/AKSRT/Widgets/CustomHtmlGapWidget.php @@ -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 '
' . esc_html__('自定义 HTML:', 'aksrt') . '' . esc_html__('请填写内容或切换为间距模式', 'aksrt') . '
'; + echo function_exists('aksrt_get_widget_null') + ? aksrt_get_widget_null(__('请填写 HTML 内容或切换为间距模式', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + : '
' . esc_html__('自定义 HTML:', 'aksrt') . '' . esc_html__('请填写内容或切换为间距模式', 'aksrt') . '
'; echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } return; diff --git a/src/AKSRT/Widgets/WidgetPostsNavs.php b/src/AKSRT/Widgets/WidgetPostsNavs.php index 3567c6e5..0c0dfc4c 100644 --- a/src/AKSRT/Widgets/WidgetPostsNavs.php +++ b/src/AKSRT/Widgets/WidgetPostsNavs.php @@ -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 + : '

' . esc_html__('目录树仅在详情页显示', 'aksrt') . '

'; + echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } return; } diff --git a/src/AKSRT/Widgets/WidgetProductList.php b/src/AKSRT/Widgets/WidgetProductList.php index b455b40e..3fbe06a4 100644 --- a/src/AKSRT/Widgets/WidgetProductList.php +++ b/src/AKSRT/Widgets/WidgetProductList.php @@ -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 '
'; } - if ($mini) { - // Compact row: thumb + title + price (zibll mini shop row lite). - echo '