feat(navigation): hard-switch to Zibll navigation and Font Awesome 5
This commit is contained in:
1 parent
3c3ddac8be
commit
a0b84977a2
630 files changed
+101647
-11293
No files matched your search
+3
-3
@@ -110,10 +110,10 @@ class Admin {
|
||||
}
|
||||
}
|
||||
|
||||
// Match frontend FA5 pack so FaIcon / menu glyphs render in the SPA.
|
||||
// Use the same local FA5 pack as the public stack.
|
||||
wp_enqueue_style(
|
||||
'aksrt-font-awesome-5',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css',
|
||||
'aksrt-font-awesome',
|
||||
get_template_directory_uri() . '/assets/vendor/fontawesome5/css/all.min.css',
|
||||
[],
|
||||
'5.15.4'
|
||||
);
|
||||
|
||||
@@ -56,7 +56,7 @@ trait GlobalControllerPart1 {
|
||||
if (!empty($item['add_items']) && is_array($item['add_items'])) {
|
||||
foreach ($item['add_items'] as $sub_item) {
|
||||
$label = sanitize_text_field($sub_item['label'] ?? '');
|
||||
$icon = sanitize_text_field($sub_item['icon'] ?? 'fas fa-pen');
|
||||
$icon = sanitize_text_field($sub_item['icon'] ?? 'fa fas fa-pen');
|
||||
$url = esc_url_raw($sub_item['url'] ?? '');
|
||||
if ($label === '') {
|
||||
continue;
|
||||
@@ -237,7 +237,7 @@ trait GlobalControllerPart1 {
|
||||
$icon_dark = sanitize_text_field($item['icon_dark'] ?? '');
|
||||
$icon_light = sanitize_text_field($item['icon_light'] ?? '');
|
||||
if ($type === 'theme_mode') {
|
||||
$icon = 'fas fa-sun';
|
||||
$icon = 'fa fas fa-sun';
|
||||
$icon_dark = '';
|
||||
$icon_light = '';
|
||||
}
|
||||
@@ -247,13 +247,12 @@ trait GlobalControllerPart1 {
|
||||
if ($type === 'pay_vip') {
|
||||
$link = '';
|
||||
$hover = '';
|
||||
if ($icon === '' || str_contains($icon, 'fa-diamond') || $icon === 'fa fa-diamond') {
|
||||
$icon = 'fas fa-gem';
|
||||
}
|
||||
// Ensure FA5 prefix when bare fa-* is stored.
|
||||
if ($icon !== '' && !preg_match('/\b(fas|far|fab|fal|fad)\b/', $icon)) {
|
||||
$icon = 'fas ' . ltrim(preg_replace('/^fa\s+/', '', $icon) ?? $icon);
|
||||
if ($icon === '' || str_contains($icon, 'fa-gem') || $icon === 'fa fas fa-gem') {
|
||||
$icon = 'fa fas fa-gem';
|
||||
}
|
||||
if (!preg_match('/^fa\s+(?:fas|far|fab)\s+fa-[a-z0-9-]+(?:\s+fa-[a-z0-9-]+)*$/i', $icon)) {
|
||||
$icon = 'fa fas fa-gem';
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
|
||||
@@ -37,22 +37,34 @@ trait GlobalControllerPart2 {
|
||||
}
|
||||
|
||||
public function rest_get_categories(\WP_REST_Request $request): \WP_REST_Response {
|
||||
$categories = get_categories([
|
||||
$requested = array_filter(array_map('sanitize_key', explode(',', (string) $request->get_param('taxonomy'))));
|
||||
$taxonomies = array_values(array_filter($requested ?: ['category'], 'taxonomy_exists'));
|
||||
if ($taxonomies === []) {
|
||||
return rest_ensure_response(['code' => 'success', 'data' => []]);
|
||||
}
|
||||
|
||||
$categories = get_terms([
|
||||
'taxonomy' => $taxonomies,
|
||||
'orderby' => 'count',
|
||||
'order' => 'DESC',
|
||||
'hide_empty' => false,
|
||||
]);
|
||||
if (is_wp_error($categories)) {
|
||||
return rest_ensure_response(['code' => 'success', 'data' => []]);
|
||||
}
|
||||
|
||||
$data = array_map(function ($cat) {
|
||||
$is_category = $cat->taxonomy === 'category';
|
||||
return [
|
||||
'term_id' => (int) $cat->term_id,
|
||||
'name' => $cat->name,
|
||||
'slug' => $cat->slug,
|
||||
'taxonomy' => $cat->taxonomy,
|
||||
'count' => (int) $cat->count,
|
||||
'description' => $cat->description,
|
||||
'cover_id' => (int) get_term_meta($cat->term_id, 'aksrt_category_cover_id', true),
|
||||
'cover_url' => \AKSRT\Settings\Settings::get_category_cover_url((int) $cat->term_id),
|
||||
'recommend_desc' => (string) get_term_meta($cat->term_id, 'aksrt_category_recommend_desc', true),
|
||||
'cover_id' => $is_category ? (int) get_term_meta($cat->term_id, 'aksrt_category_cover_id', true) : 0,
|
||||
'cover_url' => $is_category ? \AKSRT\Settings\Settings::get_category_cover_url((int) $cat->term_id) : '',
|
||||
'recommend_desc' => $is_category ? (string) get_term_meta($cat->term_id, 'aksrt_category_recommend_desc', true) : '',
|
||||
];
|
||||
}, $categories);
|
||||
|
||||
|
||||
@@ -80,9 +80,6 @@ trait HomepageSettingsRest {
|
||||
if (isset($params['homepage_tab_limit'])) {
|
||||
$settings['homepage_tab_limit'] = max(1, min(12, (int) $params['homepage_tab_limit']));
|
||||
}
|
||||
if (array_key_exists('homepage_module_hero_enabled', $params)) {
|
||||
$settings['homepage_module_hero_enabled'] = !empty($params['homepage_module_hero_enabled']);
|
||||
}
|
||||
if (array_key_exists('homepage_module_banner_enabled', $params)) {
|
||||
$settings['homepage_module_banner_enabled'] = !empty($params['homepage_module_banner_enabled']);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Native WP nav-menu item options (aksrt_menu_options) with senior submenu JSON.
|
||||
* Native WP nav-menu item options using Zibll's zib_menu_options meta contract.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -41,7 +41,7 @@ class NavMenuOptions {
|
||||
*/
|
||||
public static function render_fields($item_id, $item): void {
|
||||
$item_id = (int) $item_id;
|
||||
$opts = get_post_meta($item_id, 'aksrt_menu_options', true);
|
||||
$opts = get_post_meta($item_id, 'zib_menu_options', true);
|
||||
$opts = is_array($opts) ? $opts : [];
|
||||
$icon = (string) ($opts['icon'] ?? '');
|
||||
$badge = (string) ($opts['badge'] ?? '');
|
||||
@@ -57,9 +57,9 @@ class NavMenuOptions {
|
||||
?>
|
||||
<p class="field-aksrt-icon description description-wide">
|
||||
<label for="edit-menu-item-aksrt-icon-<?php echo esc_attr((string) $item_id); ?>">
|
||||
<?php esc_html_e('图标 class(如 fas fa-home)', 'aksrt'); ?><br>
|
||||
<?php esc_html_e('图标 class(如 fa fas fa-home)', 'aksrt'); ?><br>
|
||||
<input type="text" id="edit-menu-item-aksrt-icon-<?php echo esc_attr((string) $item_id); ?>"
|
||||
class="widefat" name="aksrt_menu_options[<?php echo esc_attr((string) $item_id); ?>][icon]"
|
||||
class="widefat" name="zib_menu_options[<?php echo esc_attr((string) $item_id); ?>][icon]"
|
||||
value="<?php echo esc_attr($icon); ?>">
|
||||
</label>
|
||||
</p>
|
||||
@@ -67,7 +67,7 @@ class NavMenuOptions {
|
||||
<label for="edit-menu-item-aksrt-badge-<?php echo esc_attr((string) $item_id); ?>">
|
||||
<?php esc_html_e('徽章文字', 'aksrt'); ?><br>
|
||||
<input type="text" id="edit-menu-item-aksrt-badge-<?php echo esc_attr((string) $item_id); ?>"
|
||||
class="widefat" name="aksrt_menu_options[<?php echo esc_attr((string) $item_id); ?>][badge]"
|
||||
class="widefat" name="zib_menu_options[<?php echo esc_attr((string) $item_id); ?>][badge]"
|
||||
value="<?php echo esc_attr($badge); ?>">
|
||||
</label>
|
||||
</p>
|
||||
@@ -75,13 +75,13 @@ class NavMenuOptions {
|
||||
<label for="edit-menu-item-aksrt-badge-class-<?php echo esc_attr((string) $item_id); ?>">
|
||||
<?php esc_html_e('徽章 class', 'aksrt'); ?><br>
|
||||
<input type="text" id="edit-menu-item-aksrt-badge-class-<?php echo esc_attr((string) $item_id); ?>"
|
||||
class="widefat" name="aksrt_menu_options[<?php echo esc_attr((string) $item_id); ?>][badge_class]"
|
||||
class="widefat" name="zib_menu_options[<?php echo esc_attr((string) $item_id); ?>][badge_class]"
|
||||
value="<?php echo esc_attr($badge_class); ?>">
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-aksrt-submenu description description-wide">
|
||||
<label>
|
||||
<input type="checkbox" name="aksrt_menu_options[<?php echo esc_attr((string) $item_id); ?>][submenu_s]" value="1" <?php checked($submenu_s); ?>>
|
||||
<input type="checkbox" name="zib_menu_options[<?php echo esc_attr((string) $item_id); ?>][submenu_s]" value="1" <?php checked($submenu_s); ?>>
|
||||
<?php esc_html_e('启用高级子菜单(仅一级菜单)', 'aksrt'); ?>
|
||||
</label>
|
||||
</p>
|
||||
@@ -89,7 +89,7 @@ class NavMenuOptions {
|
||||
<label for="edit-menu-item-aksrt-submenu-type-<?php echo esc_attr((string) $item_id); ?>">
|
||||
<?php esc_html_e('高级子菜单类型', 'aksrt'); ?><br>
|
||||
<select id="edit-menu-item-aksrt-submenu-type-<?php echo esc_attr((string) $item_id); ?>"
|
||||
name="aksrt_menu_options[<?php echo esc_attr((string) $item_id); ?>][submenu_type]">
|
||||
name="zib_menu_options[<?php echo esc_attr((string) $item_id); ?>][submenu_type]">
|
||||
<option value="" <?php selected($submenu_type, ''); ?>><?php esc_html_e('无', 'aksrt'); ?></option>
|
||||
<option value="graphic_card" <?php selected($submenu_type, 'graphic_card'); ?>><?php esc_html_e('图文卡片', 'aksrt'); ?></option>
|
||||
<option value="multi_column_links" <?php selected($submenu_type, 'multi_column_links'); ?>><?php esc_html_e('多列链接', 'aksrt'); ?></option>
|
||||
@@ -100,14 +100,14 @@ class NavMenuOptions {
|
||||
<label for="edit-menu-item-aksrt-graphic-<?php echo esc_attr((string) $item_id); ?>">
|
||||
<?php esc_html_e('图文卡片 JSON(type=graphic_card)', 'aksrt'); ?><br>
|
||||
<textarea rows="8" class="widefat code" id="edit-menu-item-aksrt-graphic-<?php echo esc_attr((string) $item_id); ?>"
|
||||
name="aksrt_menu_options[<?php echo esc_attr((string) $item_id); ?>][graphic_card_opts_json]"><?php echo esc_textarea((string) $graphic_json); ?></textarea>
|
||||
name="zib_menu_options[<?php echo esc_attr((string) $item_id); ?>][graphic_card_opts_json]"><?php echo esc_textarea((string) $graphic_json); ?></textarea>
|
||||
</label>
|
||||
</p>
|
||||
<p class="field-aksrt-multi description description-wide">
|
||||
<label for="edit-menu-item-aksrt-multi-<?php echo esc_attr((string) $item_id); ?>">
|
||||
<?php esc_html_e('多列链接 JSON(type=multi_column_links)', 'aksrt'); ?><br>
|
||||
<textarea rows="8" class="widefat code" id="edit-menu-item-aksrt-multi-<?php echo esc_attr((string) $item_id); ?>"
|
||||
name="aksrt_menu_options[<?php echo esc_attr((string) $item_id); ?>][multi_column_links_opts_json]"><?php echo esc_textarea((string) $multi_json); ?></textarea>
|
||||
name="zib_menu_options[<?php echo esc_attr((string) $item_id); ?>][multi_column_links_opts_json]"><?php echo esc_textarea((string) $multi_json); ?></textarea>
|
||||
</label>
|
||||
</p>
|
||||
<?php
|
||||
@@ -120,11 +120,11 @@ class NavMenuOptions {
|
||||
public static function save($menu_id, $menu_item_db_id): void {
|
||||
$menu_item_db_id = (int) $menu_item_db_id;
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing
|
||||
if (empty($_POST['aksrt_menu_options'][ $menu_item_db_id ]) || !is_array($_POST['aksrt_menu_options'][ $menu_item_db_id ])) {
|
||||
if (empty($_POST['zib_menu_options'][ $menu_item_db_id ]) || !is_array($_POST['zib_menu_options'][ $menu_item_db_id ])) {
|
||||
return;
|
||||
}
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
|
||||
$raw = wp_unslash($_POST['aksrt_menu_options'][ $menu_item_db_id ]);
|
||||
$raw = wp_unslash($_POST['zib_menu_options'][ $menu_item_db_id ]);
|
||||
|
||||
$clean = [
|
||||
'icon' => sanitize_text_field((string) ($raw['icon'] ?? '')),
|
||||
@@ -143,7 +143,7 @@ class NavMenuOptions {
|
||||
$clean['multi_column_links_opts'] = self::sanitize_multi_opts($multi);
|
||||
}
|
||||
|
||||
update_post_meta($menu_item_db_id, 'aksrt_menu_options', $clean);
|
||||
update_post_meta($menu_item_db_id, 'zib_menu_options', $clean);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,7 +257,7 @@ class NavMenuOptions {
|
||||
'columns' => [
|
||||
[
|
||||
'title' => '栏目一',
|
||||
'icon' => 'fas fa-folder',
|
||||
'icon' => 'fa fas fa-folder',
|
||||
'link' => ['url' => '', 'text' => '', 'target' => ''],
|
||||
'items' => [
|
||||
['title' => '链接 A', 'icon' => '', 'link' => ['url' => home_url('/'), 'text' => '', 'target' => '']],
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
/**
|
||||
* Per-page Zibll header slider configuration.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
namespace AKSRT\Admin;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
final class PageConfigMetaBox {
|
||||
|
||||
private const META_KEY = 'page_config';
|
||||
private const NONCE_ACTION = 'aksrt_page_config_save';
|
||||
private const NONCE_NAME = 'aksrt_page_config_nonce';
|
||||
|
||||
public static function init(): void {
|
||||
add_action('add_meta_boxes_page', [self::class, 'register']);
|
||||
add_action('save_post_page', [self::class, 'save']);
|
||||
}
|
||||
|
||||
public static function register(): void {
|
||||
add_meta_box(
|
||||
'aksrt-page-config',
|
||||
__('页面配置', 'aksrt'),
|
||||
[self::class, 'render'],
|
||||
'page',
|
||||
'normal',
|
||||
'high'
|
||||
);
|
||||
}
|
||||
|
||||
/** @param \WP_Post $post */
|
||||
public static function render($post): void {
|
||||
$config = get_post_meta((int) $post->ID, self::META_KEY, true);
|
||||
$config = is_array($config) ? $config : [];
|
||||
wp_nonce_field(self::NONCE_ACTION, self::NONCE_NAME);
|
||||
|
||||
$show_type = (string) ($config['header_slider_show_type'] ?? '');
|
||||
$devices = [
|
||||
'header_slider_search_s' => (array) ($config['header_slider_search_s'] ?? []),
|
||||
'header_slider_card_s' => (array) ($config['header_slider_card_s'] ?? []),
|
||||
];
|
||||
?>
|
||||
<style>
|
||||
.aksrt-page-config-grid{display:grid;grid-template-columns:220px minmax(0,1fr);gap:14px 20px;align-items:start}
|
||||
.aksrt-page-config-grid>label{font-weight:600;padding-top:7px}.aksrt-page-config-grid textarea{width:100%;font-family:Consolas,monospace}
|
||||
.aksrt-page-config-grid .description{margin:4px 0 0}.aksrt-page-config-wide{grid-column:1/-1}
|
||||
@media(max-width:782px){.aksrt-page-config-grid{grid-template-columns:1fr}.aksrt-page-config-wide{grid-column:auto}}
|
||||
</style>
|
||||
<div class="aksrt-page-config-grid">
|
||||
<label for="aksrt-header-slider-show"><?php esc_html_e('启用顶部多功能组件', 'aksrt'); ?></label>
|
||||
<div><label><input id="aksrt-header-slider-show" type="checkbox" name="page_config[header_slider_show]" value="1" <?php checked(!empty($config['header_slider_show'])); ?>> <?php esc_html_e('为当前页面使用独立配置', 'aksrt'); ?></label></div>
|
||||
|
||||
<label><?php esc_html_e('显示规则', 'aksrt'); ?></label>
|
||||
<div>
|
||||
<?php foreach (['' => __('全部显示', 'aksrt'), 'only_pc' => __('仅在 PC 端显示', 'aksrt'), 'only_sm' => __('仅在移动端显示', 'aksrt')] as $value => $label) : ?>
|
||||
<label style="margin-right:16px"><input type="radio" name="page_config[header_slider_show_type]" value="<?php echo esc_attr($value); ?>" <?php checked($show_type, $value); ?>> <?php echo esc_html($label); ?></label>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<label for="aksrt-header-slider-nav-color"><?php esc_html_e('导航栏文字颜色', 'aksrt'); ?></label>
|
||||
<div><input id="aksrt-header-slider-nav-color" type="color" name="page_config[header_slider_nav_color]" value="<?php echo esc_attr((string) ($config['header_slider_nav_color'] ?? '#ffffff')); ?>"></div>
|
||||
|
||||
<?php self::render_json_field('header_slider', __('背景内容', 'aksrt'), $config['header_slider'] ?? self::slide_defaults(), 16); ?>
|
||||
<?php self::render_json_field('header_slider_option', __('背景显示设置', 'aksrt'), $config['header_slider_option'] ?? self::slider_defaults(), 12); ?>
|
||||
|
||||
<label><?php esc_html_e('叠加搜索组件', 'aksrt'); ?></label>
|
||||
<div><?php self::render_devices('header_slider_search_s', $devices['header_slider_search_s']); ?></div>
|
||||
<?php self::render_json_field('header_slider_search_option', __('搜索组件设置', 'aksrt'), $config['header_slider_search_option'] ?? self::search_defaults(), 12); ?>
|
||||
|
||||
<label><?php esc_html_e('叠加封面卡片组件', 'aksrt'); ?></label>
|
||||
<div><?php self::render_devices('header_slider_card_s', $devices['header_slider_card_s']); ?></div>
|
||||
<?php self::render_json_field('header_slider_card_option', __('图标卡片设置', 'aksrt'), $config['header_slider_card_option'] ?? self::card_defaults(), 16); ?>
|
||||
</div>
|
||||
<p class="description"><?php esc_html_e('复杂字段使用参考主题原始数组结构的 JSON;保存后统一写入 page_config 序列化元数据,不读取任何旧字段。', 'aksrt'); ?></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
/** @param mixed $value */
|
||||
private static function render_json_field(string $key, string $label, $value, int $rows): void {
|
||||
$json = wp_json_encode(is_array($value) ? $value : [], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
?>
|
||||
<label for="aksrt-<?php echo esc_attr($key); ?>"><?php echo esc_html($label); ?></label>
|
||||
<div><textarea id="aksrt-<?php echo esc_attr($key); ?>" name="page_config[<?php echo esc_attr($key); ?>]" rows="<?php echo (int) $rows; ?>"><?php echo esc_textarea((string) $json); ?></textarea></div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/** @param list<string> $selected */
|
||||
private static function render_devices(string $key, array $selected): void {
|
||||
foreach (['pc_s' => __('PC 端显示', 'aksrt'), 'm_s' => __('移动端显示', 'aksrt')] as $value => $label) {
|
||||
printf(
|
||||
'<label style="margin-right:16px"><input type="checkbox" name="page_config[%1$s][]" value="%2$s" %3$s> %4$s</label>',
|
||||
esc_attr($key),
|
||||
esc_attr($value),
|
||||
checked(in_array($value, $selected, true), true, false),
|
||||
esc_html($label)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function save(int $post_id): void {
|
||||
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
||||
return;
|
||||
}
|
||||
if (!current_user_can('edit_page', $post_id)) {
|
||||
return;
|
||||
}
|
||||
if (!isset($_POST[self::NONCE_NAME]) || !wp_verify_nonce(sanitize_text_field(wp_unslash((string) $_POST[self::NONCE_NAME])), self::NONCE_ACTION)) {
|
||||
return;
|
||||
}
|
||||
if (!isset($_POST['page_config']) || !is_array($_POST['page_config'])) {
|
||||
delete_post_meta($post_id, self::META_KEY);
|
||||
return;
|
||||
}
|
||||
|
||||
$raw = wp_unslash($_POST['page_config']);
|
||||
$config = [
|
||||
'header_slider_show' => !empty($raw['header_slider_show']),
|
||||
'header_slider_show_type' => self::enum((string) ($raw['header_slider_show_type'] ?? ''), ['', 'only_pc', 'only_sm']),
|
||||
'header_slider_nav_color' => sanitize_hex_color((string) ($raw['header_slider_nav_color'] ?? '')) ?: '#ffffff',
|
||||
'header_slider' => self::sanitize_slides(self::decode_json($raw['header_slider'] ?? '')),
|
||||
'header_slider_option' => self::sanitize_slider_options(self::decode_json($raw['header_slider_option'] ?? '')),
|
||||
'header_slider_search_s' => self::sanitize_devices($raw['header_slider_search_s'] ?? []),
|
||||
'header_slider_search_option' => self::sanitize_search_options(self::decode_json($raw['header_slider_search_option'] ?? '')),
|
||||
'header_slider_card_s' => self::sanitize_devices($raw['header_slider_card_s'] ?? []),
|
||||
'header_slider_card_option' => self::sanitize_card_options(self::decode_json($raw['header_slider_card_option'] ?? '')),
|
||||
];
|
||||
|
||||
update_post_meta($post_id, self::META_KEY, $config);
|
||||
}
|
||||
|
||||
/** @param mixed $value @return array<mixed> */
|
||||
private static function decode_json($value): array {
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
$decoded = json_decode((string) $value, true);
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
/** @param mixed $value @return list<string> */
|
||||
private static function sanitize_devices($value): array {
|
||||
return array_values(array_intersect(array_map('sanitize_key', (array) $value), ['pc_s', 'm_s']));
|
||||
}
|
||||
|
||||
/** @param list<string> $allowed */
|
||||
private static function enum(string $value, array $allowed): string {
|
||||
return in_array($value, $allowed, true) ? $value : $allowed[0];
|
||||
}
|
||||
|
||||
/** @param array<mixed> $slides @return list<array<string,mixed>> */
|
||||
private static function sanitize_slides(array $slides): array {
|
||||
$clean = [];
|
||||
foreach ($slides as $slide) {
|
||||
if (!is_array($slide)) {
|
||||
continue;
|
||||
}
|
||||
$layers = [];
|
||||
foreach ((array) ($slide['image_layer'] ?? []) as $layer) {
|
||||
if (!is_array($layer)) {
|
||||
continue;
|
||||
}
|
||||
$layers[] = [
|
||||
'image' => esc_url_raw((string) ($layer['image'] ?? '')),
|
||||
'free_size' => !empty($layer['free_size']),
|
||||
'align' => self::enum(sanitize_key((string) ($layer['align'] ?? 'center')), ['left', 'center', 'right']),
|
||||
'parallax' => max(-200, min(200, (int) ($layer['parallax'] ?? 0))),
|
||||
'parallax_scale' => max(1, min(200, (int) ($layer['parallax_scale'] ?? 100))),
|
||||
'parallax_opacity' => max(1, min(100, (int) ($layer['parallax_opacity'] ?? 100))),
|
||||
];
|
||||
}
|
||||
$text = is_array($slide['text'] ?? null) ? $slide['text'] : [];
|
||||
$link = is_array($slide['link'] ?? null) ? $slide['link'] : [];
|
||||
$clean[] = [
|
||||
'background' => esc_url_raw((string) ($slide['background'] ?? '')),
|
||||
'background_video' => esc_url_raw((string) ($slide['background_video'] ?? '')),
|
||||
'video' => esc_url_raw((string) ($slide['video'] ?? '')),
|
||||
'hide' => self::enum(sanitize_key((string) ($slide['hide'] ?? '')), ['', 'pc', 'm']),
|
||||
'link' => [
|
||||
'url' => esc_url_raw((string) ($link['url'] ?? '')),
|
||||
'target' => !empty($link['target']) ? '_blank' : '',
|
||||
'text' => sanitize_text_field((string) ($link['text'] ?? '')),
|
||||
],
|
||||
'image_layer' => $layers,
|
||||
'text' => [
|
||||
'title' => wp_kses_post((string) ($text['title'] ?? '')),
|
||||
'desc' => wp_kses_post((string) ($text['desc'] ?? '')),
|
||||
'text_align' => sanitize_html_class((string) ($text['text_align'] ?? 'left-bottom')),
|
||||
'text_size_pc' => max(12, min(50, (int) ($text['text_size_pc'] ?? 30))),
|
||||
'text_size_m' => max(12, min(50, (int) ($text['text_size_m'] ?? 20))),
|
||||
'parallax' => max(-200, min(200, (int) ($text['parallax'] ?? 40))),
|
||||
],
|
||||
];
|
||||
}
|
||||
return $clean;
|
||||
}
|
||||
|
||||
/** @param array<mixed> $value @return array<string,mixed> */
|
||||
private static function sanitize_slider_options(array $value): array {
|
||||
$defaults = array_merge(self::slider_defaults(), ['scale' => 40, 'max_height' => 500, 'min_height' => 180]);
|
||||
$value = wp_parse_args($value, $defaults);
|
||||
return [
|
||||
'direction' => self::enum(sanitize_key((string) $value['direction']), ['horizontal', 'vertical']),
|
||||
'loop' => !empty($value['loop']),
|
||||
'button' => !empty($value['button']),
|
||||
'pagination' => !empty($value['pagination']),
|
||||
'effect' => self::enum(sanitize_key((string) $value['effect']), ['slide', 'fade', 'cube', 'coverflow', 'flip']),
|
||||
'scale_height' => !empty($value['scale_height']),
|
||||
'scale' => max(10, min(300, (int) $value['scale'])),
|
||||
'auto_height' => !empty($value['auto_height']),
|
||||
'max_height' => max(120, min(800, (int) $value['max_height'])),
|
||||
'min_height' => max(100, min(500, (int) $value['min_height'])),
|
||||
'pc_height' => max(120, min(800, (int) $value['pc_height'])),
|
||||
'm_height' => max(100, min(500, (int) $value['m_height'])),
|
||||
'spacebetween' => max(0, min(500, (int) $value['spacebetween'])),
|
||||
'speed' => max(0, min(3000, (int) $value['speed'])),
|
||||
'autoplay' => !empty($value['autoplay']),
|
||||
'interval' => max(0, min(20, (int) $value['interval'])),
|
||||
];
|
||||
}
|
||||
|
||||
/** @param array<mixed> $value @return array<string,mixed> */
|
||||
private static function sanitize_search_options(array $value): array {
|
||||
$value = wp_parse_args($value, self::search_defaults());
|
||||
return [
|
||||
'show_keywords' => !empty($value['show_keywords']),
|
||||
'popular_limit' => max(2, min(50, (int) $value['popular_limit'])),
|
||||
'show_input_cat' => !empty($value['show_input_cat']),
|
||||
'in_cat' => absint($value['in_cat']),
|
||||
'more_cats' => array_values(array_filter(array_map('absint', (array) $value['more_cats']))),
|
||||
'show_type' => !empty($value['show_type']),
|
||||
'in_type' => sanitize_key((string) $value['in_type']),
|
||||
'before_html' => wp_kses_post((string) $value['before_html']),
|
||||
'after_html' => wp_kses_post((string) $value['after_html']),
|
||||
];
|
||||
}
|
||||
|
||||
/** @param array<mixed> $value @return array<string,mixed> */
|
||||
private static function sanitize_card_options(array $value): array {
|
||||
$value = wp_parse_args($value, self::card_defaults());
|
||||
$cards = [];
|
||||
foreach ((array) $value['cards'] as $card) {
|
||||
if (!is_array($card)) {
|
||||
continue;
|
||||
}
|
||||
$link = is_array($card['link'] ?? null) ? $card['link'] : [];
|
||||
$cards[] = [
|
||||
'title' => wp_kses_post((string) ($card['title'] ?? '')),
|
||||
'desc' => wp_kses_post((string) ($card['desc'] ?? '')),
|
||||
'icon' => sanitize_text_field((string) ($card['icon'] ?? '')),
|
||||
'customize_icon' => wp_kses_post((string) ($card['customize_icon'] ?? '')),
|
||||
'icon_class' => sanitize_text_field((string) ($card['icon_class'] ?? '')),
|
||||
'link' => [
|
||||
'url' => esc_url_raw((string) ($link['url'] ?? '')),
|
||||
'target' => !empty($link['target']) ? '_blank' : '',
|
||||
'text' => sanitize_text_field((string) ($link['text'] ?? '')),
|
||||
],
|
||||
];
|
||||
}
|
||||
return ['show_widget_bg' => !empty($value['show_widget_bg']), 'icon_radius4' => !empty($value['icon_radius4']), 'cards' => $cards];
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
private static function slider_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];
|
||||
}
|
||||
|
||||
/** @return list<array<string,mixed>> */
|
||||
private static function slide_defaults(): array {
|
||||
$base = defined('AKSRT_URI') ? trailingslashit(AKSRT_URI) . 'assets/vendor/zibll/img/' : '';
|
||||
$slides = [];
|
||||
foreach (['slider-bg.jpg', 'user_t.jpg'] as $image) {
|
||||
$slides[] = [
|
||||
'background' => $base . $image,
|
||||
'link' => ['url' => 'https://www.zibll.com/', 'target' => '_blank'],
|
||||
'text' => ['desc' => '', 'title' => ''],
|
||||
'text_align' => 'left-bottom', 'text_parallax' => 30,
|
||||
'text_size_m' => 20, 'text_size_pc' => 30,
|
||||
];
|
||||
}
|
||||
return $slides;
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
private static function search_defaults(): array {
|
||||
return ['show_keywords' => true, 'popular_limit' => 6, 'show_input_cat' => false, 'in_cat' => 0, 'more_cats' => [], 'show_type' => false, 'in_type' => 'post', 'before_html' => '<div class="em16 font-bold mb10">更优雅的Wordpress主题</div><div>这是导航栏幻灯片多功能组件,可在后台进行配置</div>', 'after_html' => ''];
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
private static function card_defaults(): array {
|
||||
return ['show_widget_bg' => false, 'icon_radius4' => false, 'cards' => [
|
||||
['icon' => 'zibsvg-vip_1', 'customize_icon' => '', 'icon_class' => 'c-yellow', 'link' => [], 'title' => '图标卡片', 'desc' => '这是一个图标卡片示例'],
|
||||
['icon' => 'zibsvg-vip_2', 'customize_icon' => '', 'icon_class' => 'c-blue-2', 'link' => [], 'title' => '原创作品', 'desc' => '这是一个图标卡片示例'],
|
||||
['icon' => 'zibsvg-hot', 'customize_icon' => '', 'icon_class' => 'jb-pink', 'link' => [], 'title' => '灵感来源<badge class="ml6 jb-yellow">NEW</badge>', 'desc' => '这是一个图标卡片示例'],
|
||||
['icon' => 'fa fas fa-ioxhost', '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' => '这是一个图标卡片示例'],
|
||||
]];
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class PageDisplayController extends ControllerBase {
|
||||
}
|
||||
|
||||
public function register_routes(): void {
|
||||
// Banners (generic CRUD — hero, banner kinds)
|
||||
// Homepage content-stream banners.
|
||||
register_rest_route(self::API_NAMESPACE, '/banners', [
|
||||
'methods' => 'GET',
|
||||
'callback' => [$this, 'rest_get_banners'],
|
||||
@@ -40,42 +40,23 @@ class PageDisplayController extends ControllerBase {
|
||||
]);
|
||||
}
|
||||
|
||||
private function normalize_banner_kind($kind): string {
|
||||
return in_array($kind, ['hero', 'banner'], true) ? $kind : 'hero';
|
||||
}
|
||||
|
||||
private function get_banner_kind_query(string $kind): array {
|
||||
if ('banner' === $kind) {
|
||||
return [
|
||||
[
|
||||
'key' => '_aksrt_kind',
|
||||
'value' => 'banner',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
private function get_banner_kind_query(): array {
|
||||
return [
|
||||
'relation' => 'OR',
|
||||
[
|
||||
'key' => '_aksrt_kind',
|
||||
'value' => 'hero',
|
||||
],
|
||||
[
|
||||
'key' => '_aksrt_kind',
|
||||
'compare' => 'NOT EXISTS',
|
||||
'value' => 'banner',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function rest_get_banners(\WP_REST_Request $request): \WP_REST_Response {
|
||||
$kind = $this->normalize_banner_kind($request->get_param('kind') ?: 'hero');
|
||||
$args = [
|
||||
'post_type' => 'aksrt_banner',
|
||||
'posts_per_page' => 100,
|
||||
'post_status' => 'any',
|
||||
'orderby' => 'menu_order',
|
||||
'order' => 'ASC',
|
||||
'meta_query' => $this->get_banner_kind_query($kind),
|
||||
'meta_query' => $this->get_banner_kind_query(),
|
||||
];
|
||||
$posts = get_posts($args);
|
||||
$banners = array_map(function ($post) {
|
||||
@@ -95,7 +76,6 @@ class PageDisplayController extends ControllerBase {
|
||||
'enabled' => get_post_meta($post->ID, '_enabled', true) !== '0',
|
||||
'show_text' => get_post_meta($post->ID, '_show_text', true) !== '0',
|
||||
'show_meta' => get_post_meta($post->ID, '_show_meta', true) === '1',
|
||||
'kind' => get_post_meta($post->ID, '_aksrt_kind', true) ?: 'hero',
|
||||
'sort_order' => $post->menu_order,
|
||||
'text_size_pc' => get_post_meta($post->ID, '_text_size_pc', true) ?: '',
|
||||
'text_size_m' => get_post_meta($post->ID, '_text_size_m', true) ?: '',
|
||||
@@ -108,11 +88,10 @@ class PageDisplayController extends ControllerBase {
|
||||
|
||||
public function rest_create_banner(\WP_REST_Request $request): \WP_REST_Response {
|
||||
$params = $this->get_json_params($request);
|
||||
$kind = $this->normalize_banner_kind($params['kind'] ?? 'hero');
|
||||
$title = sanitize_text_field($params['title'] ?? '');
|
||||
$post_id = wp_insert_post([
|
||||
// Title is optional in admin UI; keep a non-empty WP title for list readability.
|
||||
'post_title' => '' !== $title ? $title : ('banner' === $kind ? 'Banner Slide' : 'Hero Slide'),
|
||||
'post_title' => '' !== $title ? $title : 'Banner Slide',
|
||||
'post_type' => 'aksrt_banner',
|
||||
'post_status' => 'publish',
|
||||
'menu_order' => (int) ($params['sort_order'] ?? 0),
|
||||
@@ -133,7 +112,7 @@ class PageDisplayController extends ControllerBase {
|
||||
update_post_meta($post_id, '_enabled', !array_key_exists('enabled', $params) || !empty($params['enabled']) ? '1' : '0');
|
||||
update_post_meta($post_id, '_show_text', !array_key_exists('show_text', $params) || !empty($params['show_text']) ? '1' : '0');
|
||||
update_post_meta($post_id, '_show_meta', !empty($params['show_meta']) ? '1' : '0');
|
||||
update_post_meta($post_id, '_aksrt_kind', $kind);
|
||||
update_post_meta($post_id, '_aksrt_kind', 'banner');
|
||||
update_post_meta($post_id, '_text_size_pc', sanitize_text_field($params['text_size_pc'] ?? ''));
|
||||
update_post_meta($post_id, '_text_size_m', sanitize_text_field($params['text_size_m'] ?? ''));
|
||||
update_post_meta($post_id, '_text_parallax', !empty($params['text_parallax']) ? '1' : '0');
|
||||
@@ -146,7 +125,7 @@ class PageDisplayController extends ControllerBase {
|
||||
|
||||
public function rest_handle_banner_item(\WP_REST_Request $request): \WP_REST_Response {
|
||||
$id = absint($request['id']);
|
||||
if (!$id || get_post_type($id) !== 'aksrt_banner') {
|
||||
if (!$id || get_post_type($id) !== 'aksrt_banner' || 'banner' !== get_post_meta($id, '_aksrt_kind', true)) {
|
||||
return new \WP_REST_Response(['code' => 'not_found', 'message' => __('幻灯片不存在', 'aksrt')], 404);
|
||||
}
|
||||
|
||||
@@ -156,7 +135,6 @@ class PageDisplayController extends ControllerBase {
|
||||
}
|
||||
|
||||
$params = $this->get_json_params($request);
|
||||
$kind = $this->normalize_banner_kind($params['kind'] ?? get_post_meta($id, '_aksrt_kind', true) ?: 'hero');
|
||||
// Optional title: empty is allowed (UI shows “未命名”); do not 422.
|
||||
$title = sanitize_text_field($params['title'] ?? '');
|
||||
|
||||
@@ -165,7 +143,7 @@ class PageDisplayController extends ControllerBase {
|
||||
'post_title' => $title,
|
||||
]);
|
||||
|
||||
update_post_meta($id, '_aksrt_kind', $kind);
|
||||
update_post_meta($id, '_aksrt_kind', 'banner');
|
||||
update_post_meta($id, '_subtitle', sanitize_text_field($params['subtitle'] ?? ''));
|
||||
update_post_meta($id, '_description', sanitize_textarea_field($params['description'] ?? ''));
|
||||
update_post_meta($id, '_image_url', esc_url_raw($params['image_url'] ?? ''));
|
||||
|
||||
@@ -315,58 +315,68 @@ class GlobalSchema {
|
||||
'version' => '2.0.0',
|
||||
'option_key' => 'aksrt_settings',
|
||||
'groups' => [
|
||||
['key' => 'basic', 'title' => '搜索基础', 'fields' => [
|
||||
['key' => 'search_mode', 'label' => '搜索模式', 'type' => 'radio', 'default' => 'default', 'options' => [
|
||||
['label' => '默认搜索', 'value' => 'default'],
|
||||
['label' => 'AJAX 实时搜索', 'value' => 'ajax'],
|
||||
['label' => '跳转搜索', 'value' => 'redirect'],
|
||||
]],
|
||||
['key' => 'search_placeholder', 'label' => '搜索框提示文字', 'type' => 'input', 'default' => '开启精彩搜索'],
|
||||
]],
|
||||
['key' => 'content-types', 'title' => '搜索内容类型', 'fields' => [
|
||||
['key' => 'search_type_post', 'label' => '文章', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'search_type_user', 'label' => '用户', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'search_type_category', 'label' => '分类', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'search_type_tag', 'label' => '标签', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'search_type_product', 'label' => '商品', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'search_default_type', 'label' => '默认类型', 'type' => 'select', 'default' => 'post', 'options' => [
|
||||
['label' => '文章', 'value' => 'post'],
|
||||
['label' => '用户', 'value' => 'user'],
|
||||
['label' => '分类', 'value' => 'category'],
|
||||
['label' => '标签', 'value' => 'tag'],
|
||||
['label' => '商品', 'value' => 'product'],
|
||||
]],
|
||||
]],
|
||||
['key' => 'features', 'title' => '搜索功能', 'fields' => [
|
||||
['key' => 'search_history_enabled', 'label' => '搜索历史', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'hot_search_enabled', 'label' => '热门搜索', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'hot_search_keywords', 'label' => '热门搜索关键词', 'type' => 'textarea', 'default' => ''],
|
||||
['key' => 'search_suggestions_enabled', 'label' => '搜索建议', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'basic', 'title' => '搜索基础', 'fields' => [
|
||||
['key' => 'search_placeholder', 'label' => '搜索框提示文字', 'type' => 'input', 'default' => '开启精彩搜索'],
|
||||
]],
|
||||
['key' => 'content-types', 'title' => '搜索内容类型', 'fields' => [
|
||||
['key' => 'search_type', 'label' => '显示切换搜索类型按钮', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'search_type_in', 'label' => '默认搜索类型', 'type' => 'radio', 'default' => 'post', 'options' => [
|
||||
['label' => '文章', 'value' => 'post'],
|
||||
['label' => '用户', 'value' => 'user'],
|
||||
]],
|
||||
]],
|
||||
['key' => 'features', 'title' => '搜索功能', 'fields' => [
|
||||
['key' => 'search_history', 'label' => '搜索历史', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'search_popular_key', 'label' => '热门搜索', 'type' => 'switch', 'default' => true],
|
||||
['key' => '404_search_s', 'label' => '在 404 页面显示搜索功能', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'search_posts', 'label' => '搜索框热门文章', 'type' => 'switch', 'default' => true, 'help' => '在搜索面板中显示热门文章列表'],
|
||||
['key' => 'search_no_page', 'label' => '排除页面', 'type' => 'switch', 'default' => true, 'help' => '搜索结果中排除页面(仅显示文章)'],
|
||||
['key' => 'search_exclude_cats', 'label' => '排除分类', 'type' => 'textarea', 'default' => '', 'help' => '搜索结果中排除的分类 ID(逗号分隔)'],
|
||||
['key' => 'search_exclude_cats', 'label' => '排除分类', 'type' => 'taxonomy_select', 'taxonomy' => ['category', 'shop_cat'], 'multiple' => true, 'default' => [], 'help' => '搜索结果中排除的文章或商品分类'],
|
||||
['key' => 'search_custom_key_s', 'label' => '自定义匹配范围', 'type' => 'switch', 'default' => true, 'help' => '启用后可配置搜索匹配字段范围(标题/内容/分类/标签等)'],
|
||||
['key' => 'search_custom_key', 'label' => '匹配字段', 'type' => 'textarea', 'default' => 'title,content', 'help' => '搜索匹配的字段范围(逗号分隔:title/content/excerpt/category/tag/author)'],
|
||||
['key' => 'search_facets', 'label' => '搜索结果筛选', 'type' => 'switch', 'default' => false, 'help' => '启用搜索结果 taxonomy 筛选面板'],
|
||||
['key' => 'search_facets_order', 'label' => '筛选排序', 'type' => 'textarea', 'default' => "category\ntag", 'help' => '筛选 fieldset 显示顺序(每行一个 taxonomy slug)'],
|
||||
['key' => 'search_custom_key', 'label' => '匹配字段', 'type' => 'checkbox', 'default' => ['title', 'content', 'excerpt', 'post_tag', 'forum_topic', 'shop_cat', 'shop_discount'], 'options' => [
|
||||
['label' => '标题', 'value' => 'title'], ['label' => '内容', 'value' => 'content'], ['label' => '简介', 'value' => 'excerpt'],
|
||||
['label' => '分类', 'value' => 'category'], ['label' => '标签', 'value' => 'post_tag'], ['label' => '专题', 'value' => 'topics'],
|
||||
['label' => '评论', 'value' => 'coment'], ['label' => '作者昵称', 'value' => 'user'],
|
||||
['label' => '[帖子]话题', 'value' => 'forum_topic'], ['label' => '[帖子]标签', 'value' => 'forum_tag'],
|
||||
['label' => '[商品]分类', 'value' => 'shop_cat'], ['label' => '[商品]特色标签', 'value' => 'shop_tag'], ['label' => '[商品]优惠活动', 'value' => 'shop_discount'],
|
||||
]],
|
||||
['key' => 'search_facets', 'label' => '搜索筛选', 'type' => 'fieldset', 'sanitize_type' => 'array', 'default' => [], 'dependsOn' => ['key' => 'search_ms_s', 'value' => false], 'help' => '搜索结果中显示的筛选列表;启用 Meilisearch 后由搜索引擎生成关联筛选。', 'fields' => [
|
||||
['key' => 'category', 'label' => '[文章] 分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => []],
|
||||
['key' => 'topics', 'label' => '[文章] 专题', 'type' => 'taxonomy_select', 'taxonomy' => 'topics', 'multiple' => true, 'default' => []],
|
||||
['key' => 'post_tag', 'label' => '[文章] 标签', 'type' => 'taxonomy_select', 'taxonomy' => 'post_tag', 'multiple' => true, 'default' => []],
|
||||
['key' => 'plate_id', 'label' => '[论坛帖子] 板块 ID', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'forum_topic', 'label' => '[论坛帖子] 话题', 'type' => 'taxonomy_select', 'taxonomy' => 'forum_topic', 'multiple' => true, 'default' => []],
|
||||
['key' => 'forum_tag', 'label' => '[论坛帖子] 标签', 'type' => 'taxonomy_select', 'taxonomy' => 'forum_tag', 'multiple' => true, 'default' => []],
|
||||
['key' => 'shop_cat', 'label' => '[商品] 分类', 'type' => 'taxonomy_select', 'taxonomy' => 'shop_cat', 'multiple' => true, 'default' => []],
|
||||
['key' => 'shop_discount', 'label' => '[商品] 优惠活动', 'type' => 'taxonomy_select', 'taxonomy' => 'shop_discount', 'multiple' => true, 'default' => []],
|
||||
['key' => 'shop_tag', 'label' => '[商品] 特色标签', 'type' => 'taxonomy_select', 'taxonomy' => 'shop_tag', 'multiple' => true, 'default' => []],
|
||||
]],
|
||||
]],
|
||||
['key' => 'category-search', 'title' => '分类搜索', 'fields' => [
|
||||
['key' => 'search_cat', 'label' => '启用分类搜索', 'type' => 'switch', 'default' => true, 'help' => '在搜索框旁显示分类选择器'],
|
||||
['key' => 'search_cat_in', 'label' => '默认分类', 'type' => 'input', 'default' => '', 'help' => '默认搜索的分类 ID(留空为全部分类)'],
|
||||
['key' => 'search_more_cat_obj', 'label' => '显示更多分类', 'type' => 'switch', 'default' => true, 'help' => '展开显示全部分类列表'],
|
||||
['key' => 'search_cat_in', 'label' => '默认分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => false, 'default' => '', 'help' => '留空为全部分类'],
|
||||
['key' => 'search_more_cat_obj', 'label' => '允许选择的更多分类', 'type' => 'taxonomy_select', 'taxonomy' => 'category', 'multiple' => true, 'default' => []],
|
||||
]],
|
||||
['key' => 'popular', 'title' => '热门搜索', 'fields' => [
|
||||
['key' => 'search_popular_title', 'label' => '标题', 'type' => 'input', 'default' => '热门搜索'],
|
||||
['key' => 'search_popular_key_num', 'label' => '显示数量', 'type' => 'number', 'default' => 20, 'min' => 1, 'max' => 50],
|
||||
['key' => 'search_popular_sticky', 'label' => '置顶词(每行一个)', 'type' => 'textarea', 'default' => ''],
|
||||
]],
|
||||
['key' => 'meilisearch', 'title' => 'Meilisearch 集成', 'fields' => [
|
||||
['key' => 'search_ms_enabled', 'label' => '启用 Meilisearch', 'type' => 'switch', 'default' => false, 'help' => '启用后搜索请求将发送至 Meilisearch 服务器'],
|
||||
['key' => 'search_ms_api_url', 'label' => 'API 地址', 'type' => 'input', 'default' => '', 'help' => 'Meilisearch 服务器 URL'],
|
||||
['key' => 'search_ms_api_key', 'label' => 'API Key', 'type' => 'input', 'default' => '', 'help' => 'Meilisearch Search API Key(只读密钥)'],
|
||||
['key' => 'search_ms_index_prefix', 'label' => '索引前缀', 'type' => 'input', 'default' => 'aksrt', 'help' => '索引名称前缀'],
|
||||
['key' => 'search_ms_synonyms', 'label' => '同义词(JSON)', 'type' => 'textarea', 'default' => '', 'help' => 'Meilisearch 同义词配置 JSON'],
|
||||
['key' => 'search_popular_key_num', 'label' => '显示数量', 'type' => 'number', 'default' => 20, 'min' => 10, 'max' => 50, 'step' => 2],
|
||||
['key' => 'search_popular_sticky', 'label' => '置顶关键词', 'type' => 'input', 'default' => '', 'help' => '使用逗号分隔;可追加 &type=user 指定搜索类型'],
|
||||
]],
|
||||
['key' => 'meilisearch', 'title' => 'Meilisearch 智能搜索', 'fields' => [
|
||||
['key' => 'search_ms_s', 'label' => '启用 Meilisearch', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'search_ms_opt', 'label' => 'Meilisearch 参数', 'type' => 'fieldset', 'sanitize_type' => 'array', 'default' => [
|
||||
'api_url' => 'http://127.0.0.1:7700', 'api_key' => '', 'index_prefix' => 'aksrt',
|
||||
'synonyms' => [['key' => 'wordpress', 'val' => 'wp,wordp,wordpre']],
|
||||
], 'dependsOn' => ['key' => 'search_ms_s', 'value' => true], 'fields' => [
|
||||
['key' => 'api_url', 'label' => 'API 地址', 'type' => 'input', 'default' => 'http://127.0.0.1:7700'],
|
||||
['key' => 'api_key', 'label' => 'API 密钥', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'index_prefix', 'label' => '索引前缀', 'type' => 'input', 'default' => 'aksrt'],
|
||||
['key' => 'synonyms', 'label' => '同义词', 'type' => 'repeater', 'default' => [['key' => 'wordpress', 'val' => 'wp,wordp,wordpre']], 'addText' => '添加同义词', 'fields' => [
|
||||
['key' => 'key', 'label' => '关键词', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'val', 'label' => '同义词', 'type' => 'textarea', 'default' => ''],
|
||||
]],
|
||||
]],
|
||||
]],
|
||||
],
|
||||
],
|
||||
'email' => [
|
||||
|
||||
@@ -119,7 +119,7 @@ class SchemaPostListList {
|
||||
]],
|
||||
['key' => 'paging_ajax_ias_s', 'label' => 'AJAX 自动加载', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1']],
|
||||
['key' => 'ias_max', 'label' => '自动加载页数', 'type' => 'number', 'default' => 3, 'min' => 0, 'max' => 10, 'dependsOn' => ['key' => 'paging_ajax_s', 'value' => '1']],
|
||||
['key' => 'ajax_trigger', 'label' => '翻页按钮文字', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<i class="fa fa-angle-right"></i>加载更多'],
|
||||
['key' => 'ajax_trigger', 'label' => '翻页按钮文字', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '<i class="fa fas fa-angle-right"></i>加载更多'],
|
||||
['key' => 'ajax_nomore', 'label' => '列表全部加载完毕文案', 'type' => 'textarea', 'sanitize_type' => 'html', 'default' => '没有更多内容了'],
|
||||
],
|
||||
],
|
||||
|
||||
@@ -20,16 +20,10 @@ class SchemaPageDisplay {
|
||||
'version' => '1.1.0',
|
||||
'option_key' => 'aksrt_settings',
|
||||
'groups' => [
|
||||
['key' => 'layout', 'title' => '导航栏布局', 'fields' => [
|
||||
['key' => 'header_fixed', 'label' => '固定导航栏', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_nav_style', 'label' => '导航栏风格', 'type' => 'radio', 'default' => 'default', 'options' => [
|
||||
['label' => '默认', 'value' => 'default'],
|
||||
['label' => '透明', 'value' => 'transparent'],
|
||||
['label' => '毛玻璃', 'value' => 'blur'],
|
||||
]],
|
||||
['key' => 'header_max_width', 'label' => '导航栏最大宽度', 'type' => 'number', 'default' => 1200, 'min' => 0, 'max' => 1600],
|
||||
['key' => 'header_scroll_down_hide', 'label' => '下滑隐藏导航栏', 'type' => 'switch', 'default' => true],
|
||||
]],
|
||||
['key' => 'layout', 'title' => '导航栏布局', 'fields' => [
|
||||
['key' => 'nav_fixed', 'label' => '导航栏一直固定在顶部', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'nav_scroll_down_hide', 'label' => '下滚动隐藏,上滚动显示', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'nav_fixed', 'value' => true]],
|
||||
]],
|
||||
['key' => 'layout-type', 'title' => '布局类型', 'fields' => [
|
||||
['key' => 'header_layout', 'label' => '桌面端布局', 'type' => 'image_select', 'default' => '1', 'options' => self::header_layout_options()],
|
||||
['key' => 'mobile_header_layout', 'label' => '移动端布局', 'type' => 'image_select', 'default' => 'center', 'options' => self::mobile_header_layout_options()],
|
||||
@@ -39,18 +33,15 @@ class SchemaPageDisplay {
|
||||
['label' => '右侧滑出', 'value' => 'right'],
|
||||
]],
|
||||
]],
|
||||
['key' => 'components', 'title' => '导航组件', 'fields' => [
|
||||
['key' => 'header_search_enabled', 'label' => '搜索入口', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_user_menu', 'label' => '用户菜单', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_mobile_drawer', 'label' => '移动端抽屉导航', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_nav_pay_vip', 'label' => '导航栏开通会员按钮', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_nav_user_pay_vip', 'label' => '用户框开通会员按钮', 'type' => 'switch', 'default' => true],
|
||||
]],
|
||||
['key' => 'newposts', 'title' => '发布按钮', 'fields' => [
|
||||
['key' => 'header_newposts_enabled', 'label' => '启用发布按钮', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_newposts_text', 'label' => '按钮文案', 'type' => 'input', 'default' => '<i class="fa fa-pencil"></i> 发布'],
|
||||
['key' => 'header_newposts_radius', 'label' => '按钮圆角(胶囊)', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_newposts_class', 'label' => '按钮颜色', 'type' => 'select', 'default' => 'jb-blue', 'options' => [
|
||||
['key' => 'components', 'title' => '导航组件', 'fields' => [
|
||||
['key' => 'nav_pay_vip', 'label' => '导航栏开通会员按钮', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'nav_user_pay_vip', 'label' => '用户框开通会员按钮', 'type' => 'switch', 'default' => true],
|
||||
]],
|
||||
['key' => 'newposts', 'title' => '发布按钮', 'fields' => [
|
||||
['key' => 'nav_newposts', 'label' => '启用发布按钮', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'nav_newposts_text', 'label' => '按钮文案', 'type' => 'input', 'default' => '<i class="fa fas fa-fw fa-pen"></i>发布', 'dependsOn' => ['key' => 'nav_newposts', 'value' => true]],
|
||||
['key' => 'nav_newposts_radius', 'label' => '按钮圆角(胶囊)', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'nav_newposts', 'value' => true]],
|
||||
['key' => 'nav_newposts_class', 'label' => '按钮颜色', 'type' => 'select', 'default' => 'jb-blue', 'dependsOn' => ['key' => 'nav_newposts', 'value' => true], 'options' => [
|
||||
['label' => '蓝色', 'value' => 'jb-blue'],
|
||||
['label' => '红色', 'value' => 'jb-red'],
|
||||
['label' => '绿色', 'value' => 'jb-green'],
|
||||
@@ -58,13 +49,16 @@ class SchemaPageDisplay {
|
||||
['label' => '紫色', 'value' => 'jb-purple'],
|
||||
['label' => '粉色', 'value' => 'jb-pink'],
|
||||
]],
|
||||
['key' => 'header_newposts_types', 'label' => '发布类型', 'type' => 'checkbox', 'default' => ['post'], 'options' => [
|
||||
['label' => '文章', 'value' => 'post'],
|
||||
]],
|
||||
['key' => 'header_user_newposts_btn', 'label' => '用户卡发布类型', 'type' => 'select', 'default' => 'post', 'options' => [
|
||||
['label' => '文章', 'value' => 'post'],
|
||||
]],
|
||||
['key' => 'header_user_newposts_text', 'label' => '用户卡发布文案', 'type' => 'input', 'default' => '发布内容'],
|
||||
['key' => 'nav_newposts_btns', 'label' => '需显示的按钮', 'type' => 'checkbox', 'default' => ['post', 'bbs_topic', 'bbs_plate', 'bbs_posts'], 'dependsOn' => ['key' => 'nav_newposts', 'value' => true], 'options' => [
|
||||
['label' => '文章', 'value' => 'post'],
|
||||
['label' => '论坛话题', 'value' => 'bbs_topic'],
|
||||
['label' => '论坛版块', 'value' => 'bbs_plate'],
|
||||
['label' => '论坛帖子', 'value' => 'bbs_posts'],
|
||||
]],
|
||||
['key' => 'nav_user_newposts_btn', 'label' => '用户卡发布类型', 'type' => 'select', 'default' => 'post', 'options' => [
|
||||
['label' => '文章', 'value' => 'post'],
|
||||
]],
|
||||
['key' => 'nav_user_newposts_btn_text', 'label' => '用户卡发布文案', 'type' => 'input', 'default' => '发布文章'],
|
||||
]],
|
||||
['key' => 'color', 'title' => '颜色设置', 'fields' => [
|
||||
['key' => 'header_theme_custom', 'label' => '自定义导航栏颜色', 'type' => 'switch', 'default' => false],
|
||||
@@ -74,91 +68,59 @@ class SchemaPageDisplay {
|
||||
]],
|
||||
],
|
||||
],
|
||||
'header-components' => [
|
||||
'key' => 'header-components',
|
||||
'title' => '顶部多功能组件',
|
||||
'description' => '配置顶部组件的显示范围、设备规则、轮播参数、搜索覆盖层与图标卡片。幻灯片图片/文案内容请到「Hero 轮播」「Banner 轮播」管理。',
|
||||
'version' => '1.1.0',
|
||||
'option_key' => 'aksrt_settings',
|
||||
'groups' => [
|
||||
['key' => 'visibility', 'title' => '显示规则', 'fields' => [
|
||||
['key' => 'header_components_search_enabled', 'label' => '启用搜索覆盖层', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'header_components_cards_enabled', 'label' => '启用图标卡片', 'type' => 'switch', 'default' => false],
|
||||
['key' => 'header_components_show_on', 'label' => '按页面类型启用', 'type' => 'checkbox', 'default' => ['home'], 'options' => [
|
||||
['label' => '首页', 'value' => 'home'],
|
||||
['label' => '分类页', 'value' => 'category'],
|
||||
['label' => '标签页', 'value' => 'tag'],
|
||||
['label' => '用户页', 'value' => 'author'],
|
||||
['label' => '文章页', 'value' => 'single'],
|
||||
['label' => '搜索页', 'value' => 'search'],
|
||||
['label' => '其它页面', 'value' => 'page'],
|
||||
]],
|
||||
['key' => 'header_components_device_visibility', 'label' => '设备显示规则', 'type' => 'radio', 'default' => '', 'options' => [
|
||||
['label' => '全部', 'value' => ''],
|
||||
['label' => '仅电脑', 'value' => 'only_pc'],
|
||||
['label' => '仅移动', 'value' => 'only_sm'],
|
||||
]],
|
||||
]],
|
||||
['key' => 'nav-color', 'title' => '导航栏配色', 'fields' => [
|
||||
['key' => 'header_components_nav_color', 'label' => '导航栏文字颜色', 'type' => 'color', 'default' => '#ffffff'],
|
||||
]],
|
||||
['key' => 'slider-config', 'title' => '幻灯片配置', 'fields' => [
|
||||
['key' => 'slider_config_direction', 'label' => '滑动方向', 'type' => 'radio', 'default' => 'horizontal', 'dependsOn' => ['key' => 'header_components_show_on', 'not' => []], 'options' => [
|
||||
['label' => '水平', 'value' => 'horizontal'],
|
||||
['label' => '垂直', 'value' => 'vertical'],
|
||||
]],
|
||||
['key' => 'slider_config_speed', 'label' => '切换速度(ms)', 'type' => 'number', 'default' => 300, 'min' => 100, 'max' => 3000, 'dependsOn' => ['key' => 'header_components_show_on', 'not' => []]],
|
||||
['key' => 'slider_config_button', 'label' => '显示前进后退按钮', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_show_on', 'not' => []]],
|
||||
['key' => 'slider_config_scale_height', 'label' => '缩放高度', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_show_on', 'not' => []]],
|
||||
['key' => 'slider_config_scale', 'label' => '缩放效果', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_show_on', 'not' => []]],
|
||||
['key' => 'slider_config_max_height', 'label' => '最大高度', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'header_components_show_on', 'not' => []]],
|
||||
['key' => 'slider_config_min_height', 'label' => '最小高度', 'type' => 'input', 'default' => '', 'dependsOn' => ['key' => 'header_components_show_on', 'not' => []]],
|
||||
]],
|
||||
['key' => 'search', 'title' => '搜索组件', 'fields' => [
|
||||
['key' => 'header_components_search_pc', 'label' => 'PC 端显示搜索', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_mobile', 'label' => '移动端显示搜索', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_show_keywords', 'label' => '热门搜索', 'type' => 'switch', 'default' => true, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_popular_limit', 'label' => '关键词最多显示', 'type' => 'number', 'default' => 6, 'min' => 2, 'max' => 50, 'dependsOn' => ['key' => 'header_components_search_show_keywords', 'value' => true]],
|
||||
['key' => 'header_components_search_show_input_cat', 'label' => '显示分类搜索', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
['key' => 'header_components_search_show_type', 'label' => '显示类型切换', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true]],
|
||||
[
|
||||
'key' => 'header_components_search_before_html',
|
||||
'label' => '搜索上方额外内容',
|
||||
'type' => 'textarea',
|
||||
'sanitize_type' => 'html',
|
||||
'default' => '<div class="em16 font-bold mb10">更优雅的Wordpress主题</div>
|
||||
<div>这是导航栏幻灯片多功能组件,可在后台进行配置</div>',
|
||||
'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true],
|
||||
'help' => 'Hero 主标题/副标题写在这里(支持 HTML)。勿依赖幻灯片文案,以免与搜索重叠;请注意组件总高度。',
|
||||
],
|
||||
[
|
||||
'key' => 'header_components_search_after_html',
|
||||
'label' => '搜索下方额外内容',
|
||||
'type' => 'textarea',
|
||||
'sanitize_type' => 'html',
|
||||
'default' => '',
|
||||
'dependsOn' => ['key' => 'header_components_search_enabled', 'value' => true],
|
||||
'help' => '支持 HTML;请注意组件总高度。',
|
||||
],
|
||||
]],
|
||||
['key' => 'cards', 'title' => '图标卡片样式', 'fields' => [
|
||||
['key' => 'header_components_filter_blur_devices', 'label' => '组件高斯模糊特效', 'type' => 'checkbox', 'default' => ['pc', 'mobile'], 'options' => [
|
||||
['label' => 'PC', 'value' => 'pc'],
|
||||
['label' => '移动端', 'value' => 'mobile'],
|
||||
]],
|
||||
['key' => 'header_components_card_show_devices', 'label' => '卡片显示设备', 'type' => 'checkbox', 'default' => ['pc', 'mobile'], 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true], 'options' => [
|
||||
['label' => 'PC', 'value' => 'pc'],
|
||||
['label' => '移动端', 'value' => 'mobile'],
|
||||
]],
|
||||
['key' => 'header_components_card_shared_bg', 'label' => '共享卡片背景', 'type' => 'switch', 'default' => false, 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true]],
|
||||
['key' => 'header_components_card_icon_shape', 'label' => '图标形状', 'type' => 'radio', 'default' => 'circle', 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true], 'options' => [
|
||||
['label' => '圆形', 'value' => 'circle'],
|
||||
['label' => '方形', 'value' => 'square'],
|
||||
]],
|
||||
]],
|
||||
['key' => 'icon-cards', 'title' => '图标卡片列表', 'fields' => [
|
||||
['key' => 'header_components_icon_cards', 'label' => '图标卡片', 'type' => 'repeater', 'sanitize_type' => 'array', 'default' => [], 'dependsOn' => ['key' => 'header_components_cards_enabled', 'value' => true]],
|
||||
]],
|
||||
'header-components' => [
|
||||
'key' => 'header-components',
|
||||
'title' => '顶部多功能组件',
|
||||
'description' => 'Zibll 顶部幻灯、搜索覆盖层与图标卡片的原始字段契约。',
|
||||
'version' => '2.0.0',
|
||||
'option_key' => 'aksrt_settings',
|
||||
'groups' => [
|
||||
['key' => 'visibility', 'title' => '显示规则', 'fields' => [
|
||||
['key' => 'header_slider_show', 'label' => '启用顶部多功能组件的页面', 'type' => 'checkbox', 'default' => [], 'options' => [
|
||||
['label' => '首页', 'value' => 'home'],
|
||||
['label' => '分类页', 'value' => 'category'],
|
||||
['label' => '标签页', 'value' => 'tag'],
|
||||
['label' => '用户页', 'value' => 'author'],
|
||||
['label' => '文章页', 'value' => 'single'],
|
||||
['label' => '搜索页', 'value' => 'search'],
|
||||
['label' => '其它页面', 'value' => 'page'],
|
||||
['label' => '专题页', 'value' => 'topics'],
|
||||
['label' => '论坛首页', 'value' => 'forum_home'],
|
||||
['label' => '论坛版块', 'value' => 'forum_plate'],
|
||||
['label' => '论坛帖子', 'value' => 'forum_post'],
|
||||
]],
|
||||
['key' => 'header_slider_show_type', 'label' => '显示规则', 'type' => 'radio', 'default' => '', 'dependsOn' => ['key' => 'header_slider_show', 'not' => []], 'options' => [
|
||||
['label' => '全部', 'value' => ''],
|
||||
['label' => '仅电脑', 'value' => 'only_pc'],
|
||||
['label' => '仅移动', 'value' => 'only_sm'],
|
||||
]],
|
||||
['key' => 'header_slider_nav_color', 'label' => '导航栏文字颜色', 'type' => 'color', 'default' => '#ffffff', 'dependsOn' => ['key' => 'header_slider_show', 'not' => []]],
|
||||
]],
|
||||
['key' => 'slides', 'title' => '幻灯片', 'fields' => [
|
||||
['key' => 'header_slider', 'label' => '幻灯片项目', 'type' => 'repeater', 'sanitize_type' => 'array', 'default' => self::header_slider_defaults(), 'addText' => '添加幻灯片', 'fields' => [
|
||||
['key' => 'background', 'label' => '背景图片', 'type' => 'media', 'default' => ''],
|
||||
['key' => 'background_video', 'label' => '视频背景', 'type' => 'media', 'default' => '', 'help' => 'PC 端视频优先;移动端仅显示背景图片。'],
|
||||
['key' => 'video', 'label' => '视频内容', 'type' => 'input', 'default' => ''],
|
||||
['key' => 'hide', 'label' => '隐藏设备', 'type' => 'radio', 'default' => '', 'options' => [
|
||||
['label' => '不隐藏', 'value' => ''],
|
||||
['label' => 'PC 端不显示', 'value' => 'pc'],
|
||||
['label' => '移动端不显示', 'value' => 'm'],
|
||||
]],
|
||||
['key' => 'link', 'label' => '跳转链接', 'type' => 'json', 'sanitize_type' => 'array', 'default' => ['url' => '', 'target' => '', 'text' => '']],
|
||||
['key' => 'image_layer', 'label' => '叠加图层', 'type' => 'json', 'sanitize_type' => 'array', 'default' => [], 'help' => '每层支持 image、free_size、align、parallax、parallax_scale、parallax_opacity。'],
|
||||
['key' => 'text', 'label' => '叠加文案', 'type' => 'json', 'sanitize_type' => 'array', 'default' => ['title' => '', 'desc' => '', 'text_align' => 'left-bottom', 'text_size_pc' => 30, 'text_size_m' => 20, 'parallax' => 40]],
|
||||
]],
|
||||
['key' => 'header_slider_option', 'label' => '幻灯片参数', 'type' => 'json', 'sanitize_type' => 'array', 'default' => self::header_slider_option_defaults()],
|
||||
]],
|
||||
['key' => 'search', 'title' => '搜索组件', 'fields' => [
|
||||
['key' => 'header_slider_search_s', 'label' => '显示搜索组件', 'type' => 'checkbox', 'default' => ['pc_s', 'm_s'], 'options' => self::device_options()],
|
||||
['key' => 'header_slider_search_option', 'label' => '搜索组件参数', 'type' => 'json', 'sanitize_type' => 'array', 'default' => self::header_slider_search_defaults()],
|
||||
]],
|
||||
['key' => 'cards', 'title' => '图标卡片组件', 'fields' => [
|
||||
['key' => 'header_slider_card_s', 'label' => '显示图标卡片', 'type' => 'checkbox', 'default' => ['pc_s', 'm_s'], 'options' => self::device_options()],
|
||||
['key' => 'header_slider_card_option', 'label' => '图标卡片参数', 'type' => 'json', 'sanitize_type' => 'array', 'default' => self::header_slider_card_defaults()],
|
||||
['key' => 'header_slider_filter_blur', 'label' => '组件高斯模糊特效', 'type' => 'checkbox', 'default' => ['pc_s', 'm_s'], 'options' => self::device_options()],
|
||||
]],
|
||||
],
|
||||
],
|
||||
'category' => [
|
||||
@@ -341,43 +303,6 @@ class SchemaPageDisplay {
|
||||
]],
|
||||
],
|
||||
],
|
||||
'menu-decoration' => [
|
||||
'key' => 'menu-decoration',
|
||||
'title' => '菜单装饰',
|
||||
'version' => '1.0.0',
|
||||
'option_key' => 'aksrt_settings',
|
||||
'groups' => [
|
||||
['key' => 'icon', 'title' => '菜单图标', 'fields' => [
|
||||
['key' => 'menu_icon_enabled', 'label' => '显示菜单图标', 'type' => 'switch', 'default' => true],
|
||||
['key' => 'menu_badge_enabled', 'label' => '显示菜单徽章', 'type' => 'switch', 'default' => true],
|
||||
]],
|
||||
['key' => 'submenu', 'title' => '下拉子菜单', 'fields' => [
|
||||
['key' => 'menu_submenu_style', 'label' => '子菜单样式', 'type' => 'radio', 'default' => 'dropdown', 'options' => [
|
||||
['label' => '普通下拉', 'value' => 'dropdown'],
|
||||
['label' => '多列下拉', 'value' => 'mega'],
|
||||
['label' => '图文卡片', 'value' => 'cards'],
|
||||
]],
|
||||
['key' => 'menu_submenu_columns', 'label' => '多列列数', 'type' => 'number', 'default' => 1, 'min' => 1, 'max' => 5],
|
||||
['key' => 'menu_submenu_width', 'label' => '子菜单宽度 (px)', 'type' => 'number', 'default' => 220, 'min' => 160, 'max' => 800],
|
||||
]],
|
||||
['key' => 'effect', 'title' => '交互效果', 'fields' => [
|
||||
['key' => 'menu_hover_effect', 'label' => 'Hover 效果', 'type' => 'radio', 'default' => 'underline', 'options' => [
|
||||
['label' => '下划线', 'value' => 'underline'],
|
||||
['label' => '背景色', 'value' => 'background'],
|
||||
['label' => '文字变色', 'value' => 'color'],
|
||||
['label' => '无效果', 'value' => 'none'],
|
||||
]],
|
||||
['key' => 'menu_item_padding', 'label' => '菜单项内边距 (px)', 'type' => 'number', 'default' => 12, 'min' => 4, 'max' => 32],
|
||||
]],
|
||||
['key' => 'mobile', 'title' => '移动端菜单', 'fields' => [
|
||||
['key' => 'menu_mobile_style', 'label' => '移动端菜单样式', 'type' => 'radio', 'default' => 'drawer', 'options' => [
|
||||
['label' => '抽屉', 'value' => 'drawer'],
|
||||
['label' => '全屏', 'value' => 'fullscreen'],
|
||||
['label' => '下拉', 'value' => 'dropdown'],
|
||||
]],
|
||||
]],
|
||||
],
|
||||
],
|
||||
'footer' => [
|
||||
'key' => 'footer',
|
||||
'title' => '底部页脚',
|
||||
@@ -465,8 +390,82 @@ class SchemaPageDisplay {
|
||||
];
|
||||
}
|
||||
|
||||
/** @return list<array{label:string,value:string,image:string}> */
|
||||
private static function header_layout_options(): array {
|
||||
/** @return list<array{label:string,value:string}> */
|
||||
private static function device_options(): array {
|
||||
return [
|
||||
['label' => '电脑端', 'value' => 'pc_s'],
|
||||
['label' => '移动端', 'value' => 'm_s'],
|
||||
];
|
||||
}
|
||||
|
||||
/** @return list<array<string,mixed>> */
|
||||
private static function header_slider_defaults(): array {
|
||||
$base = defined('AKSRT_URI') ? trailingslashit(AKSRT_URI) . 'assets/vendor/zibll/img/' : '';
|
||||
$slides = [];
|
||||
foreach (['slider-bg.jpg', 'user_t.jpg'] as $image) {
|
||||
$slides[] = [
|
||||
'background' => $base . $image,
|
||||
'link' => ['url' => 'https://www.zibll.com/', 'target' => '_blank'],
|
||||
'text' => ['desc' => '', 'title' => ''],
|
||||
'text_align' => 'left-bottom',
|
||||
'text_parallax' => 30,
|
||||
'text_size_m' => 20,
|
||||
'text_size_pc' => 30,
|
||||
];
|
||||
}
|
||||
return $slides;
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
private static function header_slider_option_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,
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
private static function header_slider_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><div>这是导航栏幻灯片多功能组件,可在后台进行配置</div>',
|
||||
'after_html' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<string,mixed> */
|
||||
private static function header_slider_card_defaults(): array {
|
||||
return [
|
||||
'show_widget_bg' => false,
|
||||
'icon_radius4' => false,
|
||||
'cards' => [
|
||||
['icon' => 'zibsvg-vip_1', 'customize_icon' => '', 'icon_class' => 'c-yellow', 'link' => [], 'title' => '图标卡片', 'desc' => '这是一个图标卡片示例'],
|
||||
['icon' => 'zibsvg-vip_2', 'customize_icon' => '', 'icon_class' => 'c-blue-2', 'link' => [], 'title' => '原创作品', 'desc' => '这是一个图标卡片示例'],
|
||||
['icon' => 'zibsvg-hot', 'customize_icon' => '', 'icon_class' => 'jb-pink', 'link' => [], 'title' => '灵感来源<badge class="ml6 jb-yellow">NEW</badge>', 'desc' => '这是一个图标卡片示例'],
|
||||
['icon' => 'fa fas fa-ioxhost', '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' => '这是一个图标卡片示例'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/** @return list<array{label:string,value:string,image:string}> */
|
||||
private static function header_layout_options(): array {
|
||||
$base = defined('AKSRT_URI') ? trailingslashit(AKSRT_URI) . 'assets/images/header-layout/' : '';
|
||||
return [
|
||||
['label' => '布局 1(经典)', 'value' => '1', 'image' => $base . 'header_layout_1.png'],
|
||||
|
||||
Reference in new issue
Block a user