From f529e88862e7f30c98a1253f02e3f63b36c89e27 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Jul 2026 09:46:17 +0800 Subject: [PATCH] feat(widgets): announcement swiper, layout gap, partners/about polish Announcement defaults to vertical new-swiper; gap supports PC/mobile heights; partners lazy+empty admin; about card uses identity name/bio. --- assets/css/frontend/widget-batch5.css | 208 ++++++++++++++++++ src/AKSRT/Widgets/AboutWidget.php | 4 +- src/AKSRT/Widgets/CustomHtmlGapWidget.php | 141 ++++++++----- src/AKSRT/Widgets/WidgetAnnouncement.php | 235 +++++++++++++-------- src/AKSRT/Widgets/WidgetPartnersScroll.php | 9 +- 5 files changed, 455 insertions(+), 142 deletions(-) diff --git a/assets/css/frontend/widget-batch5.css b/assets/css/frontend/widget-batch5.css index 45c11701..fcf64247 100644 --- a/assets/css/frontend/widget-batch5.css +++ b/assets/css/frontend/widget-batch5.css @@ -2009,3 +2009,211 @@ a.main-color > .icon-cover-card:hover, .widget_aksrt_icon_cards .col-xs-3, .widget_aksrt_icon_cover_cards .col-xs-3 { width: 25%; } } + +/* ===== Batch16-18: highlights/combo/reviews/announcement/gap/pricing polish ===== */ + +.aksrt-highlights__row { + display: grid; + gap: 12px; + margin-bottom: 12px; +} +.aksrt-highlights__row.is-large { grid-template-columns: 1fr; } +.aksrt-highlights__row.is-medium { grid-template-columns: repeat(2, minmax(0, 1fr)); } +.aksrt-highlights__row.is-small { grid-template-columns: repeat(3, minmax(0, 1fr)); } +@media (max-width: 767px) { + .aksrt-highlights__row.is-medium, + .aksrt-highlights__row.is-small { grid-template-columns: 1fr; } +} +.aksrt-hl-card { + display: block; + position: relative; + overflow: hidden; + border-radius: 12px; + text-decoration: none; + color: inherit; + background: var(--surface-1, #fff); + border: 1px solid var(--color-line, #e5e7eb); + min-height: 120px; + transition: transform .25s ease, box-shadow .25s ease; +} +.aksrt-hl-card:hover { + transform: translateY(-2px); + box-shadow: 0 10px 24px rgba(0,0,0,.06); +} +.aksrt-hl-card__media { + position: absolute; + inset: 0; + z-index: 0; +} +.aksrt-hl-card__media img { + width: 100%; + height: 100%; + object-fit: cover; +} +.aksrt-hl-card__body { + position: relative; + z-index: 1; + padding: 16px; +} +.aksrt-hl-card.color-blue { --hl: #3b82f6; } +.aksrt-hl-card.color-pink { --hl: #ec4899; } +.aksrt-hl-card.color-purple { --hl: #a855f7; } +.aksrt-hl-card.color-green { --hl: #22c55e; } +.aksrt-hl-card.color-orange { --hl: #f97316; } +.aksrt-hl-card.color-cyan { --hl: #06b6d4; } +.aksrt-hl-card__icon { + width: 36px; + height: 36px; + border-radius: 10px; + display: inline-flex; + align-items: center; + justify-content: center; + background: color-mix(in srgb, var(--hl, #3b82f6) 16%, transparent); + color: var(--hl, #3b82f6); + margin-bottom: 8px; +} +.aksrt-hl-card__title { font-weight: 700; font-size: 16px; } +.aksrt-hl-card__desc { margin-top: 6px; font-size: 13px; color: var(--muted-2-color, #888); } + +/* Combo row gutters */ +.aksrt-combo-info.row.gutters-10 { + display: flex; + flex-wrap: wrap; + margin: 0 -5px; +} +.aksrt-combo-info.row.gutters-10 > [class*="col-"] { + padding: 0 5px 10px; + box-sizing: border-box; +} +.aksrt-combo-info .col-sm-12 { width: 100%; } +.aksrt-combo-info .col-sm-6 { width: 50%; } +.aksrt-combo-info .col-sm-4 { width: 33.333%; } +.aksrt-combo-info .col-sm-3 { width: 25%; } +.aksrt-combo-info .col-sm-2 { width: 16.666%; } +@media (max-width: 767px) { + .aksrt-combo-info .col-xs-12 { width: 100%; } + .aksrt-combo-info .col-xs-6 { width: 50%; } + .aksrt-combo-info .col-xs-4 { width: 33.333%; } +} + +/* Reviews swiper */ +.aksrt-reviews-swiper { + position: relative; + overflow: hidden; + padding: 0 28px 4px; +} +.aksrt-reviews-swiper .swiper-slide { + width: calc(100% / var(--aksrt-rev-pc, 3)); + max-width: 360px; + height: auto; + padding-right: 12px; + box-sizing: border-box; +} +@media (max-width: 767px) { + .aksrt-reviews-swiper .swiper-slide { + width: calc(100% / var(--aksrt-rev-m, 1.2)); + } +} +.aksrt-reviews__card { + height: 100%; + border-radius: 12px; + border: 1px solid var(--color-line, #e5e7eb); + background: var(--surface-1, #fff); + padding: 16px; + position: relative; +} +.aksrt-reviews__head { + display: flex; + align-items: center; + gap: 10px; + margin-bottom: 8px; +} +.aksrt-reviews__avatar { + width: 44px; + height: 44px; + border-radius: 50%; + object-fit: cover; + display: block; + background: var(--surface-2, #eee); +} +.aksrt-reviews__avatar.is-placeholder { + display: inline-flex; + align-items: center; + justify-content: center; + color: #999; +} +.aksrt-reviews__name { font-weight: 700; } +.aksrt-reviews__role { font-size: 12px; color: var(--muted-2-color, #888); } +.aksrt-reviews__stars .fa-star.is-on { color: #f5b301; } +.aksrt-reviews__stars .fa-star.is-off { color: #ddd; } +.aksrt-reviews__content { margin: 10px 0 0; font-size: 13px; line-height: 1.6; color: var(--muted-color, #555); } +.aksrt-reviews__quote { + position: absolute; + right: 12px; + bottom: 10px; + opacity: .12; + font-size: 28px; +} +.aksrt-reviews-swiper .swiper-button-prev, +.aksrt-reviews-swiper .swiper-button-next { + width: 28px; + height: 28px; + margin-top: 0; + top: 42%; + border-radius: 50%; + background: var(--surface-1, #fff); + border: 1px solid var(--color-line, #e5e7eb); + color: var(--color-ink, #111); +} +.aksrt-reviews-swiper .swiper-button-prev:after, +.aksrt-reviews-swiper .swiper-button-next:after { font-size: 12px; font-weight: 700; } +.aksrt-reviews-swiper .swiper-button-prev { left: 0; } +.aksrt-reviews-swiper .swiper-button-next { right: 0; } + +/* Announcement vertical swiper reuse notice styles */ +.aksrt-announcement-swiper-wrap { + display: flex; + align-items: center; + gap: 10px; + padding: 10px 12px; + border-radius: 8px; + background: var(--surface-1, #fff); + border: 1px solid var(--color-line, #e5e7eb); +} +.aksrt-announcement-swiper-wrap .aksrt-notice-swiper, +.aksrt-announcement-swiper { + flex: 1; + min-width: 0; + height: 28px; + overflow: hidden; +} +.aksrt-announcement-swiper .notice-slide, +.aksrt-announcement-swiper .swiper-slide { + height: 28px; + line-height: 28px; +} +.aksrt-announcement-swiper .text-ellipsis { + display: block; + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + color: inherit; + text-decoration: none; +} + +/* Layout gap responsive */ +.aksrt-layout-gap { + width: 100%; + pointer-events: none; +} +@media (max-width: 767px) { + .aksrt-layout-gap { + height: var(--aksrt-gap-m, 20px) !important; + } +} +.widget-custom-html.is-full { + margin-left: calc(50% - 50vw); + margin-right: calc(50% - 50vw); + width: 100vw; + max-width: 100vw; +} diff --git a/src/AKSRT/Widgets/AboutWidget.php b/src/AKSRT/Widgets/AboutWidget.php index a1aba833..953b3913 100644 --- a/src/AKSRT/Widgets/AboutWidget.php +++ b/src/AKSRT/Widgets/AboutWidget.php @@ -70,8 +70,8 @@ class AboutWidget extends \WP_Widget {
-
display_name); ?>
-
user_email); ?>
+
(int) $u->ID, 'class' => 'flex ac', 'follow' => false, 'medal' => true, 'auth' => true, 'level' => true]); } else { echo esc_html($u->display_name); } ?>
+
ID, 'description', true)); echo esc_html($bio !== '' ? $bio : $u->user_email); ?>
diff --git a/src/AKSRT/Widgets/CustomHtmlGapWidget.php b/src/AKSRT/Widgets/CustomHtmlGapWidget.php index 6a02ef61..154493d9 100644 --- a/src/AKSRT/Widgets/CustomHtmlGapWidget.php +++ b/src/AKSRT/Widgets/CustomHtmlGapWidget.php @@ -1,5 +1,7 @@ esc_html__('插入自定义 HTML 或间距', 'aksrt'), - ]); - } + public function __construct() { + parent::__construct('aksrt_custom_html_gap', esc_html__('AKSRT 自定义HTML/间距', 'aksrt'), [ + 'description' => esc_html__('插入自定义 HTML 或布局间距(PC/移动可分设)。', 'aksrt'), + 'classname' => 'widget_aksrt_custom_html_gap', + ]); + } - public function widget($args, $instance): void { - $mode = sanitize_key($instance['mode'] ?? 'html'); + /** + * @param array $args + * @param array $instance + */ + public function widget($args, $instance): void { + $mode = sanitize_key((string) ($instance['mode'] ?? 'html')); - if ($mode === 'gap') { - $height = max(0, min(500, (int) ($instance['gap_height'] ?? 20))); - echo ''; - return; - } + if ($mode === 'gap') { + $pc = max(0, min(500, (int) ($instance['gap_height'] ?? 20))); + $m = max(0, min(500, (int) ($instance['gap_height_m'] ?? $pc))); + // zibll layout gap: empty spacing block without widget chrome. + $style = sprintf('--aksrt-gap-pc:%dpx;--aksrt-gap-m:%dpx;height:%dpx;', $pc, $m, $pc); + echo ''; + return; + } - echo $args['before_widget']; - $title = apply_filters('widget_title', $instance['title'] ?? '', $instance, $this->id_base); - if ($title) echo $args['before_title'] . esc_html($title) . $args['after_title']; - echo '
' . wp_kses_post($instance['content'] ?? '') . '
'; - echo $args['after_widget']; - } + $content = (string) ($instance['content'] ?? ''); + 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 $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } + return; + } - public function form($instance): void { - $mode = sanitize_key($instance['mode'] ?? 'html'); - ?> -

- - -

-

- - -

-

- - -

-

- - -

- id_base); + if ($title !== '') { + echo $args['before_title'] . esc_html($title) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } + $full_width = !empty($instance['full_width']); + $cls = 'widget-custom-html' . ($full_width ? ' is-full' : ''); + echo '
' . wp_kses_post($content) . '
'; + echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } - public function update($new_instance, $old_instance): array { - return [ - 'mode' => in_array($new_instance['mode'] ?? '', ['html', 'gap'], true) ? $new_instance['mode'] : 'html', - 'title' => sanitize_text_field($new_instance['title'] ?? ''), - 'content' => wp_kses_post($new_instance['content'] ?? ''), - 'gap_height' => max(0, min(500, (int) ($new_instance['gap_height'] ?? 20))), - ]; - } + /** + * @param array $instance + */ + public function form($instance): void { + $mode = sanitize_key((string) ($instance['mode'] ?? 'html')); + ?> +

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ +

+ $new_instance + * @param array $old_instance + * @return array + */ + public function update($new_instance, $old_instance): array { + return [ + 'mode' => in_array(($new_instance['mode'] ?? ''), ['html', 'gap'], true) ? $new_instance['mode'] : 'html', + 'title' => sanitize_text_field((string) ($new_instance['title'] ?? '')), + 'content' => wp_kses_post((string) ($new_instance['content'] ?? '')), + 'gap_height' => max(0, min(500, (int) ($new_instance['gap_height'] ?? 20))), + 'gap_height_m' => max(0, min(500, (int) ($new_instance['gap_height_m'] ?? $new_instance['gap_height'] ?? 20))), + 'full_width' => !empty($new_instance['full_width']) ? 1 : 0, + ]; + } } diff --git a/src/AKSRT/Widgets/WidgetAnnouncement.php b/src/AKSRT/Widgets/WidgetAnnouncement.php index d28f2b6a..dda10886 100644 --- a/src/AKSRT/Widgets/WidgetAnnouncement.php +++ b/src/AKSRT/Widgets/WidgetAnnouncement.php @@ -1,5 +1,7 @@ __('滚动显示公告/通知。', 'aksrt')] - ); - } + public function __construct() { + parent::__construct( + 'aksrt_announcement', + __('公告跑马灯', 'aksrt'), + [ + 'description' => __('滚动显示公告/通知(共享垂直 Swiper)。', 'aksrt'), + 'classname' => 'widget_aksrt_announcement', + ] + ); + } - public function widget($args, $instance): void { - $title = !empty($instance['title']) ? $instance['title'] : ''; - $items = !empty($instance['items']) ? $instance['items'] : ''; - $icon = !empty($instance['icon']) ? $instance['icon'] : 'fas fa-bullhorn'; - $speed = !empty($instance['speed']) ? max(5, min(30, (int) $instance['speed'])) : 10; + /** + * @param array $args + * @param array $instance + */ + public function widget($args, $instance): void { + $title = !empty($instance['title']) ? (string) $instance['title'] : ''; + $items = !empty($instance['items']) ? (string) $instance['items'] : ''; + $icon = !empty($instance['icon']) ? (string) $instance['icon'] : 'fas fa-bullhorn'; + $speed = !empty($instance['speed']) ? max(5, min(30, (int) $instance['speed'])) : 10; + $mode = sanitize_key((string) ($instance['mode'] ?? 'swiper')); + if (!in_array($mode, ['swiper', 'marquee'], true)) { + $mode = 'swiper'; + } + $interval = max(2, min(15, (int) ($instance['interval'] ?? max(3, (int) round($speed / 2))))); + $blank = !empty($instance['blank']); - $lines = array_filter(array_map('trim', explode("\n", $items))); - if (empty($lines)) return; + $lines = array_values(array_filter(array_map('trim', explode("\n", $items)))); + if (!$lines) { + return; + } - echo $args['before_widget']; + echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - if ($title) { - echo $args['before_title'] . esc_html($title) . $args['after_title']; - } + if ($title !== '') { + echo $args['before_title'] . esc_html($title) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } - echo '
'; - echo ''; - echo '
'; - echo '
    '; + if ($mode === 'marquee') { + // Legacy CSS marquee path. + echo '
    '; + echo ''; + echo '
    '; + echo '
      '; + $render = function (string $line) use ($blank): void { + $parts = explode('|', $line, 2); + $text = trim($parts[0]); + $link = isset($parts[1]) ? trim($parts[1]) : ''; + echo '
    • '; + if ($link !== '') { + echo '' . esc_html($text) . ''; + } else { + echo esc_html($text); + } + echo '
    • '; + }; + foreach ($lines as $line) { + $render($line); + } + // Duplicate first for seamless CSS loop. + $render($lines[0]); + echo '
    '; + } else { + // Shared vertical new-swiper (same stack as NoticeWidget). + echo '
    '; + echo '
    '; + echo '
    '; + echo '
    '; + foreach ($lines as $line) { + $parts = explode('|', $line, 2); + $text = trim($parts[0]); + $link = isset($parts[1]) ? trim($parts[1]) : ''; + echo '
    '; + if ($link !== '') { + echo '' . esc_html($text) . ''; + } else { + echo '' . esc_html($text) . ''; + } + echo '
    '; + } + echo '
    '; + } - foreach ($lines as $line) { - // 支持 "文本|链接" 格式 - $parts = explode('|', $line, 2); - $text = trim($parts[0]); - $link = isset($parts[1]) ? trim($parts[1]) : ''; + echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + } - echo '
  • '; - if ($link) { - echo '' . esc_html($text) . ''; - } else { - echo esc_html($text); - } - echo '
  • '; - } + /** + * @param array $instance + */ + public function form($instance): void { + $title = !empty($instance['title']) ? (string) $instance['title'] : ''; + $items = !empty($instance['items']) ? (string) $instance['items'] : ''; + $icon = !empty($instance['icon']) ? (string) $instance['icon'] : 'fas fa-bullhorn'; + $speed = !empty($instance['speed']) ? (int) $instance['speed'] : 10; + $mode = (string) ($instance['mode'] ?? 'swiper'); + ?> +

    + + +

    +

    + + + +

    +

    + +

    +

    + + +

    +

    + + +

    +

    + +

    +

    + +

    + '; - if ($first_link) { - echo '' . esc_html($first_text) . ''; - } else { - echo esc_html($first_text); - } - echo ''; - - echo '
'; - echo '
'; - echo '
'; - - echo $args['after_widget']; - } - - public function form($instance): void { - $title = !empty($instance['title']) ? $instance['title'] : ''; - $items = !empty($instance['items']) ? $instance['items'] : ''; - $icon = !empty($instance['icon']) ? $instance['icon'] : 'fas fa-bullhorn'; - $speed = !empty($instance['speed']) ? (int) $instance['speed'] : 10; - ?> -

- - -

-

- - - -

-

- - -

-

- - -

- $new_instance + * @param array $old_instance + * @return array + */ + public function update($new_instance, $old_instance): array { + $mode = sanitize_key((string) ($new_instance['mode'] ?? 'swiper')); + if (!in_array($mode, ['swiper', 'marquee'], true)) { + $mode = 'swiper'; + } + return [ + 'title' => sanitize_text_field((string) ($new_instance['title'] ?? '')), + 'items' => sanitize_textarea_field((string) ($new_instance['items'] ?? '')), + 'icon' => sanitize_text_field((string) ($new_instance['icon'] ?? 'fas fa-bullhorn')), + 'speed' => max(5, min(30, (int) ($new_instance['speed'] ?? 10))), + 'mode' => $mode, + 'interval' => max(2, min(15, (int) ($new_instance['interval'] ?? 4))), + 'blank' => !empty($new_instance['blank']) ? 1 : 0, + ]; + } } diff --git a/src/AKSRT/Widgets/WidgetPartnersScroll.php b/src/AKSRT/Widgets/WidgetPartnersScroll.php index c1633cb4..344cadbb 100644 --- a/src/AKSRT/Widgets/WidgetPartnersScroll.php +++ b/src/AKSRT/Widgets/WidgetPartnersScroll.php @@ -25,6 +25,13 @@ class WidgetPartnersScroll extends \WP_Widget { public function widget($args, $instance): void { $partners = $this->resolve_partners($instance); if (!$partners) { + 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; } @@ -125,7 +132,7 @@ class WidgetPartnersScroll extends \WP_Widget { $alt = esc_attr($title !== '' ? $title : __('合作伙伴', 'aksrt')); $img_tag = $image !== '' - ? '' . $alt . '' + ? '' . $alt . '' : ''; $inner = '';