feat(header): add 叠加组件 with after_html per background item
「顶部多功能组件 → 背景内容」的每个背景项目新增「叠加组件」手风琴, 其中提供「组件下方额外内容」(after_html) 输入框,支持 HTML。 - 后台 schema:slider_item_fields 增加 overlay accordion(sanitize_type html), 默认值与 PageConfigMetaBox / DisplayPageGroups 的默认项目同步带上空 overlay - 保存:页面独立配置(page_config 元数据)按项目写入 overlay.after_html, 沿用 wp_kses_post() 过滤 - 前端:after_html 作为 .slide-overlay-after 覆盖层输出在所属幻灯片内 (幻灯片是 overflow:hidden 的定位层,放到幻灯片外会被裁掉), 默认贴底居中、仅其中的链接与表单接收点击 - main.min.css 由 tools/build-public-assets.mjs 重新生成 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
44a03fd5f4
commit
c2733017fd
10 files changed
+89
-4
No files matched your search
@@ -189,6 +189,7 @@ final class PageConfigMetaBox {
|
||||
];
|
||||
}
|
||||
$text = is_array($slide['text'] ?? null) ? $slide['text'] : [];
|
||||
$overlay = is_array($slide['overlay'] ?? null) ? $slide['overlay'] : [];
|
||||
$link = is_array($slide['link'] ?? null) ? $slide['link'] : [];
|
||||
$clean[] = [
|
||||
'background' => esc_url_raw((string) ($slide['background'] ?? '')),
|
||||
@@ -201,6 +202,10 @@ final class PageConfigMetaBox {
|
||||
'text' => sanitize_text_field((string) ($link['text'] ?? '')),
|
||||
],
|
||||
'image_layer' => $layers,
|
||||
'overlay' => [
|
||||
// 叠加组件:幻灯片之上的附加 HTML,按项目独立配置。
|
||||
'after_html' => wp_kses_post((string) ($overlay['after_html'] ?? '')),
|
||||
],
|
||||
'text' => [
|
||||
'title' => wp_kses_post((string) ($text['title'] ?? '')),
|
||||
'desc' => wp_kses_post((string) ($text['desc'] ?? '')),
|
||||
@@ -302,6 +307,7 @@ final class PageConfigMetaBox {
|
||||
$slides[] = [
|
||||
'background' => $base . $image,
|
||||
'link' => ['url' => home_url('/'), 'target' => '_blank'],
|
||||
'overlay' => ['after_html' => ''],
|
||||
'text' => ['desc' => '', 'title' => '', 'text_align' => 'left-bottom', 'parallax' => 40, 'text_size_m' => 20, 'text_size_pc' => 30],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -169,6 +169,10 @@ class SchemaPageDisplay {
|
||||
self::field('background', '图片背景', 'upload', ''), self::field('background_video', '视频背景', 'upload', '', ['media_type' => 'video']), self::field('hide', '显示规则', 'radio', '', ['options' => self::options(['' => '全部显示', 'pc' => 'PC端不显示', 'm' => '移动端不显示'])]), self::field('link', '跳转链接', 'link', []),
|
||||
self::field('image_layer', '叠加图层', 'group', [], ['button_title' => '添加图层', 'fields' => [self::field('image', '图层图片', 'upload', ''), self::field('free_size', '自由尺寸', 'switcher', false), self::field('align', '图层对齐', 'radio', 'center', ['dependsOn' => ['all' => [self::not_empty('image'), self::enabled('free_size')]], 'options' => self::options(['left' => '靠左显示', 'center' => '居中显示', 'right' => '靠右显示'])]), self::field('parallax', '视差滚动', 'number', 0, ['dependsOn' => self::not_empty('image'), 'min' => -200, 'max' => 200, 'step' => 5]), self::field('parallax_scale', '视差缩放', 'number', 100, ['dependsOn' => self::not_empty('image'), 'min' => 1, 'max' => 200, 'step' => 5]), self::field('parallax_opacity', '视差透明', 'number', 100, ['dependsOn' => ['all' => [self::not_empty('image'), self::not_empty('parallax')]], 'min' => 1, 'max' => 100, 'step' => 5])]]),
|
||||
self::field('text', '叠加文案', 'accordion', ['title' => '', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_pc' => 30, 'text_size_m' => 20, 'parallax' => 40], ['fields' => [self::field('title', '幻灯片标题', 'textarea', '', ['sanitize_type' => 'html']), self::field('desc', '幻灯片简介', 'textarea', '', ['dependsOn' => self::not_empty('title'), 'sanitize_type' => 'html']), self::field('text_align', '显示位置', 'image_select', 'left-bottom', ['dependsOn' => self::not_empty('title'), 'previewWidth' => 160, 'options' => self::text_align_options()]), self::field('text_size_pc', 'PC端字体大小', 'number', 30, ['dependsOn' => self::not_empty('title'), 'min' => 12, 'max' => 50, 'step' => 1]), self::field('text_size_m', '移动端字体大小', 'number', 20, ['dependsOn' => self::not_empty('title'), 'min' => 12, 'max' => 50, 'step' => 1]), self::field('parallax', '文案视差滚动', 'number', 40, ['dependsOn' => self::not_empty('title'), 'min' => -200, 'max' => 200, 'step' => 10])]]),
|
||||
// 叠加组件:幻灯片之上的附加内容,独立于「叠加文案」,按项目逐条配置。
|
||||
self::field('overlay', '叠加组件', 'accordion', ['after_html' => ''], ['fields' => [
|
||||
self::field('after_html', '组件下方额外内容', 'textarea', '', ['sanitize_type' => 'html', 'rows' => 4, 'description' => '支持 HTML 代码;显示在背景内容下方,请注意代码规范与组件总高度。']),
|
||||
]]),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -187,7 +191,7 @@ class SchemaPageDisplay {
|
||||
private static function orderby_fields(): array { return [self::field('lists', '显示排序方式', 'select', ['modified', 'views', 'like', 'comment_count'], ['multiple' => true, 'sortable' => true, 'options' => self::post_order_options(false)]), self::field('dropdown', '更多排序方式', 'switcher', false)]; }
|
||||
private static function ajax_fields(string $source): array { return [self::field('lists', '按钮列表', 'async_select', [], ['source' => $source, 'multiple' => true, 'sortable' => true]), self::field('dropdown', '下拉列表', 'switcher', false), self::field('dropdown_lists', '下拉菜单列表', 'async_select', [], ['dependsOn' => self::enabled('dropdown'), 'source' => $source, 'multiple' => true, 'sortable' => true])]; }
|
||||
private static function footer_image_fields(): array { return [self::field('text', '显示文字', 'text', ''), self::field('image', '显示图片', 'upload', ''), self::field('link', '点击跳转', 'link', [])]; }
|
||||
private static function header_slider_defaults(): array { $img = self::asset('assets/img/'); return [['background' => $img . 'slider-bg.jpg', 'link' => ['url' => home_url('/'), 'target' => '_blank'], 'text' => ['title' => '', 'desc' => '', 'text_align' => 'left-bottom', 'parallax' => 40, 'text_size_m' => 20, 'text_size_pc' => 30]], ['background' => $img . 'user_t.jpg', 'link' => ['url' => home_url('/'), 'target' => '_blank'], 'text' => ['title' => '', 'desc' => '', 'text_align' => 'left-bottom', 'parallax' => 40, 'text_size_m' => 20, 'text_size_pc' => 30]]]; }
|
||||
private static function header_slider_defaults(): array { $img = self::asset('assets/img/'); return [['background' => $img . 'slider-bg.jpg', 'link' => ['url' => home_url('/'), 'target' => '_blank'], 'overlay' => ['after_html' => ''], 'text' => ['title' => '', 'desc' => '', 'text_align' => 'left-bottom', 'parallax' => 40, 'text_size_m' => 20, 'text_size_pc' => 30]], ['background' => $img . 'user_t.jpg', 'link' => ['url' => home_url('/'), 'target' => '_blank'], 'overlay' => ['after_html' => ''], 'text' => ['title' => '', 'desc' => '', 'text_align' => 'left-bottom', 'parallax' => 40, 'text_size_m' => 20, 'text_size_pc' => 30]]]; }
|
||||
private static function slider_options_defaults(): array { return ['direction' => 'horizontal', 'loop' => true, 'button' => true, 'pagination' => true, 'effect' => 'slide', 'scale_height' => false, 'auto_height' => false, 'pc_height' => 550, 'm_height' => 280, 'spacebetween' => 0, 'speed' => 0, 'autoplay' => true, 'interval' => 6]; }
|
||||
private static function search_defaults(): array { return ['show_keywords' => true, 'popular_limit' => 6, 'show_input_cat' => false, 'in_cat' => '', 'more_cats' => '', 'show_type' => false, 'in_type' => 'post', 'before_html' => '<div class="em16 font-bold mb10">更优雅的Wordpress主题</div>' . "\n" . '<div>这是导航栏幻灯片多功能组件,可在后台进行配置</div>', 'after_html' => '']; }
|
||||
private static function card_defaults(): array { return ['show_widget_bg' => false, 'icon_radius4' => false, 'cards' => [['icon' => 'fa fas fa-gem', 'customize_icon' => '', 'icon_class' => 'c-yellow', 'link' => [], 'title' => '图标卡片', 'desc' => '这是一个图标卡片示例'], ['icon' => 'fa fas fa-star', 'customize_icon' => '', 'icon_class' => 'c-blue-2', 'link' => [], 'title' => '原创作品', 'desc' => '这是一个图标卡片示例'], ['icon' => 'fa fas fa-fire', 'customize_icon' => '', 'icon_class' => 'jb-pink', 'link' => [], 'title' => '灵感来源<badge class="ml6 jb-yellow">NEW</badge>', 'desc' => '这是一个图标卡片示例'], ['icon' => 'fa fas fa-wrench', 'customize_icon' => '', 'icon_class' => 'jb-cyan', 'link' => [], 'title' => '系统工具 <badge class="ml6 jb-blue">GO <span class="fa fas fa-angle-right em12"></span></badge>', 'desc' => '这是一个图标卡片示例']]]; }
|
||||
|
||||
@@ -95,6 +95,7 @@ trait DisplayPageGroups {
|
||||
$slides[] = [
|
||||
'background' => $base . $image,
|
||||
'link' => ['url' => 'https://www.legacy.com/', 'target' => '_blank'],
|
||||
'overlay' => ['after_html' => ''],
|
||||
'text' => ['desc' => '', 'title' => '', 'text_align' => 'left-bottom', 'parallax' => 40, 'text_size_m' => 20, 'text_size_pc' => 30],
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user