对小工具进行了一些修复
This commit is contained in:
@@ -145,19 +145,45 @@ final class WidgetSchemas {
|
||||
$fields[] = ['id' => 'autoplay', 'type' => 'switcher', 'label' => '自动滚动', 'default' => true];
|
||||
}
|
||||
if ($slug === 'tab_posts') {
|
||||
$fields[] = [
|
||||
'id' => 'tabs', 'type' => 'group', 'label' => '栏目', 'max_items' => 10,
|
||||
'fields' => [
|
||||
['id' => 'title', 'type' => 'text', 'label' => '栏目标题', 'default' => ''],
|
||||
['id' => 'category_id', 'type' => 'number', 'label' => '分类 ID', 'default' => 0, 'min' => 0],
|
||||
['id' => 'tag_ids', 'type' => 'text', 'label' => '标签 ID', 'default' => '', 'sanitize' => 'ids'],
|
||||
['id' => 'pay_type', 'type' => 'select', 'label' => '付费类型', 'default' => '', 'options' => self::pay_types()],
|
||||
],
|
||||
];
|
||||
return self::tab_posts_fields();
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
private static function tab_posts_fields(): array {
|
||||
return [
|
||||
['id' => 'style', 'type' => 'radio', 'label' => '列表样式', 'default' => 'mini', 'options' => ['list' => '列表样式', 'card' => '卡片样式', 'mini' => 'mini列表']],
|
||||
['id' => 'mini_opt', 'type' => 'checkbox', 'label' => 'mini列表配置', 'default' => [], 'dependency' => ['style', '==', 'mini'], 'options' => ['show_thumb' => '显示缩略图', 'show_number' => '显示编号(开启翻页后,只在第一页有效)', 'show_meta' => '显示作者、时间、点赞等信息']],
|
||||
['id' => 'count', 'type' => 'spinner', 'label' => '显示数量', 'default' => 6, 'min' => 4, 'max' => 20, 'step' => 1],
|
||||
['id' => 'paginate', 'type' => 'radio', 'label' => '翻页按钮', 'default' => '', 'options' => ['' => '不翻页', 'ajax' => 'AJAX追加列表翻页', 'number' => '数字翻页按钮']],
|
||||
[
|
||||
'id' => 'tabs', 'type' => 'group', 'label' => '栏目', 'max_items' => 10,
|
||||
'default' => [
|
||||
['title' => '热门推荐', 'orderby' => 'views'],
|
||||
['title' => '最近更新', 'orderby' => 'modified'],
|
||||
['title' => '猜你喜欢', 'orderby' => 'rand'],
|
||||
],
|
||||
'fields' => [
|
||||
['id' => 'title', 'type' => 'textarea', 'label' => '标题(必填)', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1]],
|
||||
['id' => 'cat', 'type' => 'text', 'label' => '分类限制', 'default' => '', 'sanitize' => 'reference_ids'],
|
||||
['id' => 'topics', 'type' => 'text', 'label' => '专题限制', 'default' => '', 'sanitize' => 'reference_ids', 'description' => '多个 ID 用英文逗号隔开,支持负数排除。'],
|
||||
['id' => 'zibpay_type', 'type' => 'checkbox', 'label' => '商品类型筛选', 'default' => [], 'options' => ['1' => '付费阅读', '2' => '付费下载', '5' => '付费图片', '6' => '付费视频']],
|
||||
['id' => 'limit_day', 'type' => 'spinner', 'label' => '发布时间限制', 'default' => 0, 'min' => 0, 'step' => 5, 'max' => 3650],
|
||||
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => '', 'options' => self::posts_orderby()],
|
||||
['id' => 'order', 'type' => 'radio', 'label' => '顺序', 'default' => 'desc', 'options' => ['desc' => '降序', 'asc' => '升序']],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private static function posts_orderby(): array {
|
||||
return [
|
||||
'' => '默认排序', 'modified' => '更新时间', 'date' => '发布时间', 'views' => '浏览数量',
|
||||
'like' => '点赞数量', 'comment_count' => '评论数量', 'favorite' => '收藏数量',
|
||||
'zibpay_price' => '销售价格', 'zibpay_points_price' => '积分售价', 'sales_volume' => '销售数量', 'rand' => '随机排序',
|
||||
];
|
||||
}
|
||||
|
||||
private static function post_query_fields(): array {
|
||||
return [
|
||||
['id' => 'category_ids', 'type' => 'text', 'label' => '分类 ID', 'default' => '', 'sanitize' => 'ids'],
|
||||
@@ -206,31 +232,81 @@ final class WidgetSchemas {
|
||||
}
|
||||
|
||||
private static function slider(string $slug): array {
|
||||
$asset_uri = function_exists('get_template_directory_uri') ? get_template_directory_uri() . '/assets/img/' : '';
|
||||
$align_uri = function_exists('get_template_directory_uri') ? get_template_directory_uri() . '/assets/images/slider-align/' : '';
|
||||
$slide_fields = [
|
||||
['id' => 'background', 'type' => 'upload', 'label' => '图片背景', 'default' => ''],
|
||||
['id' => 'background_video', 'type' => 'upload', 'label' => '视频背景', 'default' => '', 'description' => '图片背景、视频背景至少二选一;PC 端视频优先,移动端只显示图片。'],
|
||||
['id' => 'hide', 'type' => 'radio', 'label' => '显示规则', 'default' => '', 'options' => ['' => '全部显示', 'pc' => 'PC端不显示', 'm' => '移动端不显示']],
|
||||
['id' => 'link', 'type' => 'link', 'label' => '跳转链接', 'default' => []],
|
||||
['id' => 'image_layer', 'type' => 'group', 'label' => '叠加图层', 'max_items' => 12, 'fields' => [
|
||||
['id' => 'image', 'type' => 'upload', 'label' => '图层图片', 'default' => ''],
|
||||
['id' => 'free_size', 'type' => 'switcher', 'label' => '自由尺寸', 'default' => false],
|
||||
['id' => 'align', 'type' => 'radio', 'label' => '图层对齐', 'default' => 'center', 'options' => ['left' => '靠左显示', 'center' => '居中显示', 'right' => '靠右显示'], 'dependency' => ['image|free_size', '!=|!=', '|']],
|
||||
['id' => 'parallax', 'type' => 'spinner', 'label' => '视差滚动', 'default' => 0, 'min' => -200, 'max' => 200, 'step' => 5, 'dependency' => ['image', '!=', '']],
|
||||
['id' => 'parallax_scale', 'type' => 'spinner', 'label' => '视差缩放', 'default' => 100, 'min' => 1, 'max' => 200, 'step' => 5, 'dependency' => ['image', '!=', '']],
|
||||
['id' => 'parallax_opacity', 'type' => 'spinner', 'label' => '视差透明', 'default' => 100, 'min' => 1, 'max' => 100, 'step' => 5, 'dependency' => ['image|parallax', '!=|!=', '|']],
|
||||
]],
|
||||
['id' => 'text', 'type' => 'accordion', 'label' => '叠加文案', 'fields' => [
|
||||
['id' => 'title', 'type' => 'textarea', 'label' => '幻灯片文案', 'default' => '', 'allow_html' => true],
|
||||
['id' => 'desc', 'type' => 'textarea', 'label' => '幻灯片简介', 'default' => '', 'allow_html' => true, 'dependency' => ['title', '!=', '']],
|
||||
['id' => 'text_align', 'type' => 'image_select', 'label' => '显示位置', 'default' => 'left-bottom', 'options' => ['left-bottom' => $align_uri . 'left-bottom.jpg', 'left-conter' => $align_uri . 'left-conter.jpg', 'conter-conter' => $align_uri . 'conter-conter.jpg', 'conter-bottom' => $align_uri . 'conter-bottom.jpg', 'right-conter' => $align_uri . 'right-conter.jpg', 'right-bottom' => $align_uri . 'right-bottom.jpg']],
|
||||
['id' => 'text_size_pc', 'type' => 'spinner', 'label' => 'PC端字体大小', 'default' => 30, 'min' => 12, 'max' => 50],
|
||||
['id' => 'text_size_m', 'type' => 'spinner', 'label' => '移动端字体大小', 'default' => 20, 'min' => 12, 'max' => 50],
|
||||
['id' => 'parallax', 'type' => 'spinner', 'label' => '文案视差滚动', 'default' => 40, 'min' => -200, 'max' => 200, 'step' => 10],
|
||||
]],
|
||||
];
|
||||
$fields = [
|
||||
['id' => 'direction', 'type' => 'radio', 'label' => '方向', 'default' => 'horizontal', 'options' => ['horizontal' => '横向', 'vertical' => '纵向']],
|
||||
['id' => 'effect', 'type' => 'select', 'label' => '切换效果', 'default' => 'slide', 'options' => ['slide' => '滑动', 'fade' => '淡入', 'cube' => '立方体', 'coverflow' => '封面流']],
|
||||
['id' => 'pc_height', 'type' => 'spinner', 'label' => 'PC 高度', 'default' => 400, 'min' => 120, 'max' => 1000],
|
||||
['id' => 'm_height', 'type' => 'spinner', 'label' => '移动端高度', 'default' => 240, 'min' => 100, 'max' => 800],
|
||||
['id' => 'spacebetween', 'type' => 'spinner', 'label' => '间距', 'default' => 15, 'min' => 0, 'max' => 100],
|
||||
['id' => 'speed', 'type' => 'spinner', 'label' => '切换速度(毫秒)', 'default' => 500, 'min' => 100, 'max' => 5000],
|
||||
['id' => 'interval', 'type' => 'spinner', 'label' => '自动播放间隔(秒)', 'default' => 4, 'min' => 1, 'max' => 60],
|
||||
['id' => 'autoplay', 'type' => 'switcher', 'label' => '自动播放', 'default' => true],
|
||||
['id' => 'loop', 'type' => 'switcher', 'label' => '循环', 'default' => true],
|
||||
['id' => 'button', 'type' => 'switcher', 'label' => '显示切换按钮', 'default' => true],
|
||||
['id' => 'pagination', 'type' => 'switcher', 'label' => '显示分页器', 'default' => true],
|
||||
['id' => 'slides', 'type' => 'group', 'label' => '幻灯片', 'max_items' => 30, 'fields' => [
|
||||
['id' => 'background', 'type' => 'upload', 'label' => '背景图片', 'default' => ''],
|
||||
['id' => 'background_video', 'type' => 'upload', 'label' => '背景视频', 'default' => ''],
|
||||
['id' => 'hide_mobile', 'type' => 'switcher', 'label' => '移动端隐藏', 'default' => false],
|
||||
['id' => 'link', 'type' => 'link', 'label' => '链接', 'default' => []],
|
||||
['id' => 'title', 'type' => 'text', 'label' => '标题', 'default' => ''],
|
||||
['id' => 'description', 'type' => 'textarea', 'label' => '说明', 'default' => ''],
|
||||
['id' => 'text_align', 'type' => 'select', 'label' => '文字位置', 'default' => 'left-bottom', 'options' => ['left-top' => '左上', 'left-center' => '左中', 'left-bottom' => '左下', 'center' => '居中', 'right-bottom' => '右下']],
|
||||
['id' => 'layers', 'type' => 'group', 'label' => '图片图层', 'max_items' => 12, 'fields' => [['id' => 'image', 'type' => 'upload', 'label' => '图片', 'default' => ''], ['id' => 'parallax', 'type' => 'spinner', 'label' => '视差', 'default' => 0, 'min' => -300, 'max' => 300], ['id' => 'scale', 'type' => 'slider', 'label' => '缩放', 'default' => 100, 'min' => 10, 'max' => 300]]],
|
||||
['id' => 'slides', 'type' => 'group', 'label' => '幻灯片内容', 'max_items' => 30, 'min_items' => 1, 'default' => [['background' => $asset_uri . 'slider-bg.jpg', 'image_layer' => [['image' => $asset_uri . 'slider-layer-1.png', 'align' => 'center', 'free_size' => true, 'parallax' => -100, 'parallax_scale' => 100, 'parallax_opacity' => 100], ['image' => $asset_uri . 'slider-layer-2.png', 'align' => 'center', 'free_size' => true, 'parallax' => -50, 'parallax_scale' => 50, 'parallax_opacity' => 30]]]], 'fields' => $slide_fields],
|
||||
['id' => 'option', 'type' => 'accordion', 'label' => '幻灯片设置', 'default' => ['direction' => 'horizontal', 'button' => true, 'pagination' => true, 'effect' => 'slide', 'auto_height' => false, 'pc_height' => 400, 'm_height' => 240, 'spacebetween' => 15, 'speed' => 0, 'interval' => 4], 'fields' => [
|
||||
['id' => 'direction', 'type' => 'radio', 'label' => '幻灯片方向', 'default' => 'horizontal', 'options' => ['horizontal' => '左右切换', 'vertical' => '上下切换']],
|
||||
['id' => 'loop', 'type' => 'switcher', 'label' => '循环切换', 'default' => true],
|
||||
['id' => 'button', 'type' => 'switcher', 'label' => '显示翻页按钮', 'default' => false],
|
||||
['id' => 'pagination', 'type' => 'switcher', 'label' => '显示指示器', 'default' => false],
|
||||
['id' => 'effect', 'type' => 'select', 'label' => '切换动画', 'default' => 'slide', 'options' => ['slide' => '滑动', 'fade' => '淡出淡入', 'cube' => '3D方块', 'coverflow' => '3D滑入', 'flip' => '3D翻转']],
|
||||
['id' => 'scale_height', 'type' => 'switcher', 'label' => '按比例自动高度', 'default' => true, 'dependency' => ['direction', '!=', 'vertical']],
|
||||
['id' => 'scale', 'type' => 'spinner', 'label' => '长宽比例', 'default' => 35, 'min' => 10, 'max' => 300, 'step' => 5, 'dependency' => ['direction|scale_height', '!=|!=', 'vertical|']],
|
||||
['id' => 'auto_height', 'type' => 'switcher', 'label' => '自动高度', 'default' => false, 'dependency' => ['direction|scale_height', '!=|==', 'vertical|']],
|
||||
['id' => 'max_height', 'type' => 'spinner', 'label' => '最大高度', 'default' => 500, 'min' => 120, 'max' => 800, 'step' => 20, 'dependency' => ['auto_height', '!=', '']],
|
||||
['id' => 'min_height', 'type' => 'spinner', 'label' => '最小高度', 'default' => 180, 'min' => 100, 'max' => 500, 'step' => 20, 'dependency' => ['auto_height', '!=', '']],
|
||||
['id' => 'pc_height', 'type' => 'spinner', 'label' => '电脑端高度', 'default' => 400, 'min' => 120, 'max' => 800, 'step' => 20],
|
||||
['id' => 'm_height', 'type' => 'spinner', 'label' => '移动端高度', 'default' => 200, 'min' => 100, 'max' => 500, 'step' => 20],
|
||||
['id' => 'spacebetween', 'type' => 'spinner', 'label' => '幻灯片间距', 'default' => 15, 'min' => 0, 'max' => 500, 'step' => 5],
|
||||
['id' => 'speed', 'type' => 'spinner', 'label' => '切换速度', 'default' => 0, 'min' => 0, 'max' => 3000, 'step' => 100],
|
||||
['id' => 'autoplay', 'type' => 'switcher', 'label' => '自动播放', 'default' => true],
|
||||
['id' => 'interval', 'type' => 'spinner', 'label' => '停顿时间', 'default' => 4, 'min' => 0, 'max' => 20, 'dependency' => ['autoplay', '!=', '']],
|
||||
]],
|
||||
];
|
||||
if ($slug === 'slider_media_combo') {
|
||||
$fields[] = ['id' => 'side_cards', 'type' => 'group', 'label' => '右侧图文视频卡片', 'max_items' => 6, 'fields' => self::media_card_fields()];
|
||||
$combo_slides = [
|
||||
['background' => $asset_uri . 'slider-bg.jpg', 'text' => ['title' => '更优雅的 WordPress 主题:AKSRT', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_m' => 16, 'text_size_pc' => 24, 'parallax' => 0]],
|
||||
['background' => $asset_uri . 'slider-bg.jpg', 'text' => ['title' => '更优雅的 WordPress 主题 AKSRT', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_m' => 16, 'text_size_pc' => 24, 'parallax' => 0]],
|
||||
];
|
||||
$combo_option = [
|
||||
['id' => 'loop', 'type' => 'switcher', 'label' => '循环切换', 'default' => true],
|
||||
['id' => 'button', 'type' => 'switcher', 'label' => '显示翻页按钮', 'default' => true],
|
||||
['id' => 'pagination', 'type' => 'switcher', 'label' => '显示指示器', 'default' => true],
|
||||
['id' => 'effect', 'type' => 'select', 'label' => '切换动画', 'default' => 'slide', 'options' => ['slide' => '滑动', 'fade' => '淡出淡入', 'cube' => '3D方块', 'coverflow' => '3D滑入', 'flip' => '3D翻转']],
|
||||
['id' => 'spacebetween', 'type' => 'spinner', 'label' => '幻灯片间距', 'default' => 20, 'min' => 0, 'max' => 500, 'step' => 5],
|
||||
['id' => 'speed', 'type' => 'spinner', 'label' => '切换速度', 'default' => 0, 'min' => 0, 'max' => 3000, 'step' => 100],
|
||||
['id' => 'autoplay', 'type' => 'switcher', 'label' => '自动播放', 'default' => true],
|
||||
['id' => 'interval', 'type' => 'spinner', 'label' => '停顿时间', 'default' => 4, 'min' => 0, 'max' => 20, 'dependency' => ['autoplay', '!=', '']],
|
||||
];
|
||||
$fields = [
|
||||
['id' => 'layout_ratio', 'type' => 'slider', 'label' => '幻灯片宽度占比', 'default' => 60, 'min' => 0, 'max' => 100],
|
||||
['id' => 'slide_scale', 'type' => 'spinner', 'label' => '幻灯片长宽比', 'default' => 50, 'min' => 0, 'max' => 500, 'step' => 5],
|
||||
['id' => 'pc_row', 'type' => 'button_set', 'label' => '右侧卡片列数', 'default' => 2, 'options' => [1 => '1列', 2 => '2列', 3 => '3列', 4 => '4列']],
|
||||
['id' => 'pc_col', 'type' => 'button_set', 'label' => '右侧卡片行数', 'default' => 2, 'options' => [1 => '1行', 2 => '2行', 3 => '3行', 4 => '4行']],
|
||||
['id' => 'm_layout_type', 'type' => 'radio', 'label' => '移动端布局方式', 'default' => 'vertical', 'options' => ['default' => '保持PC端布局', 'vertical' => '上下布局', 'hide_slide' => '隐藏幻灯片', 'hide_cover' => '隐藏卡片']],
|
||||
['id' => 'm_row', 'type' => 'button_set', 'label' => '移动端卡片单行数量', 'default' => 2, 'dependency' => ['m_layout_type', 'any', 'hide_slide,vertical'], 'options' => [1 => '1个', 2 => '2个', 3 => '3个', 4 => '4个', 6 => '6个']],
|
||||
['id' => 'm_cover_ratio', 'type' => 'spinner', 'label' => '移动端卡片长宽比', 'default' => 45, 'min' => 5, 'max' => 300, 'step' => 5, 'dependency' => ['m_layout_type', 'any', 'hide_slide,vertical']],
|
||||
['id' => 'slides', 'type' => 'group', 'label' => '幻灯片内容', 'max_items' => 30, 'min_items' => 1, 'default' => $combo_slides, 'fields' => $slide_fields],
|
||||
['id' => 'option', 'type' => 'accordion', 'label' => '幻灯片设置', 'default' => ['button' => true, 'pagination' => true, 'effect' => 'slide', 'spacebetween' => 20, 'speed' => 0, 'interval' => 4, 'autoplay' => true, 'loop' => true], 'fields' => $combo_option],
|
||||
['id' => 'covers', 'type' => 'group', 'label' => '右侧图文视频卡片', 'max_items' => 30, 'default' => array_fill(0, 4, ['image' => $asset_uri . 'user_t.jpg', 'title' => '']), 'fields' => [
|
||||
['id' => 'image', 'type' => 'upload', 'label' => '图片背景', 'default' => '', 'library' => 'image'], ['id' => 'video', 'type' => 'upload', 'label' => '视频背景', 'default' => '', 'library' => 'video'], ['id' => 'hide', 'type' => 'radio', 'label' => '显示规则', 'default' => '', 'options' => ['' => '全部显示', 'pc' => 'PC端不显示', 'm' => '移动端不显示']], ['id' => 'title', 'type' => 'textarea', 'label' => '文字', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1]], ['id' => 'link', 'type' => 'link', 'label' => '跳转链接', 'default' => []],
|
||||
]],
|
||||
['id' => 'mask_opacity', 'type' => 'slider', 'label' => '遮罩透明度', 'default' => 0, 'min' => 0, 'max' => 90], ['id' => 'font_size_pc', 'type' => 'spinner', 'label' => 'PC端字体大小', 'default' => 16, 'min' => 10, 'max' => 80, 'step' => 2], ['id' => 'font_size_m', 'type' => 'spinner', 'label' => '移动端字体大小', 'default' => 14, 'min' => 10, 'max' => 80, 'step' => 2], ['id' => 'font_bold', 'type' => 'switcher', 'label' => '粗体显示', 'default' => false], ['id' => 'font_color', 'type' => 'color', 'label' => '文字颜色', 'default' => ''],
|
||||
];
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user