'theme', 'type' => 'palette', 'label' => '色彩主题', 'default' => 'jb-red', 'options' => CommonFields::palette()],
];
}
if (in_array($slug, ['pricing_plans', 'reviews', 'faq', 'stats', 'highlights', 'feature_intro', 'tilt_cases'], true)) {
return self::knowledge_product($slug);
}
if (in_array($slug, ['slider', 'slider_media_combo'], true)) {
return self::slider($slug);
}
if (in_array($slug, ['user_card', 'author_card', 'user_ranking', 'user_list'], true)) {
return self::user($slug);
}
return self::general($slug);
}
private static function general(string $slug): array {
switch ($slug) {
case 'search':
return [
['id' => 'placeholder', 'type' => 'text', 'label' => '提示文字', 'default' => '输入关键词搜索'],
['id' => 'search_style', 'type' => 'radio', 'label' => '显示样式', 'default' => 'button', 'options' => ['button' => '按钮式', 'compact' => '紧凑式', 'large' => '大尺寸']],
];
case 'posts_toc':
return [
['id' => 'title', 'type' => 'text', 'label' => '标题', 'default' => '文章目录'],
['id' => 'mini_title', 'type' => 'text', 'label' => '副标题', 'default' => ''],
['id' => 'in_affix', 'type' => 'switcher', 'label' => '侧栏随动(仅在侧边栏有效)', 'default' => false],
];
case 'quote':
return [
['id' => 'source', 'type' => 'select', 'label' => '内容来源', 'default' => 'local', 'options' => ['local' => '本地句子', 'api' => '在线一言']],
['id' => 'quotes', 'type' => 'textarea', 'label' => '本地句子', 'description' => '每行一句', 'default' => "保持好奇,持续创造。\n知识因为分享而更有价值。"],
['id' => 'interval', 'type' => 'spinner', 'label' => '自动更新间隔(秒)', 'default' => 30, 'min' => 5, 'max' => 300],
];
case 'video':
return [
['id' => 'url', 'type' => 'upload', 'label' => '视频地址', 'default' => ''],
['id' => 'poster', 'type' => 'upload', 'label' => '视频封面', 'default' => ''],
['id' => 'autoplay', 'type' => 'switcher', 'label' => '自动播放', 'default' => false],
['id' => 'muted', 'type' => 'switcher', 'label' => '静音', 'default' => false],
['id' => 'ratio', 'type' => 'select', 'label' => '长宽比例', 'default' => '16:9', 'options' => ['16:9' => '16:9', '4:3' => '4:3', '1:1' => '1:1', 'auto' => '自适应']],
];
case 'embed':
return [
['id' => 'url', 'type' => 'upload', 'label' => '嵌入地址', 'default' => ''],
['id' => 'ratio', 'type' => 'slider', 'label' => '高度比例(%)', 'default' => 56.25, 'min' => 20, 'max' => 200, 'step' => 0.25],
['id' => 'allow_fullscreen', 'type' => 'switcher', 'label' => '允许全屏', 'default' => true],
];
case 'layout_gap':
return [
['id' => 'pc_gap', 'type' => 'slider', 'label' => 'PC 端间隔', 'default' => 20, 'min' => 0, 'max' => 300],
['id' => 'm_gap', 'type' => 'slider', 'label' => '移动端间隔', 'default' => 10, 'min' => 0, 'max' => 200],
];
case 'tag_cloud':
return [
['id' => 'taxonomy', 'type' => 'select', 'label' => '分类法', 'default' => 'post_tag', 'options' => ['post_tag' => '标签', 'category' => '分类']],
['id' => 'number', 'type' => 'spinner', 'label' => '数量', 'default' => 20, 'min' => 1, 'max' => 100],
['id' => 'orderby', 'type' => 'select', 'label' => '排序', 'default' => 'count', 'options' => ['count' => '内容数量', 'name' => '名称', 'term_id' => 'ID', 'rand' => '随机']],
['id' => 'show_count', 'type' => 'switcher', 'label' => '显示数量', 'default' => false],
];
case 'recent_comments':
return [
['id' => 'limit', 'type' => 'spinner', 'label' => '显示数量', 'default' => 8, 'min' => 1, 'max' => 50, 'step' => 1],
['id' => 'outer', 'type' => 'text', 'label' => '排除用户ID', 'default' => '', 'sanitize' => 'ids', 'description' => '填写需要排除的用户ID,用逗号分割,例如:55,66,100'],
['id' => 'outpost', 'type' => 'text', 'label' => '排除文章ID', 'default' => '', 'sanitize' => 'ids', 'description' => '填写需要排除的文章ID,用逗号分割,例如:55,66,100'],
['id' => 'show_source', 'type' => 'switcher', 'label' => '显示来源', 'default' => false],
['id' => 'style', 'type' => 'radio', 'label' => '显示样式', 'default' => '', 'options' => ['' => '简约', 'style_2' => '风格2']],
];
case 'links':
return [
['id' => 'style', 'type' => 'button_set', 'label' => '样式', 'default' => 'card', 'options' => ['card' => '卡片', 'bigcard' => '大卡片', 'image' => '图片', 'simple' => '简约']],
['id' => 'limit', 'type' => 'spinner', 'label' => '最大数量', 'default' => 12, 'min' => 1, 'max' => 100],
['id' => 'links', 'type' => 'group', 'label' => '链接列表', 'max_items' => 100, 'fields' => self::card_fields(true)],
];
case 'notice':
return [
['id' => 'blank', 'type' => 'switcher', 'label' => '链接新窗口打开', 'default' => false],
['id' => 'radius', 'type' => 'switcher', 'label' => '两边显示为圆形', 'default' => false],
['id' => 'interval', 'type' => 'spinner', 'label' => '滚动间隔', 'default' => 3, 'min' => 1, 'max' => 10, 'step' => 1, 'unit' => '秒'],
['id' => 'color', 'type' => 'palette', 'label' => '颜色', 'default' => 'c-blue', 'options' => self::zib_palette()],
['id' => 'source', 'type' => 'radio', 'label' => '内容来源', 'default' => '', 'options' => ['' => '自定义', 'posts' => '文章']],
['id' => 'msg_icon', 'type' => 'icon', 'label' => '消息图标', 'default' => 'zibsvg-hot', 'dependency' => ['source', '!=', '']],
['id' => 'count', 'type' => 'spinner', 'label' => '获取文章数量', 'default' => 8, 'min' => 1, 'max' => 50, 'dependency' => ['source', '!=', '']],
['id' => 'desc_s', 'type' => 'switcher', 'label' => '显示简介(关闭则只显示标题)', 'default' => false],
['id' => 'posts_opts', 'type' => 'fieldset', 'label' => '文章筛选', 'default' => [], 'dependency' => ['source', '==', 'posts'], 'fields' => self::notice_post_fields()],
[
'id' => 'img_ids', 'type' => 'group', 'label' => '消息列表', 'max_items' => 50,
'dependency' => ['source', '==', ''],
'default' => [
['title' => '子比主题,更优雅的Wordpress主题', 'icon' => 'zibsvg-hot', 'href' => 'https://zibll.com'],
['title' => '更优雅的WordPress网站主题:子比主题!全面开启', 'icon' => 'zibsvg-hot', 'href' => 'https://zibll.com'],
],
'fields' => [
['id' => 'title', 'type' => 'text', 'label' => '消息内容', 'default' => '', 'allow_html' => true],
['id' => 'icon', 'type' => 'icon', 'label' => '图标', 'default' => 'fa-home'],
['id' => 'href', 'type' => 'text', 'label' => '跳转链接', 'default' => '', 'sanitize' => 'url'],
],
],
];
case 'text_title':
return [
['id' => 'heading', 'type' => 'textarea', 'label' => '标题', 'default' => ''],
['id' => 'description', 'type' => 'textarea', 'label' => '简介', 'default' => ''],
['id' => 'alignment', 'type' => 'button_set', 'label' => '对齐', 'default' => 'center', 'options' => ['left' => '左', 'center' => '中', 'right' => '右']],
];
case 'buttons':
return [
['id' => 'obs_animation', 'type' => 'select', 'label' => '入场动画', 'default' => '', 'options' => self::animation_options()],
['id' => 'animation_repeat', 'type' => 'switcher', 'label' => '重复动画', 'default' => false, 'dependency' => ['obs_animation', '!=', '']],
['id' => 'pc_width', 'type' => 'spinner', 'label' => '按钮宽度(PC端宽度,0为自动)', 'default' => 0, 'min' => 0, 'max' => 500, 'step' => 4, 'unit' => 'px'],
['id' => 'm_width', 'type' => 'spinner', 'label' => '移动端宽度(0为自动)', 'default' => 0, 'min' => 0, 'max' => 500, 'step' => 4, 'unit' => 'px'],
['id' => 'pc_padding', 'type' => 'radio', 'label' => 'PC端按钮尺寸', 'default' => 'large', 'options' => ['small' => '小尺寸', 'medium' => '中尺寸', 'large' => '大尺寸']],
['id' => 'm_padding', 'type' => 'radio', 'label' => '移动端按钮尺寸', 'default' => 'medium', 'options' => ['small' => '小尺寸', 'medium' => '中尺寸', 'large' => '大尺寸']],
['id' => 'pc_gap', 'type' => 'spinner', 'label' => 'PC端按钮间距', 'default' => 12, 'min' => 0, 'max' => 60, 'step' => 4, 'unit' => 'px'],
['id' => 'm_gap', 'type' => 'spinner', 'label' => '移动端按钮间距', 'default' => 6, 'min' => 0, 'max' => 60, 'step' => 4, 'unit' => 'px'],
['id' => 'align', 'type' => 'radio', 'label' => '对齐方式', 'default' => 'center', 'options' => ['left' => '左对齐', 'center' => '居中', 'right' => '右对齐']],
['id' => 'radius', 'type' => 'switcher', 'label' => '两端圆角', 'default' => false],
['id' => 'hollow', 'type' => 'switcher', 'label' => '空心样式', 'default' => false],
['id' => 'go_link', 'type' => 'switcher', 'label' => '外链重定向', 'default' => true],
['id' => 'items', 'type' => 'group', 'label' => '添加按钮', 'max_items' => 50, 'default' => [], 'fields' => [
['id' => 'text', 'type' => 'text', 'label' => '按钮文字', 'default' => '', 'allow_html' => true],
['id' => 'icon_left', 'type' => 'icon', 'label' => '按钮前图标', 'default' => ''],
['id' => 'icon_right', 'type' => 'icon', 'label' => '按钮后图标', 'default' => ''],
['id' => 'link', 'type' => 'link', 'label' => '按钮链接', 'default' => []],
['id' => 'color', 'type' => 'palette', 'label' => '按钮颜色', 'default' => '', 'options' => self::button_palette()],
]],
];
case 'partners':
return [
['id' => 'rows', 'type' => 'button_set', 'label' => 'PC端显示几行滚动', 'default' => 3, 'options' => [1 => '1行', 2 => '2行', 3 => '3行', 4 => '4行', 5 => '5行', 6 => '6行']],
['id' => 'm_rows', 'type' => 'button_set', 'label' => '移动端显示几行滚动', 'default' => 3, 'options' => [1 => '1行', 2 => '2行', 3 => '3行', 4 => '4行', 5 => '5行', 6 => '6行']],
['id' => 'style_type', 'type' => 'radio', 'label' => '选择合作伙伴卡片的呈现方式', 'default' => 'card', 'options' => ['card' => '图文卡片(适合正方形logo)', 'logo' => '纯 Logo', 'chip' => '精简胶囊']],
['id' => 'card_width', 'type' => 'spinner', 'label' => '单卡片宽度', 'default' => 200, 'min' => 80, 'max' => 500, 'step' => 10, 'unit' => 'px', 'dependency' => ['style_type', '==', 'card'], 'description' => 'PC端每张卡片的宽度(纯 Logo 模式下宽度会自适应图片,此项不生效)'],
['id' => 'card_height', 'type' => 'spinner', 'label' => '卡片高度', 'default' => 60, 'min' => 50, 'max' => 260, 'step' => 5, 'unit' => 'px', 'dependency' => ['style_type', '!=', 'chip'], 'description' => '每张卡片的高度,纯 Logo 模式建议 70-120'],
['id' => 'card_bg', 'type' => 'switcher', 'label' => '显示每张合作伙伴卡片的背景', 'default' => true],
['id' => 'card_radius', 'type' => 'slider', 'label' => '卡片圆角', 'default' => 16, 'min' => 0, 'max' => 60, 'step' => 1, 'unit' => 'px', 'dependency' => ['card_bg', '!=', '']],
['id' => 'speed', 'type' => 'slider', 'label' => '滚动速度(数越小越快)', 'default' => 3, 'min' => 0.1, 'max' => 10, 'step' => 0.1, 'unit' => 's'],
['id' => 'direction', 'type' => 'radio', 'label' => '滚动方向', 'default' => 'alternate', 'options' => ['alternate' => '奇数行左,偶数行右', 'left' => '全部向左', 'right' => '全部向右']],
['id' => 'pause_hover', 'type' => 'switcher', 'label' => '鼠标悬停暂停', 'default' => true],
['id' => 'show_widget_bg', 'type' => 'switcher', 'label' => '模块背景', 'default' => false, 'description' => '显示整个模块外层背景'],
['id' => 'go_link', 'type' => 'switcher', 'label' => '外链重定向', 'default' => true, 'description' => '开启后,将链接转为内部go跳转链接'],
['id' => 'end_fade', 'type' => 'switcher', 'label' => '两端渐隐', 'default' => true, 'description' => '开启后,卡片两端会渐隐,使卡片无缝连接'],
['id' => 'link_type', 'type' => 'radio', 'label' => '合作伙伴获取方式', 'default' => 'link', 'options' => ['link' => '通过链接获取', 'manual' => '手动添加']],
['id' => 'link_cats', 'type' => 'terms', 'label' => '选择链接分类', 'taxonomy' => 'link_category', 'default' => [], 'dependency' => ['link_type', '==', 'link'], 'description' => '需显示的链接分类,留空则为全部'],
['id' => 'link_limit', 'type' => 'spinner', 'label' => '最大获取数量', 'default' => 50, 'min' => 0, 'step' => 5, 'unit' => '个', 'dependency' => ['link_type', '==', 'link']],
['id' => 'link_orderby', 'type' => 'select', 'label' => '排序方式', 'default' => 'name', 'dependency' => ['link_type', '==', 'link'], 'options' => ['name' => '名称排序', 'updated' => '更新时间', 'rating' => '链接评分', 'rand' => '随机排序']],
['id' => 'page_links_order', 'type' => 'radio', 'label' => '顺序', 'default' => 'ASC', 'dependency' => ['link_type', '==', 'link'], 'options' => ['ASC' => '升序', 'DESC' => '降序']],
[
'id' => 'partners', 'type' => 'group', 'label' => '添加合作伙伴', 'item_label' => '合作伙伴', 'max_items' => 60, 'dependency' => ['link_type', '==', 'manual'],
'default' => [],
'fields' => [
['id' => 'title', 'type' => 'textarea', 'label' => '名称', 'default' => '', 'attributes' => ['rows' => 1], 'description' => '卡片第一行文案,建议简短'],
['id' => 'desc', 'type' => 'textarea', 'label' => '简介', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 2], 'description' => '卡片第二行文案,支持 HTML(仅在图文卡片模式下显示)'],
['id' => 'image', 'type' => 'upload', 'label' => 'Logo图片', 'default' => '', 'library' => 'image', 'description' => '如果样式选择为图文卡片,则建议全部为正方形图片'],
['id' => 'link', 'type' => 'link', 'label' => '链接', 'default' => []],
],
],
];
case 'combo_info':
return array_merge(self::obs_animation_fields(), [
['id' => 'pc_row', 'type' => 'button_set', 'label' => 'PC端单行排列数量', 'default' => 4, 'options' => [2 => '2个', 3 => '3个', 4 => '4个', 6 => '6个']],
['id' => 'm_row', 'type' => 'button_set', 'label' => '移动端单行排列数量', 'default' => 1, 'options' => [1 => '1个', 2 => '2个']],
['id' => 'pc_gap', 'type' => 'button_set', 'label' => 'PC端卡片间距', 'default' => 10, 'options' => [5 => '10px', 10 => '20px']],
['id' => 'm_gap', 'type' => 'button_set', 'label' => '移动端卡片间距', 'default' => 5, 'options' => [5 => '10px', 10 => '20px']],
['id' => 'card_radius', 'type' => 'slider', 'label' => '卡片圆角', 'default' => 16, 'min' => 0, 'max' => 30, 'step' => 1, 'unit' => 'px'],
['id' => 'top_band', 'type' => 'switcher', 'label' => '显示顶部渐变背景', 'default' => true],
['id' => 'top_band_height', 'type' => 'slider', 'label' => '色带高度', 'default' => 150, 'min' => 100, 'max' => 400, 'step' => 20, 'unit' => 'px', 'dependency' => ['top_band', '==', '1']],
['id' => 'go_link', 'type' => 'switcher', 'label' => '外链重定向', 'default' => true, 'description' => '开启后,将链接转为内部go跳转链接'],
['id' => 'cta_text', 'type' => 'text', 'label' => '默认按钮文案', 'default' => '立即体验', 'description' => '每张卡片可单独覆盖'],
['id' => 'cta_color', 'type' => 'palette', 'label' => '默认按钮颜色', 'default' => '', 'options' => self::cta_palette()],
['id' => 'cards', 'type' => 'group', 'label' => '添加卡片', 'item_label' => '卡片', 'max_items' => 30, 'default' => [], 'fields' => [
['id' => 'title', 'type' => 'textarea', 'label' => '卡片标题', 'default' => '', 'attributes' => ['rows' => 1]],
['id' => 'icon', 'type' => 'icon', 'label' => '图标', 'default' => ''],
['id' => 'icon_image', 'type' => 'upload', 'label' => '图片图标', 'default' => '', 'library' => 'image', 'description' => '图标和图片图标二选一,设置图片将覆盖图标'],
[
'id' => 'tags', 'type' => 'group', 'label' => '标签', 'item_label' => '标签', 'max_items' => 20, 'default' => [],
'fields' => [
['id' => 'text', 'type' => 'text', 'label' => '标签文字', 'default' => ''],
['id' => 'color', 'type' => 'palette', 'label' => '标签颜色', 'default' => '', 'options' => self::tag_palette()],
],
],
['id' => 'desc', 'type' => 'textarea', 'label' => '简介描述', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 3], 'description' => '卡片描述文案,超出会自动省略(默认3行)'],
['id' => 'link', 'type' => 'link', 'label' => '链接', 'default' => []],
['id' => 'cta_text', 'type' => 'text', 'label' => '按钮文案(可选)', 'default' => '', 'description' => '留空则使用默认按钮文案'],
['id' => 'cta_color', 'type' => 'palette', 'label' => '按钮颜色(可选)', 'default' => '', 'options' => self::cta_palette()],
['id' => 'band_color', 'type' => 'select', 'label' => '顶部色带配色', 'default' => 'auto', 'options' => ['auto' => '自动(按序循环)', 'blue' => '蓝紫', 'cyan' => '青蓝', 'green' => '青绿', 'yellow' => '橙黄', 'pink' => '粉红', 'purple' => '紫罗兰', 'gray' => '中性灰']],
]],
]);
case 'media_cards':
return array_merge(self::obs_animation_fields(), [
['id' => 'pc_row', 'type' => 'button_set', 'label' => 'PC端单行排列数量', 'default' => 4, 'options' => self::row_options()],
['id' => 'm_row', 'type' => 'button_set', 'label' => '移动端单行排列数量', 'default' => 2, 'options' => self::row_options(), 'description' => '请根据此模块放置位置的宽度合理调整单行数量,避免显示不佳'],
['id' => 'mask_opacity', 'type' => 'slider', 'label' => '遮罩透明度', 'default' => 10, 'min' => 0, 'max' => 90, 'step' => 1, 'unit' => '%', 'description' => '图片上显示的黑色遮罩层的透明度'],
['id' => 'height_scale', 'type' => 'spinner', 'label' => '封面长宽比例', 'default' => 30, 'min' => 5, 'max' => 300, 'step' => 5, 'unit' => '%'],
['id' => 'font_size_pc', 'type' => 'spinner', 'label' => 'PC端字体大小', 'default' => 18, 'min' => 10, 'max' => 80, 'step' => 2, 'unit' => 'px'],
['id' => 'font_size_m', 'type' => 'spinner', 'label' => '移动端字体大小', 'default' => 14, 'min' => 10, 'max' => 80, 'step' => 2, 'unit' => 'px'],
['id' => 'font_bold', 'type' => 'switcher', 'label' => '粗体显示', 'default' => false],
['id' => 'font_color', 'type' => 'color', 'label' => '文字颜色', 'default' => ''],
['id' => 'covers', 'type' => 'group', 'label' => '添加封面', 'item_label' => '内容', 'max_items' => 40, 'default' => [], 'fields' => self::cover_fields(), 'description' => '
由于移动端多数浏览器不支持视频背景功能,所以移动端不会显示视频!
'],
]);
case 'icon_cards':
return self::icon_cards_fields();
case 'icon_cover_cards':
return self::icon_cover_cards_fields();
default:
return [['id' => 'cards', 'type' => 'group', 'label' => '卡片', 'max_items' => 40, 'fields' => self::media_card_fields()]];
}
}
private static function content(string $slug): array {
switch ($slug) {
case 'posts':
return self::posts_fields();
case 'tab_posts':
return self::tab_posts_fields();
case 'oneline_posts':
return self::oneline_posts_fields();
case 'hot_posts':
return self::hot_posts_fields();
case 'term_cards':
return self::term_cards_fields();
case 'term_aggregation':
return self::term_aggregation_fields();
}
return [];
}
private static function posts_fields(): array {
return [
['id' => 'load_mode', 'type' => 'radio', 'label' => '模块加载方式', 'default' => 'ajax', 'options' => ['detail' => '直接加载', 'ajax' => 'ajax懒加载'], 'description' => 'ajax懒加载:当页面加载完后,根据用户需要在加载当前模块内容,可提高页面渲染效率'],
['id' => 'cat', 'type' => 'text', 'label' => '分类限制', 'default' => '', 'sanitize' => 'reference_ids', 'description' => '限制请填写对应的ID,多个ID请用英文逗号隔开。如:1,2,3。支持负数进行排除,例如:-1,-2,-3。'],
['id' => 'zibpay_type', 'type' => 'checkbox', 'label' => '商品类型筛选', 'default' => [], 'options' => self::pay_types(), 'description' => '不做其它筛选'],
['id' => 'limit_day', 'type' => 'spinner', 'label' => '发布时间限制', 'default' => 0, 'min' => 0, 'step' => 5, 'unit' => '天', 'description' => '仅显示最近多少天发布的文章,为0则不限制'],
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => '', 'options' => self::posts_orderby()],
['id' => 'order', 'type' => 'radio', 'label' => '顺序', 'default' => 'desc', 'options' => ['desc' => '降序', 'asc' => '升序']],
['id' => 'style', 'type' => 'radio', 'label' => '列表样式', 'default' => 'list', 'options' => ['list' => '列表样式', 'card' => '卡片样式', 'mini' => 'mini列表'], 'description' => '注意:不同样式尺寸不同,请根据放置的位置合理选择。例如:放在宽度较小的侧边栏,则需选择mini样式,否则显示效果不佳
'],
['id' => 'mini_opt', 'type' => 'checkbox', 'label' => 'mini列表配置', 'default' => [], 'dependency' => ['style', '==', 'mini'], 'options' => self::mini_opt_options(), 'description' => '不做其它筛选'],
['id' => 'count', 'type' => 'spinner', 'label' => '显示数量', 'default' => 12, 'min' => 4, 'max' => 20, 'step' => 1, 'unit' => '篇'],
['id' => 'paginate', 'type' => 'radio', 'label' => '翻页按钮', 'default' => '', 'options' => ['' => '不翻页', 'ajax' => 'AJAX追加列表翻页', 'number' => '数字翻页按钮']],
];
}
private static function tab_posts_fields(): array {
return [
['id' => 'style', 'type' => 'radio', 'label' => '列表样式', 'default' => 'mini', 'options' => ['list' => '列表样式', 'card' => '卡片样式', 'mini' => 'mini列表'], 'description' => '注意:不同样式尺寸不同,请根据放置的位置合理选择。例如:放在宽度较小的侧边栏,则需选择mini样式,否则显示效果不佳
'],
['id' => 'mini_opt', 'type' => 'checkbox', 'label' => 'mini列表配置', 'default' => [], 'dependency' => ['style', '==', 'mini'], 'options' => self::mini_opt_options(), 'description' => '不做其它筛选'],
['id' => 'count', 'type' => 'spinner', 'label' => '显示数量', 'default' => 6, 'min' => 4, 'max' => 20, 'step' => 1, 'unit' => '篇'],
['id' => 'paginate', 'type' => 'radio', 'label' => '翻页按钮', 'default' => '', 'options' => ['' => '不翻页', 'ajax' => 'AJAX追加列表翻页', 'number' => '数字翻页按钮']],
[
'id' => 'tabs', 'type' => 'group', 'label' => '栏目', 'max_items' => 10, 'item_label' => '栏目',
'default' => [
['title' => '热门推荐', 'orderby' => 'views'],
['title' => '最近更新', 'orderby' => 'modified'],
['title' => '猜你喜欢', 'orderby' => 'rand'],
],
'fields' => [
['id' => 'title', 'type' => 'textarea', 'label' => '标题(必填)', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1], 'description' => '栏目显示的标题,支持HTML代码,注意代码规范'],
['id' => 'cat', 'type' => 'text', 'label' => '分类限制', 'default' => '', 'sanitize' => 'reference_ids'],
['id' => 'zibpay_type', 'type' => 'checkbox', 'label' => '商品类型筛选', 'default' => [], 'options' => self::pay_types(), 'description' => '不做其它筛选'],
['id' => 'limit_day', 'type' => 'spinner', 'label' => '发布时间限制', 'default' => 0, 'min' => 0, 'step' => 5, 'unit' => '天', 'description' => '仅显示最近多少天发布的文章,为0则不限制'],
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => '', 'options' => self::posts_orderby()],
['id' => 'order', 'type' => 'radio', 'label' => '顺序', 'default' => 'desc', 'options' => ['desc' => '降序', 'asc' => '升序']],
],
],
];
}
private static function oneline_posts_fields(): array {
return [
['id' => 'cat', 'type' => 'text', 'label' => '分类限制', 'default' => '', 'sanitize' => 'reference_ids', 'description' => '限制请填写对应的ID,多个ID请用英文逗号隔开。如:1,2,3。支持负数进行排除,例如:-1,-2,-3。'],
['id' => 'zibpay_type', 'type' => 'checkbox', 'label' => '商品类型筛选', 'default' => [], 'options' => self::pay_types(), 'description' => '不做其它筛选'],
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => '', 'options' => self::posts_orderby()],
['id' => 'order', 'type' => 'radio', 'label' => '顺序', 'default' => 'desc', 'options' => ['desc' => '降序', 'asc' => '升序']],
['id' => 'style', 'type' => 'radio', 'label' => '列表样式', 'default' => 'card', 'options' => ['list' => '列表样式', 'card' => '卡片样式', 'mini' => 'mini列表'], 'description' => '注意:不同样式尺寸不同,请根据放置的位置合理选择。例如:放在宽度较小的侧边栏,则需选择mini样式,否则显示效果不佳
'],
['id' => 'count', 'type' => 'spinner', 'label' => '显示数量', 'default' => 12, 'min' => 4, 'max' => 20, 'step' => 1, 'unit' => '篇'],
];
}
private static function hot_posts_fields(): array {
return [
['id' => 'orderby', 'type' => 'radio', 'label' => '榜单类型', 'default' => 'views', 'options' => [
'views' => '热门榜单(按阅读量排序)',
'like' => '超赞榜单(按点赞量排序)',
'comment_count' => '话题榜单(按评论量排序)',
'favorite' => '收藏榜单(按收藏量排序)',
]],
['id' => 'limit_day', 'type' => 'spinner', 'label' => '限制时间(最近X天)', 'default' => 0, 'min' => 0, 'max' => 999999, 'step' => 1, 'unit' => '天', 'description' => '设置多少天内发布的文章有效,为0则不限制时间'],
['id' => 'count', 'type' => 'spinner', 'label' => '最大显示数量', 'default' => 6, 'min' => 1, 'max' => 20, 'step' => 1, 'unit' => '篇'],
['id' => 'target_blank', 'type' => 'switcher', 'label' => '新窗口打开', 'default' => false],
];
}
private static function term_cards_fields(): array {
return array_merge(self::obs_animation_fields(), [
['id' => 'term_id', 'type' => 'terms', 'label' => '添加分类', 'taxonomy' => 'category', 'default' => [], 'description' => '选择并排序需要的分类,如选择的分类下没有封面则不会显示'],
['id' => 'type', 'type' => 'radio', 'label' => '卡片样式', 'default' => 'style-1', 'options' => ['style-1' => '简单样式', 'style-2' => '样式二', 'style-3' => '样式三', 'style-4' => '样式四']],
['id' => 'height_scale', 'type' => 'spinner', 'label' => '卡片长宽比例', 'default' => 60, 'min' => 20, 'max' => 300, 'step' => 5, 'unit' => '%'],
['id' => 'pc_row', 'type' => 'button_set', 'label' => 'PC端单行排列数量', 'default' => 2, 'options' => self::row_options()],
['id' => 'm_row', 'type' => 'button_set', 'label' => '移动端单行排列数量', 'default' => 2, 'options' => self::row_options(), 'description' => '请根据此模块放置位置的宽度合理调整单行数量,避免显示不佳'],
['id' => 'mask_opacity', 'type' => 'slider', 'label' => '遮罩透明度', 'default' => 10, 'min' => 0, 'max' => 90, 'step' => 1, 'unit' => '%', 'description' => '图片上显示的黑色遮罩层的透明度'],
['id' => 'target_blank', 'type' => 'switcher', 'label' => '新窗口打开', 'default' => false],
]);
}
private static function term_aggregation_fields(): array {
return array_merge(self::obs_animation_fields(), [
['id' => 'pc_row', 'type' => 'slider', 'label' => '单行布局', 'default' => 2, 'min' => 1, 'max' => 2, 'step' => 1, 'unit' => '个', 'description' => '请根据此模块放置位置的宽度合理调整单行数量'],
['id' => 'term_id', 'type' => 'terms', 'label' => '添加分类', 'taxonomy' => 'category', 'default' => [], 'description' => '选择并排序需要的分类,如选择的分类下没有文章则不会显示'],
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => 'modified', 'options' => self::posts_orderby(), 'dependency' => ['term_id', '!=', '']],
['id' => 'order', 'type' => 'radio', 'label' => '顺序', 'default' => 'desc', 'options' => ['desc' => '降序', 'asc' => '升序'], 'dependency' => ['term_id', '!=', '']],
['id' => 'count', 'type' => 'spinner', 'label' => '最大文章数量', 'default' => 4, 'min' => 1, 'max' => 20, 'step' => 1, 'unit' => '篇', 'dependency' => ['term_id', '!=', ''], 'description' => '请确保所选的分类内的文章数量均超过此数量,否则会出现布局错位的问题!
'],
['id' => 'target_blank', 'type' => 'switcher', 'label' => '新窗口打开', 'default' => false, 'dependency' => ['term_id', '!=', '']],
]);
}
private static function obs_animation_fields(): array {
return [
['id' => 'obs_animation', 'type' => 'select', 'label' => '入场动画', 'default' => '', 'options' => self::animation_options(), 'description' => '页面滚动到此模块时触发的入场动画[注意:需合理配置适当启用]'],
['id' => 'animation_repeat', 'type' => 'switcher', 'label' => '重复动画', 'default' => false, 'dependency' => ['obs_animation', '!=', ''], 'description' => '每次滚动到此模块都触发动画[注意:有性能消耗,部分老旧浏览器会有闪烁问题]'],
];
}
private static function row_options(): array {
return [1 => '1个', 2 => '2个', 3 => '3个', 4 => '4个', 6 => '6个', 12 => '12个'];
}
private static function mini_opt_options(): array {
return [
'show_thumb' => '显示缩略图',
'show_number' => '显示编号(开启翻页后,只在第一页有效)',
'show_meta' => '显示作者、时间、点赞等信息',
];
}
private static function posts_orderby(): array {
return [
'modified' => '更新时间',
'date' => '发布时间',
'views' => '浏览数量',
'like' => '点赞数量',
'comment_count' => '评论数量',
'favorite' => '收藏数量',
'rand' => '随机排序',
];
}
private static function knowledge_product(string $slug): array {
$base = [
['id' => 'pc_row', 'type' => 'spinner', 'label' => 'PC 单行数量', 'default' => 3, 'min' => 1, 'max' => 6],
['id' => 'm_row', 'type' => 'spinner', 'label' => '移动端单行数量', 'default' => 1, 'min' => 1, 'max' => 3],
];
if ($slug === 'pricing_plans') {
$base[] = ['id' => 'plans', 'type' => 'group', 'label' => '课程/会员方案', 'max_items' => 12, 'fields' => [
['id' => 'title', 'type' => 'text', 'label' => '方案名称', 'default' => ''],
['id' => 'price', 'type' => 'text', 'label' => '价格', 'default' => ''],
['id' => 'description', 'type' => 'textarea', 'label' => '简介', 'default' => ''],
['id' => 'features', 'type' => 'textarea', 'label' => '权益(每行一项)', 'default' => ''],
['id' => 'cta_type', 'type' => 'select', 'label' => '按钮类型', 'default' => 'link', 'options' => ['link' => '链接', 'post' => '付费文章', 'vip' => '会员方案']],
['id' => 'post_id', 'type' => 'number', 'label' => '文章 ID', 'default' => 0, 'min' => 0],
['id' => 'vip_level', 'type' => 'number', 'label' => '会员等级', 'default' => 1, 'min' => 1, 'max' => 20],
['id' => 'link', 'type' => 'link', 'label' => '按钮链接', 'default' => []],
['id' => 'featured', 'type' => 'switcher', 'label' => '推荐方案', 'default' => false],
]];
return $base;
}
if ($slug === 'faq') {
$base[] = ['id' => 'search', 'type' => 'switcher', 'label' => '显示搜索', 'default' => true];
$base[] = ['id' => 'items', 'type' => 'group', 'label' => '问答', 'max_items' => 60, 'fields' => [['id' => 'question', 'type' => 'text', 'label' => '问题', 'default' => ''], ['id' => 'answer', 'type' => 'textarea', 'label' => '回答', 'default' => '', 'allow_html' => true]]];
return $base;
}
$base[] = ['id' => 'items', 'type' => 'group', 'label' => '内容项', 'max_items' => 40, 'fields' => array_merge(self::media_card_fields(), [
['id' => 'value', 'type' => 'text', 'label' => '数值/徽标', 'default' => ''],
['id' => 'features', 'type' => 'textarea', 'label' => '特性', 'default' => ''],
['id' => 'rating', 'type' => 'slider', 'label' => '评分', 'default' => 5, 'min' => 1, 'max' => 5],
])];
return $base;
}
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' => '', 'library' => 'image'],
['id' => 'background_video', 'type' => 'upload', 'label' => '视频背景', 'default' => '', 'library' => 'video', 'description' => '(必填)图片背景、视频背景至少二选一,如果同时设置则PC端视频优先(PC端视频加载失败则显示图片)如果需要在移动端显示,则必须设置图片背景,移动端只显示图片
'],
['id' => 'hide', 'type' => 'radio', 'label' => '显示规则', 'default' => '', 'options' => ['' => '全部显示', 'pc' => 'PC端不显示', 'm' => '移动端不显示']],
['id' => 'link', 'type' => 'link', 'label' => '跳转链接', 'default' => []],
['id' => 'image_layer', 'type' => 'group', 'label' => '叠加图层', 'item_label' => '图层', 'button_title' => '添加图层', 'max_items' => 12, 'description' => '添加额外的幻灯片图层,配合图层设置及幻灯片其它设置,可轻松制作出漂亮无比的幻灯片', 'fields' => [
['id' => 'image', 'type' => 'upload', 'label' => '图层图片', 'default' => '', 'library' => 'image'],
['id' => 'free_size', 'type' => 'switcher', 'label' => '自由尺寸', 'default' => false, 'description' => '如果图层的尺寸和背景图的尺寸不一致,可开启此项以自定义图层对齐方向'],
['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, 'unit' => '%', 'description' => '提前或延后进入视线,负值为延后,正值为提前,0为关闭[-200~200]', 'dependency' => ['image', '!=', '']],
['id' => 'parallax_scale', 'type' => 'spinner', 'label' => '视差缩放', 'default' => 100, 'min' => 1, 'max' => 200, 'step' => 5, 'unit' => '%', 'description' => '放大或缩小进入视线,原图大小的百分之多少[1~200]', 'dependency' => ['image', '!=', '']],
['id' => 'parallax_opacity', 'type' => 'spinner', 'label' => '视差透明', 'default' => 100, 'min' => 1, 'max' => 100, 'step' => 5, 'unit' => '%', 'description' => '以百分之多少的透明度进入视线[1~100]
视差功能对浏览器性能有一定影响,如果图层较多,不建议全部开启', 'dependency' => ['image|parallax', '!=|!=', '|']],
]],
['id' => 'text', 'type' => 'accordion', 'label' => '叠加文案', 'fields' => [
['id' => 'title', 'type' => 'textarea', 'label' => '幻灯片文案', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1]],
['id' => 'desc', 'type' => 'textarea', 'label' => '幻灯片简介', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1], 'description' => '标题、简介均支持HTML代码,请注意代码规范及标签闭合', 'dependency' => ['title', '!=', '']],
['id' => 'text_align', 'type' => 'image_select', 'label' => '显示位置', 'default' => 'left-bottom', 'description' => '前景图显示位置及文案位置需合理搭配', '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, 'unit' => 'PX'],
['id' => 'text_size_m', 'type' => 'spinner', 'label' => '移动端字体大小', 'default' => 20, 'min' => 12, 'max' => 50, 'unit' => 'PX', 'description' => '在此设置标题的字体大小,简介的大小为标题大小的60%,最小12px
字体越大,文案周边的间距也越大!字体大小请根据内容合理调整,避免在某些设备显示不全'],
['id' => 'parallax', 'type' => 'spinner', 'label' => '文案视差滚动', 'default' => 40, 'min' => -200, 'max' => 200, 'step' => 10, 'unit' => '%', 'description' => '视差滚动功能为较背景滚动的时间差,为负数则滚动慢一拍,为正数则滚动快一拍,为0则关闭'],
]],
];
$fields = [
['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') {
$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, 'unit' => 'PX'],
['id' => 'speed', 'type' => 'spinner', 'label' => '切换速度', 'default' => 0, 'min' => 0, 'max' => 3000, 'step' => 100, 'unit' => '毫秒', 'description' => '设置为“0”,则为自动模式:根据幻灯片大小自动设置最佳速度'],
['id' => 'autoplay', 'type' => 'switcher', 'label' => '自动播放', 'default' => true],
['id' => 'interval', 'type' => 'spinner', 'label' => '停顿时间', 'default' => 4, 'min' => 0, 'max' => 20, 'unit' => '秒', 'dependency' => ['autoplay', '!=', '']],
];
$fields = [
['id' => 'obs_animation', 'type' => 'select', 'label' => '入场动画', 'default' => '', 'options' => self::animation_options(), 'description' => '页面滚动到封面区域时触发的入场动画[注意:需合理配置适当启用]'],
['id' => 'animation_repeat', 'type' => 'switcher', 'label' => '重复动画', 'default' => false, 'dependency' => ['obs_animation', '!=', ''], 'description' => '每次滚动到封面区域都触发动画[注意:有性能消耗,部分老旧浏览器会有闪烁问题]'],
['type' => 'subheading', 'content' => 'PC端布局配置'],
['id' => 'layout_ratio', 'type' => 'slider', 'label' => '幻灯片宽度占比', 'default' => 60, 'min' => 0, 'max' => 100, 'step' => 1, 'unit' => '%'],
['id' => 'slide_scale', 'type' => 'spinner', 'label' => '幻灯片长宽比', 'default' => 50, 'min' => 0, 'max' => 500, 'step' => 5, 'unit' => '%'],
['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行']],
['type' => 'subheading', 'content' => '移动端布局方式'],
['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, 'unit' => '%', 'dependency' => ['m_layout_type', 'any', 'hide_slide,vertical']],
['type' => 'subheading', 'content' => '左侧幻灯片'],
['id' => 'slides', 'type' => 'group', 'label' => '幻灯片内容', 'item_label' => '幻灯片', 'button_title' => '添加幻灯片', 'max_items' => 30, 'min_items' => 1, 'default' => $combo_slides, 'fields' => $slide_fields, 'description' => '注意:当添加的幻灯片内容只有一个的时候,则不会以幻灯片的形式展示(不能滑动切换,相当于单个图片或视频)由于移动端多数浏览器不支持视频背景功能,所以移动端不会显示视频!
'],
['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],
['type' => 'subheading', 'content' => '右侧图文视频卡片'],
['id' => 'covers', 'type' => 'group', 'label' => '右侧图文视频卡片', 'item_label' => '卡片', 'button_title' => '添加卡片', 'max_items' => 30, 'default' => array_fill(0, 4, ['image' => $asset_uri . 'user_t.jpg', 'title' => '']), 'fields' => self::cover_fields(), 'description' => '注意:由于移动端多数浏览器不支持视频背景功能,所以移动端不会显示视频!
'],
['type' => 'subheading', 'content' => '卡片样式配置'],
['id' => 'mask_opacity', 'type' => 'slider', 'label' => '遮罩透明度', 'default' => 0, 'min' => 0, 'max' => 90, 'step' => 1, 'unit' => '%', 'description' => '图片上显示的黑色遮罩层的透明度'],
['id' => 'font_size_pc', 'type' => 'spinner', 'label' => 'PC端字体大小', 'default' => 16, 'min' => 10, 'max' => 80, 'step' => 2, 'unit' => 'px'],
['id' => 'font_size_m', 'type' => 'spinner', 'label' => '移动端字体大小', 'default' => 14, 'min' => 10, 'max' => 80, 'step' => 2, 'unit' => 'px'],
['id' => 'font_bold', 'type' => 'switcher', 'label' => '粗体显示', 'default' => false],
['id' => 'font_color', 'type' => 'color', 'label' => '文字颜色', 'default' => ''],
];
}
return $fields;
}
private static function user(string $slug): array {
if ($slug === 'user_ranking') {
return [
['id' => 'orderby', 'type' => 'select', 'label' => '榜单类型', 'default' => 'points', 'options' => ['checkin_all_day' => '累计签到', 'checkin_continuous_day' => '连续签到', 'points' => '积分', 'followers' => '粉丝']],
['id' => 'number', 'type' => 'spinner', 'label' => '显示数量', 'default' => 8, 'min' => 1, 'max' => 50],
['id' => 'show_badge', 'type' => 'switcher', 'label' => '显示前三徽标', 'default' => true],
];
}
if ($slug === 'user_list') {
return [
['id' => 'number', 'type' => 'spinner', 'label' => '显示数量', 'default' => 12, 'min' => 1, 'max' => 100],
['id' => 'include', 'type' => 'text', 'label' => '包含用户 ID', 'default' => '', 'sanitize' => 'ids'],
['id' => 'exclude', 'type' => 'text', 'label' => '排除用户 ID', 'default' => '', 'sanitize' => 'ids'],
['id' => 'orderby', 'type' => 'select', 'label' => '排序', 'default' => 'registered', 'options' => ['registered' => '注册时间', 'display_name' => '名称', 'post_count' => '文章数', 'points' => '积分', 'followers' => '粉丝']],
];
}
$button_fields = [
['id' => 'show_button', 'type' => 'switcher', 'label' => '显示按钮', 'description' => $slug === 'user_card' ? '登录后才会显示' : '当登录用户就是文章作者的时候才会显示', 'default' => true],
['id' => 'button_1', 'type' => 'radio', 'label' => '按钮1类型', 'default' => 'post', 'options' => ['post' => '文章投稿'], 'dependency' => ['show_button', '!=', '']],
['id' => 'button_1_class', 'type' => 'palette', 'label' => '按钮1颜色', 'default' => 'jb-pink', 'options' => self::zib_palette(), 'dependency' => ['show_button', '!=', '']],
['id' => 'button_1_text', 'type' => 'text', 'label' => '按钮1文字', 'default' => '发布文章', 'dependency' => ['show_button', '!=', '']],
['id' => 'button_2', 'type' => 'radio', 'label' => '按钮2类型', 'default' => 'center', 'options' => ['home' => '个人主页', 'center' => '用户中心'], 'dependency' => ['show_button', '!=', '']],
['id' => 'button_2_class', 'type' => 'palette', 'label' => '按钮2颜色', 'default' => 'jb-blue', 'options' => self::zib_palette(), 'dependency' => ['show_button', '!=', '']],
['id' => 'button_2_text', 'type' => 'text', 'label' => '按钮2文字', 'default' => '用户中心', 'dependency' => ['show_button', '!=', '']],
];
if ($slug === 'user_card') {
return [
['id' => 'show_img_bg', 'type' => 'switcher', 'label' => '显示封面', 'default' => true],
['id' => 'loged_title', 'type' => 'text', 'label' => '未登录的文案', 'default' => 'HI!请登录'],
...$button_fields,
];
}
return [
['id' => 'show_img_bg', 'type' => 'switcher', 'label' => '显示封面', 'default' => true],
['id' => 'show_posts', 'type' => 'switcher', 'label' => '显示文章', 'default' => true],
['id' => 'post_style', 'type' => 'radio', 'label' => '显示样式', 'default' => 'mini', 'options' => ['mini' => '简约风格', 'card' => '图文卡片'], 'dependency' => ['show_posts', '!=', '']],
['id' => 'limit', 'type' => 'spinner', 'label' => '显示数量', 'default' => 6, 'min' => 2, 'max' => 12, 'step' => 1, 'unit' => '篇', 'dependency' => ['show_posts', '!=', '']],
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => 'date', 'options' => ['modified' => '最近更新', 'date' => '最新发布', 'views' => '最多浏览', 'like' => '最多点赞', 'comment_count' => '最多评论', 'favorite' => '最多收藏', 'rand' => '随机'], 'dependency' => ['show_posts', '!=', '']],
...$button_fields,
];
}
private static function icon_cards_fields(): array {
return [
['id' => 'show_widget_bg', 'type' => 'switcher', 'label' => '显示模块背景', 'default' => false],
['id' => 'pc_row', 'type' => 'button_set', 'label' => 'PC端单行排列数量', 'default' => 2, 'options' => [1 => '1个', 2 => '2个', 3 => '3个', 4 => '4个', 6 => '6个', 12 => '12个']],
['id' => 'm_row', 'type' => 'button_set', 'label' => '移动端单行排列数量', 'default' => 2, 'options' => [1 => '1个', 2 => '2个', 3 => '3个', 4 => '4个', 6 => '6个', 12 => '12个']],
['id' => 'size', 'type' => 'slider', 'label' => '图标尺寸微调', 'default' => 0, 'min' => -10, 'max' => 10, 'step' => 1],
['id' => 'cards', 'type' => 'group', 'label' => '添加图标', 'max_items' => 40, 'default' => [], 'fields' => [
['id' => 'icon', 'type' => 'icon', 'label' => '选择图标', 'default' => 'fa fas fa-magic'],
['id' => 'customize_icon', 'type' => 'textarea', 'label' => '自定义图标', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1]],
['id' => 'link', 'type' => 'link', 'label' => '跳转链接', 'default' => []],
['id' => 'icon_radius', 'type' => 'switcher', 'label' => '显示图标背景', 'default' => false],
['id' => 'icon_class', 'type' => 'palette', 'label' => '图标样式', 'default' => 'c-yellow', 'options' => self::icon_background_palette(), 'dependency' => ['icon_radius', '!=', '']],
['id' => 'icon_color', 'type' => 'palette', 'label' => '图标颜色', 'default' => 'key-color', 'options' => self::icon_text_palette(), 'dependency' => ['icon_radius|icon_custom_color', '==|==', '|']],
['id' => 'icon_custom_color', 'type' => 'color', 'label' => '自定义图标颜色', 'default' => '', 'dependency' => ['icon_radius', '==', '']],
['id' => 'title', 'type' => 'textarea', 'label' => '文案标题', 'default' => '', 'allow_html' => true, 'sanitize' => 'rich_html', 'attributes' => ['rows' => 1]],
['id' => 'desc', 'type' => 'textarea', 'label' => '文案简介', 'default' => '', 'allow_html' => true, 'sanitize' => 'rich_html', 'attributes' => ['rows' => 2]],
]],
];
}
private static function icon_cover_cards_fields(): array {
return [
['id' => 'pc_row', 'type' => 'button_set', 'label' => 'PC端单行排列数量', 'default' => 4, 'options' => [1 => '1个', 2 => '2个', 3 => '3个', 4 => '4个', 6 => '6个']],
['id' => 'm_row', 'type' => 'button_set', 'label' => '移动端单行排列数量', 'default' => 2, 'options' => [1 => '1个', 2 => '2个']],
['id' => 'show_widget_bg', 'type' => 'switcher', 'label' => '显示模块背景', 'default' => false],
['id' => 'icon_radius4', 'type' => 'switcher', 'label' => '方形图标', 'default' => false],
['id' => 'cards', 'type' => 'group', 'label' => '添加卡片', 'max_items' => 40, 'default' => [], 'fields' => [
['id' => 'title', 'type' => 'textarea', 'label' => '文案标题', 'default' => '', 'allow_html' => true, 'sanitize' => 'rich_html', 'attributes' => ['rows' => 1]],
['id' => 'desc', 'type' => 'textarea', 'label' => '文案简介', 'default' => '', 'allow_html' => true, 'sanitize' => 'rich_html', 'attributes' => ['rows' => 2]],
['id' => 'icon', 'type' => 'icon', 'label' => '选择图标', 'default' => 'fa fas fa-magic'],
['id' => 'customize_icon', 'type' => 'textarea', 'label' => '自定义图标', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1]],
['id' => 'icon_class', 'type' => 'palette', 'label' => '图标颜色', 'default' => 'c-yellow', 'options' => self::icon_background_palette()],
['id' => 'link', 'type' => 'link', 'label' => '跳转链接', 'default' => []],
]],
];
}
private static function icon_background_palette(): array {
return [
'transparent' => '透明', 'c-red' => '红色', 'c-red-2' => '深红', 'c-yellow' => '黄色', 'c-yellow-2' => '深黄', 'c-cyan' => '青色', 'c-blue' => '蓝色', 'c-blue-2' => '深蓝', 'c-green' => '绿色', 'c-green-2' => '深绿', 'c-purple' => '紫色', 'c-purple-2' => '深紫',
'b-red' => '红色背景', 'b-yellow' => '黄色背景', 'b-cyan' => '青色背景', 'b-blue' => '蓝色背景', 'b-green' => '绿色背景', 'b-purple' => '紫色背景', 'b-black' => '黑色背景',
'jb-red' => '渐变红', 'jb-pink' => '渐变粉', 'jb-yellow' => '渐变黄', 'jb-cyan' => '渐变青', 'jb-blue' => '渐变蓝', 'jb-green' => '渐变绿', 'jb-purple' => '渐变紫', 'jb-vip1' => '会员金', 'jb-vip2' => '会员黑',
];
}
private static function icon_text_palette(): array {
return [
'key-color' => '主要文字', 'c-red' => '红色', 'c-red-2' => '深红', 'c-yellow' => '黄色', 'c-yellow-2' => '深黄', 'c-cyan' => '青色', 'c-blue' => '蓝色', 'c-blue-2' => '深蓝', 'c-green' => '绿色', 'c-green-2' => '深绿', 'c-purple' => '紫色', 'c-purple-2' => '深紫',
];
}
private static function media_card_fields(): array {
return [
['id' => 'title', 'type' => 'text', 'label' => '标题', 'default' => ''],
['id' => 'description', 'type' => 'textarea', 'label' => '说明', 'default' => ''],
['id' => 'image', 'type' => 'upload', 'label' => '图片', 'default' => ''],
['id' => 'image_dark', 'type' => 'upload', 'label' => '深色图片', 'default' => ''],
['id' => 'video', 'type' => 'upload', 'label' => '视频', 'default' => ''],
['id' => 'link', 'type' => 'link', 'label' => '链接', 'default' => []],
];
}
/** 图文视频封面卡片单元(移动端不显示视频)。 */
private static function cover_fields(): array {
return [
['id' => 'image', 'type' => 'upload', 'label' => '图片背景', 'default' => '', 'library' => 'image'],
['id' => 'video', 'type' => 'upload', 'label' => '视频背景', 'default' => '', 'library' => 'video', 'description' => '(必填)图片背景、视频背景至少二选一,如果同时设置则PC端视频优先(PC端视频加载失败则显示图片),移动端只显示图片'],
['id' => 'hide', 'type' => 'radio', 'label' => '显示规则', 'default' => '', 'options' => ['' => '全部显示', 'pc' => 'PC端不显示', 'm' => '移动端不显示']],
['id' => 'title', 'type' => 'textarea', 'label' => '文字', 'default' => '', 'allow_html' => true, 'attributes' => ['rows' => 1], 'description' => '支持HTML代码'],
['id' => 'link', 'type' => 'link', 'label' => '跳转链接', 'default' => []],
];
}
private static function cta_palette(): array {
return ['' => '默认'] + self::text_palette();
}
private static function tag_palette(): array {
return ['' => '默认'] + self::zib_palette();
}
private static function text_palette(): array {
return [
'c-red' => '红色', 'c-red-2' => '深红', 'c-yellow' => '黄色', 'c-yellow-2' => '深黄', 'c-cyan' => '青色',
'c-blue' => '蓝色', 'c-blue-2' => '深蓝', 'c-green' => '绿色', 'c-green-2' => '深绿', 'c-purple' => '紫色', 'c-purple-2' => '深紫',
];
}
private static function card_fields(bool $link = false): array {
$fields = [['id' => 'title', 'type' => 'text', 'label' => '标题', 'default' => ''], ['id' => 'description', 'type' => 'textarea', 'label' => '说明', 'default' => '']];
if ($link) {
$fields[] = ['id' => 'link', 'type' => 'link', 'label' => '链接', 'default' => []];
}
return $fields;
}
private static function animation_options(): array {
return ['' => '无动画', 'fade' => '淡入', 'slideup' => '从下往上滑出', 'slidedown' => '从上往下滑出', 'slideright' => '从左往右滑出', 'slideleft' => '从右往左滑出', 'zoomin' => '由小变大', 'zoomout' => '由大变小'];
}
private static function button_palette(): array {
return ['' => '默认'] + self::zib_palette();
}
private static function zib_palette(): array {
return [
'c-red' => '红色', 'c-red-2' => '深红', 'c-yellow' => '黄色', 'c-yellow-2' => '深黄',
'c-cyan' => '青色', 'c-blue' => '蓝色', 'c-blue-2' => '深蓝', 'c-green' => '绿色',
'c-green-2' => '深绿', 'c-purple' => '紫色', 'c-purple-2' => '深紫',
'b-red' => '红色背景', 'b-yellow' => '黄色背景', 'b-cyan' => '青色背景', 'b-blue' => '蓝色背景',
'b-green' => '绿色背景', 'b-purple' => '紫色背景', 'b-black' => '黑色背景',
'jb-red' => '渐变红', 'jb-pink' => '渐变粉', 'jb-yellow' => '渐变黄', 'jb-cyan' => '渐变青',
'jb-blue' => '渐变蓝', 'jb-green' => '渐变绿', 'jb-purple' => '渐变紫', 'jb-vip1' => '会员金', 'jb-vip2' => '会员黑',
];
}
private static function notice_post_fields(): array {
return [
['id' => 'cat', 'type' => 'text', 'label' => '分类限制', 'default' => '', 'sanitize' => 'reference_ids'],
['id' => 'orderby', 'type' => 'select', 'label' => '排序方式', 'default' => '', 'options' => self::posts_orderby()],
['id' => 'order', 'type' => 'radio', 'label' => '顺序', 'default' => 'desc', 'options' => ['desc' => '降序', 'asc' => '升序']],
];
}
private static function pay_types(): array {
return ['1' => '付费阅读', '2' => '付费下载', '5' => '付费图片', '6' => '付费视频'];
}
}