Merge pull request 'Worktree ux depth batch16 18' (#234) from worktree-ux-depth-batch16-18 into main

Reviewed-on: CYL/wordpress-theme-aksrt#234
This commit is contained in:
2026-07-21 10:06:19 +08:00
11 changed files with 552 additions and 181 deletions
+208
View File
@@ -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;
}
+2 -2
View File
@@ -70,8 +70,8 @@ class AboutWidget extends \WP_Widget {
</div>
<div class="aksrt-user-card__info">
<div class="aksrt-user-card__name"><?php echo esc_html($u->display_name); ?></div>
<div class="aksrt-user-card__desc"><?php echo esc_html($u->user_email); ?></div>
<div class="aksrt-user-card__name"><?php if (function_exists('aksrt_get_user_name')) { echo aksrt_get_user_name(['id' => (int) $u->ID, 'class' => 'flex ac', 'follow' => false, 'medal' => true, 'auth' => true, 'level' => true]); } else { echo esc_html($u->display_name); } ?></div>
<div class="aksrt-user-card__desc"><?php $bio = trim((string) get_user_meta($u->ID, 'description', true)); echo esc_html($bio !== '' ? $bio : $u->user_email); ?></div>
</div>
<div class="aksrt-user-card__btns">
+63 -22
View File
@@ -1,5 +1,7 @@
<?php
/**
* Custom HTML / layout gap (zibll zib_widget_ui_layout_gap + custom HTML).
*
* @package AKSRT
*/
@@ -11,57 +13,96 @@ class CustomHtmlGapWidget extends \WP_Widget {
public function __construct() {
parent::__construct('aksrt_custom_html_gap', esc_html__('AKSRT 自定义HTML/间距', 'aksrt'), [
'description' => esc_html__('插入自定义 HTML 或间距', 'aksrt'),
'description' => esc_html__('插入自定义 HTML 或布局间距(PC/移动可分设)。', 'aksrt'),
'classname' => 'widget_aksrt_custom_html_gap',
]);
}
/**
* @param array<string,mixed> $args
* @param array<string,mixed> $instance
*/
public function widget($args, $instance): void {
$mode = sanitize_key($instance['mode'] ?? 'html');
$mode = sanitize_key((string) ($instance['mode'] ?? 'html'));
if ($mode === 'gap') {
$height = max(0, min(500, (int) ($instance['gap_height'] ?? 20)));
echo '<div class="widget-custom-gap" style="height:' . (int) $height . 'px;" aria-hidden="true"></div>';
$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 '<div class="widget-custom-gap aksrt-layout-gap" style="' . esc_attr($style) . '" aria-hidden="true"></div>';
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 '<div class="widget-custom-html">' . wp_kses_post($instance['content'] ?? '') . '</div>';
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 '<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;
}
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$title = apply_filters('widget_title', (string) ($instance['title'] ?? ''), $instance, $this->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 '<div class="' . esc_attr($cls) . '">' . wp_kses_post($content) . '</div>';
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* @param array<string,mixed> $instance
*/
public function form($instance): void {
$mode = sanitize_key($instance['mode'] ?? 'html');
$mode = sanitize_key((string) ($instance['mode'] ?? 'html'));
?>
<p>
<label for="<?php echo $this->get_field_id('mode'); ?>"><?php esc_html_e('模式:', 'aksrt'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('mode'); ?>" name="<?php echo $this->get_field_name('mode'); ?>">
<label for="<?php echo esc_attr($this->get_field_id('mode')); ?>"><?php esc_html_e('模式:', 'aksrt'); ?></label>
<select class="widefat" id="<?php echo esc_attr($this->get_field_id('mode')); ?>" name="<?php echo esc_attr($this->get_field_name('mode')); ?>">
<option value="html" <?php selected($mode, 'html'); ?>><?php esc_html_e('自定义 HTML', 'aksrt'); ?></option>
<option value="gap" <?php selected($mode, 'gap'); ?>><?php esc_html_e('间距', 'aksrt'); ?></option>
<option value="gap" <?php selected($mode, 'gap'); ?>><?php esc_html_e('布局间距', 'aksrt'); ?></option>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('标题(仅 HTML 模式,可选):', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo esc_attr($instance['title'] ?? ''); ?>">
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('标题(仅 HTML 模式,可选):', 'aksrt'); ?></label>
<input class="widefat" type="text" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" value="<?php echo esc_attr((string) ($instance['title'] ?? '')); ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('content'); ?>"><?php esc_html_e('HTML 内容:', 'aksrt'); ?></label>
<textarea class="widefat" rows="6" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>"><?php echo esc_textarea($instance['content'] ?? ''); ?></textarea>
<label for="<?php echo esc_attr($this->get_field_id('content')); ?>"><?php esc_html_e('HTML 内容:', 'aksrt'); ?></label>
<textarea class="widefat" rows="6" id="<?php echo esc_attr($this->get_field_id('content')); ?>" name="<?php echo esc_attr($this->get_field_name('content')); ?>"><?php echo esc_textarea((string) ($instance['content'] ?? '')); ?></textarea>
</p>
<p>
<label for="<?php echo $this->get_field_id('gap_height'); ?>"><?php esc_html_e('间距高度(px,仅间距模式):', 'aksrt'); ?></label>
<input class="tiny-text" type="number" min="0" max="500" id="<?php echo $this->get_field_id('gap_height'); ?>" name="<?php echo $this->get_field_name('gap_height'); ?>" value="<?php echo (int) ($instance['gap_height'] ?? 20); ?>">
<label for="<?php echo esc_attr($this->get_field_id('gap_height')); ?>"><?php esc_html_e('PC 间距高度 px:', 'aksrt'); ?></label>
<input class="tiny-text" type="number" min="0" max="500" id="<?php echo esc_attr($this->get_field_id('gap_height')); ?>" name="<?php echo esc_attr($this->get_field_name('gap_height')); ?>" value="<?php echo esc_attr((string) ((int) ($instance['gap_height'] ?? 20))); ?>">
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('gap_height_m')); ?>"><?php esc_html_e('移动间距高度 px:', 'aksrt'); ?></label>
<input class="tiny-text" type="number" min="0" max="500" id="<?php echo esc_attr($this->get_field_id('gap_height_m')); ?>" name="<?php echo esc_attr($this->get_field_name('gap_height_m')); ?>" value="<?php echo esc_attr((string) ((int) ($instance['gap_height_m'] ?? $instance['gap_height'] ?? 20))); ?>">
</p>
<p>
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('full_width')); ?>" value="1" <?php checked(!empty($instance['full_width'])); ?>> <?php esc_html_e('HTML 通栏', 'aksrt'); ?></label>
</p>
<?php
}
/**
* @param array<string,mixed> $new_instance
* @param array<string,mixed> $old_instance
* @return array<string,mixed>
*/
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'] ?? ''),
'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,
];
}
}
+102 -45
View File
@@ -1,5 +1,7 @@
<?php
/**
* Announcement marquee → vertical notice swiper (zibll notice family parity).
*
* @package AKSRT
*/
@@ -13,70 +15,97 @@ class WidgetAnnouncement extends \WP_Widget {
parent::__construct(
'aksrt_announcement',
__('公告跑马灯', 'aksrt'),
['description' => __('滚动显示公告/通知。', 'aksrt')]
[
'description' => __('滚动显示公告/通知(共享垂直 Swiper)。', 'aksrt'),
'classname' => 'widget_aksrt_announcement',
]
);
}
/**
* @param array<string,mixed> $args
* @param array<string,mixed> $instance
*/
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';
$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;
echo $args['before_widget'];
if ($title) {
echo $args['before_title'] . esc_html($title) . $args['after_title'];
$lines = array_values(array_filter(array_map('trim', explode("\n", $items))));
if (!$lines) {
return;
}
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ($title !== '') {
echo $args['before_title'] . esc_html($title) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ($mode === 'marquee') {
// Legacy CSS marquee path.
echo '<div class="aksrt-announcement">';
echo '<span class="aksrt-announcement__icon"><i class="' . esc_attr($icon) . '"></i></span>';
echo '<span class="aksrt-announcement__icon"><i class="' . esc_attr($icon) . '" aria-hidden="true"></i></span>';
echo '<div class="aksrt-announcement__track">';
echo '<ul class="aksrt-announcement__list" style="animation-duration: ' . esc_attr((string) $speed) . 's;">';
foreach ($lines as $line) {
// 支持 "文本|链接" 格式
$render = function (string $line) use ($blank): void {
$parts = explode('|', $line, 2);
$text = trim($parts[0]);
$link = isset($parts[1]) ? trim($parts[1]) : '';
echo '<li class="aksrt-announcement__item">';
if ($link) {
echo '<a href="' . esc_url($link) . '">' . esc_html($text) . '</a>';
if ($link !== '') {
echo '<a href="' . esc_url($link) . '"' . ($blank ? ' target="_blank" rel="noopener noreferrer"' : '') . '>' . esc_html($text) . '</a>';
} else {
echo esc_html($text);
}
echo '</li>';
};
foreach ($lines as $line) {
$render($line);
}
// 复制第一条实现无缝滚动
$first_line = $lines[0];
$first_parts = explode('|', $first_line, 2);
$first_text = trim($first_parts[0]);
$first_link = isset($first_parts[1]) ? trim($first_parts[1]) : '';
echo '<li class="aksrt-announcement__item">';
if ($first_link) {
echo '<a href="' . esc_url($first_link) . '">' . esc_html($first_text) . '</a>';
// Duplicate first for seamless CSS loop.
$render($lines[0]);
echo '</ul></div></div>';
} else {
echo esc_html($first_text);
// Shared vertical new-swiper (same stack as NoticeWidget).
echo '<div class="aksrt-scroll-notice aksrt-announcement-swiper-wrap swiper-bulletin">';
echo '<div class="aksrt-scroll-notice__icon bulletin-icon"><i class="' . esc_attr($icon) . '" aria-hidden="true"></i></div>';
echo '<div class="new-swiper aksrt-notice-swiper aksrt-announcement-swiper" data-direction="vertical" data-loop data-autoplay data-interval="' . esc_attr((string) ($interval * 1000)) . '">';
echo '<div class="swiper-wrapper">';
foreach ($lines as $line) {
$parts = explode('|', $line, 2);
$text = trim($parts[0]);
$link = isset($parts[1]) ? trim($parts[1]) : '';
echo '<div class="swiper-slide notice-slide">';
if ($link !== '') {
echo '<a class="text-ellipsis"' . ($blank ? ' target="_blank" rel="noopener noreferrer"' : '') . ' href="' . esc_url($link) . '">' . esc_html($text) . '</a>';
} else {
echo '<span class="text-ellipsis">' . esc_html($text) . '</span>';
}
echo '</li>';
echo '</ul>';
echo '</div>';
echo '</div>';
echo $args['after_widget'];
}
echo '</div></div></div>';
}
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* @param array<string,mixed> $instance
*/
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';
$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');
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('标题(可选):', 'aksrt'); ?></label>
@@ -84,26 +113,54 @@ class WidgetAnnouncement extends \WP_Widget {
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('items')); ?>"><?php esc_html_e('公告内容(每行一条):', 'aksrt'); ?></label>
<textarea class="widefat" id="<?php echo esc_attr($this->get_field_id('items')); ?>" name="<?php echo esc_attr($this->get_field_name('items')); ?>" rows="5" placeholder="系统维护通知&#10;新功能上线|https://example.com&#10;活动公告"><?php echo esc_textarea($items); ?></textarea>
<textarea class="widefat" id="<?php echo esc_attr($this->get_field_id('items')); ?>" name="<?php echo esc_attr($this->get_field_name('items')); ?>" rows="5" placeholder="系统维护通知&#10;新功能上线|https://example.com"><?php echo esc_textarea($items); ?></textarea>
<small><?php esc_html_e('每行一条,格式:文本 或 文本|链接', 'aksrt'); ?></small>
</p>
<p>
<label><?php esc_html_e('模式', 'aksrt'); ?>
<select name="<?php echo esc_attr($this->get_field_name('mode')); ?>">
<option value="swiper" <?php selected($mode, 'swiper'); ?>><?php esc_html_e('垂直轮播(推荐)', 'aksrt'); ?></option>
<option value="marquee" <?php selected($mode, 'marquee'); ?>><?php esc_html_e('横向跑马灯', 'aksrt'); ?></option>
</select>
</label>
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('icon')); ?>"><?php esc_html_e('图标:', 'aksrt'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('icon')); ?>" name="<?php echo esc_attr($this->get_field_name('icon')); ?>" type="text" value="<?php echo esc_attr($icon); ?>">
</p>
<p>
<label for="<?php echo esc_attr($this->get_field_id('speed')); ?>"><?php esc_html_e('滚动速度(秒):', 'aksrt'); ?></label>
<label for="<?php echo esc_attr($this->get_field_id('speed')); ?>"><?php esc_html_e('滚动速度(秒,跑马灯):', 'aksrt'); ?></label>
<input class="tiny-text" id="<?php echo esc_attr($this->get_field_id('speed')); ?>" name="<?php echo esc_attr($this->get_field_name('speed')); ?>" type="number" value="<?php echo esc_attr((string) $speed); ?>" min="5" max="30">
</p>
<p>
<label><?php esc_html_e('轮播间隔(秒)', 'aksrt'); ?>
<input class="tiny-text" type="number" min="2" max="15" name="<?php echo esc_attr($this->get_field_name('interval')); ?>" value="<?php echo esc_attr((string) ((int) ($instance['interval'] ?? 4))); ?>">
</label>
</p>
<p>
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('blank')); ?>" value="1" <?php checked(!empty($instance['blank'])); ?>> <?php esc_html_e('链接新窗口', 'aksrt'); ?></label>
</p>
<?php
}
/**
* @param array<string,mixed> $new_instance
* @param array<string,mixed> $old_instance
* @return array<string,mixed>
*/
public function update($new_instance, $old_instance): array {
$instance = [];
$instance['title'] = sanitize_text_field($new_instance['title'] ?? '');
$instance['items'] = sanitize_textarea_field($new_instance['items'] ?? '');
$instance['icon'] = sanitize_text_field($new_instance['icon'] ?? 'fas fa-bullhorn');
$instance['speed'] = max(5, min(30, (int) ($new_instance['speed'] ?? 10)));
return $instance;
$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,
];
}
}
+29 -4
View File
@@ -44,16 +44,29 @@ class WidgetComboInfo extends \WP_Widget {
echo $args['before_title'] . esc_html($title) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
$style = sprintf('--aksrt-zci-radius:%dpx;--aksrt-zci-band-h:%dpx;--aksrt-zci-pc:%d;--aksrt-zci-m:%d;', $radius, $band_h, $pc_row, $m_row);
$wrap = 'aksrt-combo-info' . ($top_band ? ' has-band' : '');
$style = sprintf('--aksrt-zci-radius:%dpx;--aksrt-zci-band-h:%dpx;--aksrt-zci-pc:%d;--aksrt-zci-m:%d;--zci-radius:%dpx;--zci-band-h:%dpx;', $radius, $band_h, $pc_row, $m_row, $radius, $band_h);
$wrap = 'aksrt-combo-info zib-combo-info-card row gutters-10' . ($top_band ? ' has-band zci-has-band' : '');
$anim = sanitize_key((string) ($instance['obs_animation'] ?? ''));
$anim_repeat = !empty($instance['animation_repeat']);
$pc_span = max(1, (int) floor(12 / $pc_row));
$m_span = max(1, (int) floor(12 / $m_row));
$col = 'col-sm-' . $pc_span . ' col-xs-' . $m_span;
echo '<div class="' . esc_attr($wrap) . '" style="' . esc_attr($style) . '">';
$auto_idx = 0;
$ci = 0;
foreach ($cards as $card) {
$html = $this->render_card($card, $cta_default, $auto_idx, $go_link, $top_band);
if ($html !== '') {
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ($html === '') {
continue;
}
$pack = function_exists('aksrt_obs_animate_attrs')
? aksrt_obs_animate_attrs($anim, $anim_repeat, $ci * 0.1)
: ['class' => '', 'attr' => ''];
echo '<div class="' . esc_attr(trim($col . $pack['class'])) . '"' . $pack['attr'] . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '</div>';
$ci++;
}
echo '</div>';
@@ -219,6 +232,16 @@ class WidgetComboInfo extends \WP_Widget {
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('top_band')); ?>" value="1" <?php checked(!empty($instance['top_band']) || !isset($instance['top_band'])); ?>> <?php esc_html_e('顶部色带', 'aksrt'); ?></label><br>
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('go_link')); ?>" value="1" <?php checked(!empty($instance['go_link'])); ?>> <?php esc_html_e('外链跳转页', 'aksrt'); ?></label>
</p>
<p>
<label><?php esc_html_e('入场动画', 'aksrt'); ?>
<select name="<?php echo esc_attr($this->get_field_name('obs_animation')); ?>">
<option value="" <?php selected(($instance['obs_animation'] ?? ''), ''); ?>><?php esc_html_e('无', 'aksrt'); ?></option>
<option value="slideup" <?php selected(($instance['obs_animation'] ?? ''), 'slideup'); ?>><?php esc_html_e('上滑', 'aksrt'); ?></option>
<option value="fade" <?php selected(($instance['obs_animation'] ?? ''), 'fade'); ?>><?php esc_html_e('淡入', 'aksrt'); ?></option>
<option value="zoomin" <?php selected(($instance['obs_animation'] ?? ''), 'zoomin'); ?>><?php esc_html_e('放大', 'aksrt'); ?></option>
</select>
</label>
</p>
<?php
}
@@ -233,6 +256,8 @@ class WidgetComboInfo extends \WP_Widget {
'top_band_height' => max(20, min(160, (int) ($new_instance['top_band_height'] ?? 70))),
'cta_text' => sanitize_text_field((string) ($new_instance['cta_text'] ?? '')),
'go_link' => !empty($new_instance['go_link']) ? 1 : 0,
'obs_animation' => sanitize_key((string) ($new_instance['obs_animation'] ?? '')),
'animation_repeat'=> !empty($new_instance['animation_repeat']) ? 1 : 0,
];
}
}
+5 -3
View File
@@ -50,7 +50,8 @@ class WidgetFeatureIntro extends \WP_Widget {
$ss = sanitize_text_field((string) ($instance['stat_suffix'] ?? '+'));
$sl = sanitize_text_field((string) ($instance['stat_label'] ?? ''));
if ($sn !== '') {
echo '<div class="aksrt-fi__stat"><span class="aksrt-fi__stat-num">' . esc_html($sn) . '</span>';
$num_attr = is_numeric($sn) ? ' data-aksrt-countup data-target="' . esc_attr((string) (float) $sn) . '" data-duration="1600"' : '';
echo '<div class="aksrt-fi__stat"><span class="aksrt-fi__stat-num"' . $num_attr . '>' . esc_html(is_numeric($sn) ? '0' : $sn) . '</span>';
if ($ss !== '') {
echo '<span class="aksrt-fi__stat-plus">' . esc_html($ss) . '</span>';
}
@@ -83,7 +84,8 @@ class WidgetFeatureIntro extends \WP_Widget {
echo '<div class="aksrt-fi__browser-body" style="padding-bottom:' . esc_attr((string) $ratio) . '%">';
if ($s['media_type'] === 'video' && $s['video_url'] !== '') {
$poster = $s['video_poster'] !== '' ? ' poster="' . esc_url($s['video_poster']) . '"' : '';
echo '<video class="aksrt-fi__video" src="' . esc_url($s['video_url']) . '"' . $poster . ' autoplay muted loop playsinline></video>';
$auto = $i === 0 ? ' autoplay' : '';
echo '<video class="aksrt-fi__video" src="' . esc_url($s['video_url']) . '"' . $poster . $auto . ' muted loop playsinline></video>';
} elseif ($s['image'] !== '') {
echo '<img class="aksrt-fi__img" src="' . esc_url($s['image']) . '" alt="' . esc_attr($s['tab_label']) . '" loading="lazy" />';
}
@@ -101,7 +103,7 @@ class WidgetFeatureIntro extends \WP_Widget {
var panels=[].slice.call(root.querySelectorAll('.aksrt-fi__panel'));
function go(i){
tabs.forEach(function(t,idx){t.classList.toggle('is-active',idx===i);});
panels.forEach(function(p,idx){p.classList.toggle('is-active',idx===i);});
panels.forEach(function(p,idx){p.classList.toggle('is-active',idx===i);var v=p.querySelector('video');if(v){if(idx===i){v.play&&v.play().catch(function(){})}else{v.pause&&v.pause()}}});
}
tabs.forEach(function(t){ t.addEventListener('click', function(){ go(parseInt(t.getAttribute('data-index')||'0',10)); }); });
})();
+44 -22
View File
@@ -1,6 +1,6 @@
<?php
/**
* Highlights cards (zibll zib_widget_highlights lite).
* Highlights cards (zibll zib_widget_highlights) with scroll animation + go_link.
*
* @package AKSRT
*/
@@ -22,12 +22,18 @@ class WidgetHighlights extends \WP_Widget {
);
}
/**
* @param array<string,mixed> $args
* @param array<string,mixed> $instance
*/
public function widget($args, $instance): void {
$cards = $this->normalize($instance['cards'] ?? []);
if (!$cards) {
return;
}
$go_link = !empty($instance['go_link']);
$anim = sanitize_key((string) ($instance['obs_animation'] ?? 'slideup'));
$anim_repeat = !empty($instance['animation_repeat']);
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$title = apply_filters('widget_title', (string) ($instance['title'] ?? ''), $instance, $this->id_base);
@@ -38,30 +44,23 @@ class WidgetHighlights extends \WP_Widget {
$large = array_values(array_filter($cards, static fn($c) => ($c['size'] ?? 'medium') === 'large'));
$medium = array_values(array_filter($cards, static fn($c) => ($c['size'] ?? 'medium') === 'medium'));
$small = array_values(array_filter($cards, static fn($c) => ($c['size'] ?? 'medium') === 'small'));
// Fallback: if no size tags, treat all as medium.
if (!$large && !$medium && !$small) {
$medium = $cards;
}
echo '<div class="aksrt-highlights">';
if ($large) {
echo '<div class="aksrt-highlights__row is-large">';
foreach ($large as $c) {
echo $this->card($c, 'large', $go_link); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$idx = 0;
foreach (['large' => $large, 'medium' => $medium, 'small' => $small] as $size => $group) {
if (!$group) {
continue;
}
echo '</div>';
}
if ($medium) {
echo '<div class="aksrt-highlights__row is-medium">';
foreach ($medium as $c) {
echo $this->card($c, 'medium', $go_link); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '</div>';
}
if ($small) {
echo '<div class="aksrt-highlights__row is-small">';
foreach ($small as $c) {
echo $this->card($c, 'small', $go_link); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<div class="aksrt-highlights__row is-' . esc_attr($size) . '">';
foreach ($group as $c) {
$pack = function_exists('aksrt_obs_animate_attrs')
? aksrt_obs_animate_attrs($anim, $anim_repeat, $idx * 0.08)
: ['class' => '', 'attr' => ''];
echo $this->card($c, $size, $go_link, $pack); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$idx++;
}
echo '</div>';
}
@@ -72,8 +71,9 @@ class WidgetHighlights extends \WP_Widget {
/**
* @param array<string,mixed> $c
* @param array{class:string,attr:string} $pack
*/
private function card(array $c, string $size, bool $go_link): string {
private function card(array $c, string $size, bool $go_link, array $pack): string {
$color = sanitize_key((string) ($c['color'] ?? 'blue'));
if (!in_array($color, ['blue', 'pink', 'purple', 'green', 'orange', 'cyan'], true)) {
$color = 'blue';
@@ -85,9 +85,11 @@ class WidgetHighlights extends \WP_Widget {
$tag = $url !== '' ? 'a' : 'div';
$href = $url !== '' ? ' href="' . esc_url($url) . '"' : '';
$img = (string) ($c['image'] ?? '');
$html = '<' . $tag . ' class="aksrt-hl-card size-' . esc_attr($size) . ' color-' . esc_attr($color) . '"' . $href . '>';
$cls = 'aksrt-hl-card size-' . esc_attr($size) . ' color-' . esc_attr($color) . $pack['class'];
$html = '<' . $tag . ' class="' . esc_attr(trim($cls)) . '"' . $href . $pack['attr'] . '>';
if ($img !== '') {
$html .= '<div class="aksrt-hl-card__media"><img src="' . esc_url($img) . '" alt="" loading="lazy" /></div>';
$placeholder = get_template_directory_uri() . '/assets/img/placeholder.svg';
$html .= '<div class="aksrt-hl-card__media"><img class="fit-cover aksrt-lazy lazyload" data-src="' . esc_url($img) . '" src="' . esc_url($placeholder) . '" alt="" loading="lazy" /></div>';
}
$html .= '<div class="aksrt-hl-card__body">';
if (!empty($c['icon'])) {
@@ -145,6 +147,9 @@ class WidgetHighlights extends \WP_Widget {
return $out;
}
/**
* @param array<string,mixed> $instance
*/
public function form($instance): void {
$json = is_string($instance['cards'] ?? null)
? (string) $instance['cards']
@@ -161,17 +166,34 @@ class WidgetHighlights extends \WP_Widget {
</label>
<small><?php esc_html_e('size: large|medium|small;color: blue/pink/…', 'aksrt'); ?></small>
</p>
<p>
<label><?php esc_html_e('入场动画', 'aksrt'); ?>
<select name="<?php echo esc_attr($this->get_field_name('obs_animation')); ?>">
<option value="" <?php selected(($instance['obs_animation'] ?? 'slideup'), ''); ?>><?php esc_html_e('无', 'aksrt'); ?></option>
<option value="fade" <?php selected(($instance['obs_animation'] ?? 'slideup'), 'fade'); ?>><?php esc_html_e('淡入', 'aksrt'); ?></option>
<option value="slideup" <?php selected(($instance['obs_animation'] ?? 'slideup'), 'slideup'); ?>><?php esc_html_e('上滑', 'aksrt'); ?></option>
<option value="zoomin" <?php selected(($instance['obs_animation'] ?? 'slideup'), 'zoomin'); ?>><?php esc_html_e('放大', 'aksrt'); ?></option>
</select>
</label>
</p>
<p>
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('go_link')); ?>" value="1" <?php checked(!empty($instance['go_link'])); ?>> <?php esc_html_e('外链跳转页', 'aksrt'); ?></label>
</p>
<?php
}
/**
* @param array<string,mixed> $new_instance
* @param array<string,mixed> $old_instance
* @return array<string,mixed>
*/
public function update($new_instance, $old_instance): array {
return [
'title' => sanitize_text_field((string) ($new_instance['title'] ?? '')),
'cards' => $this->normalize($new_instance['cards'] ?? []),
'go_link' => !empty($new_instance['go_link']) ? 1 : 0,
'obs_animation' => sanitize_key((string) ($new_instance['obs_animation'] ?? 'slideup')),
'animation_repeat' => !empty($new_instance['animation_repeat']) ? 1 : 0,
];
}
}
+8 -1
View File
@@ -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
: '<p class="widget-empty">' . esc_html__('暂无合作伙伴', 'aksrt') . '</p>';
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 !== ''
? '<img class="aksrt-ps-img" src="' . esc_url($image) . '" alt="' . $alt . '" loading="lazy" />'
? '<img class="aksrt-ps-img aksrt-lazy lazyload" data-src="' . esc_url($image) . '" src="' . esc_url(get_template_directory_uri() . '/assets/img/placeholder.svg') . '" alt="' . $alt . '" loading="lazy" />'
: '';
$inner = '';
+5 -2
View File
@@ -41,14 +41,17 @@ class WidgetPricingPlans extends \WP_Widget {
echo '<div class="aksrt-pricing">';
echo '<div class="aksrt-pricing__cards">';
$pi = 0;
foreach ($plans as $plan) {
$accent = sanitize_key((string) ($plan['color'] ?? 'blue'));
if (!in_array($accent, ['pink', 'purple', 'blue', 'green', 'yellow', 'cyan'], true)) {
$accent = 'blue';
}
$featured = !empty($plan['is_featured']);
$class = 'aksrt-pricing__card accent-' . $accent . ($featured ? ' is-featured' : '');
echo '<div class="' . esc_attr($class) . '">';
$pack = function_exists('aksrt_obs_animate_attrs') ? aksrt_obs_animate_attrs('slideup', false, $pi * 0.12) : ['class' => '', 'attr' => ''];
$class = 'aksrt-pricing__card accent-' . $accent . ($featured ? ' is-featured' : '') . $pack['class'];
echo '<div class="' . esc_attr(trim($class)) . '"' . $pack['attr'] . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$pi++;
if ($featured || !empty($plan['tag'])) {
$badge = (string) ($plan['tag'] !== '' ? $plan['tag'] : __('推荐', 'aksrt'));
echo '<span class="aksrt-pricing__badge">' . esc_html($badge) . '</span>';
+6 -2
View File
@@ -38,9 +38,10 @@ class WidgetReviews extends \WP_Widget {
$style = sprintf('--aksrt-rev-pc:%s;--aksrt-rev-m:%s;', rtrim(rtrim(number_format($pc, 2, '.', ''), '0'), '.'), rtrim(rtrim(number_format($m, 2, '.', ''), '0'), '.'));
echo '<div class="aksrt-reviews" style="' . esc_attr($style) . '">';
echo '<div class="aksrt-reviews__track">';
echo '<div class="swiper-container swiper-scroll aksrt-reviews-swiper">';
echo '<div class="swiper-wrapper aksrt-reviews__track">';
foreach ($reviews as $r) {
echo '<div class="aksrt-reviews__slide"><div class="aksrt-reviews__card">';
echo '<div class="swiper-slide aksrt-reviews__slide"><div class="aksrt-reviews__card" data-aksrt-tilt data-tilt-max="8">';
echo '<div class="aksrt-reviews__head">';
if ($r['avatar'] !== '') {
echo '<img class="aksrt-reviews__avatar" src="' . esc_url($r['avatar']) . '" alt="" loading="lazy" width="44" height="44" />';
@@ -70,6 +71,9 @@ class WidgetReviews extends \WP_Widget {
echo '<i class="fa fa-quote-right aksrt-reviews__quote" aria-hidden="true"></i>';
echo '</div></div>';
}
echo '</div>';
echo '<div class="swiper-button-prev" aria-label="' . esc_attr__('上一页', 'aksrt') . '"></div>';
echo '<div class="swiper-button-next" aria-label="' . esc_attr__('下一页', 'aksrt') . '"></div>';
echo '</div></div>';
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+5 -3
View File
@@ -37,7 +37,8 @@ class WidgetTiltCases extends \WP_Widget {
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<div class="aksrt-tilt">';
echo '<div class="aksrt-tilt__text">';
$pack = function_exists('aksrt_obs_animate_attrs') ? aksrt_obs_animate_attrs('slideup', false, 0) : ['class' => '', 'attr' => ''];
echo '<div class="aksrt-tilt__text' . esc_attr($pack['class']) . '"' . $pack['attr'] . '>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ($badge !== '') {
$icon = sanitize_text_field((string) ($instance['intro_badge_icon'] ?? ''));
echo '<div class="aksrt-tilt__badge">';
@@ -82,11 +83,12 @@ class WidgetTiltCases extends \WP_Widget {
}
echo '</div>';
echo '<div class="aksrt-tilt__showcase">';
echo '<div class="aksrt-tilt__showcase" data-aksrt-tilt data-tilt-max="12" data-tilt-glare="1">';
if ($images) {
foreach ($images as $i => $img) {
$cls = $i === 0 ? ' is-main' : '';
echo '<div class="aksrt-tilt__img' . esc_attr($cls) . '"><img src="' . esc_url($img) . '" alt="" loading="lazy" /></div>';
$placeholder = get_template_directory_uri() . '/assets/img/placeholder.svg';
echo '<div class="aksrt-tilt__img' . esc_attr($cls) . '"><img class="aksrt-lazy lazyload" data-src="' . esc_url($img) . '" src="' . esc_url($placeholder) . '" alt="" loading="lazy" /></div>';
}
} else {
echo '<div class="aksrt-tilt__img is-main is-empty"></div>';