feat(frontend): replace article system with Zibll 9.0
This commit is contained in:
1 parent
2881c69e9c
commit
0f2ac6c34a
69 files changed
+2603
-4163
No files matched your search
@@ -71,7 +71,6 @@ class DomainModel {
|
||||
return [
|
||||
'cover_images' => '',
|
||||
'custom_excerpt' => '',
|
||||
'layout_override' => '',
|
||||
'header_image_mode' => '',
|
||||
'show_toc' => '',
|
||||
'show_reading_progress' => '',
|
||||
@@ -105,7 +104,6 @@ class DomainModel {
|
||||
return [
|
||||
'cover_url' => '',
|
||||
'description' => '',
|
||||
'layout_mode' => '',
|
||||
'show_sidebar' => '',
|
||||
'show_header' => true,
|
||||
'show_featured' => false,
|
||||
|
||||
@@ -214,7 +214,7 @@ class HomeModules {
|
||||
return [
|
||||
['type' => 'hero', 'config' => []],
|
||||
['type' => 'tabs', 'config' => ['count' => 8]],
|
||||
['type' => 'recent', 'config' => ['count' => 8, 'layout' => 'grid-cms']],
|
||||
['type' => 'recent', 'config' => ['count' => 8, 'layout' => 'card']],
|
||||
['type' => 'ranking', 'config' => ['metric' => 'downloads', 'count' => 6]],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -163,14 +163,6 @@ class PostMetaBox {
|
||||
<small class="description"><?php esc_html_e('用于列表多图模式,填写附件 ID(逗号分隔)。', 'aksrt'); ?></small>
|
||||
</p>
|
||||
|
||||
<p><strong><?php esc_html_e('列表布局覆盖', 'aksrt'); ?></strong></p>
|
||||
<select name="aksrt_post_meta[layout_override]" class="widefat">
|
||||
<option value="" <?php selected($meta['layout_override'], ''); ?>><?php esc_html_e('跟随全局', 'aksrt'); ?></option>
|
||||
<option value="card" <?php selected($meta['layout_override'], 'card'); ?>><?php esc_html_e('卡片', 'aksrt'); ?></option>
|
||||
<option value="list" <?php selected($meta['layout_override'], 'list'); ?>><?php esc_html_e('列表', 'aksrt'); ?></option>
|
||||
<option value="mini" <?php selected($meta['layout_override'], 'mini'); ?>><?php esc_html_e('迷你', 'aksrt'); ?></option>
|
||||
</select>
|
||||
|
||||
<p><strong><?php esc_html_e('侧栏布局(Zibll show_layout)', 'aksrt'); ?></strong></p>
|
||||
<?php
|
||||
$show_layout = (string) get_post_meta($post->ID, '_aksrt_show_layout', true);
|
||||
@@ -251,9 +243,9 @@ class PostMetaBox {
|
||||
<p><strong><?php esc_html_e('副标题', 'aksrt'); ?></strong></p>
|
||||
<input type="text" name="aksrt_post_meta[subtitle]" value="<?php echo esc_attr($meta['subtitle']); ?>" class="widefat" placeholder="<?php esc_attr_e('可选,显示在标题下方', 'aksrt'); ?>">
|
||||
|
||||
<p><strong><?php esc_html_e('外链特色图', 'aksrt'); ?></strong></p>
|
||||
<input type="url" name="aksrt_post_meta[thumbnail_url]" value="<?php echo esc_url($meta['thumbnail_url']); ?>" class="widefat" placeholder="<?php esc_attr_e('外部图片 URL(覆盖特色图片)', 'aksrt'); ?>">
|
||||
<small class="description"><?php esc_html_e('填入外部图片 URL 将替代特色图片。', 'aksrt'); ?></small>
|
||||
<p><strong><?php esc_html_e('外链特色图', 'aksrt'); ?></strong></p>
|
||||
<input type="url" name="aksrt_post_meta[thumbnail_url]" value="<?php echo esc_url($meta['thumbnail_url']); ?>" class="widefat" placeholder="<?php esc_attr_e('外部图片 URL(覆盖特色图片)', 'aksrt'); ?>">
|
||||
<small class="description"><?php esc_html_e('未设置文章特色图片时使用此外链图片。', 'aksrt'); ?></small>
|
||||
|
||||
<p><strong><?php esc_html_e('幻灯片封面', 'aksrt'); ?></strong></p>
|
||||
<input type="text" name="aksrt_post_meta[featured_slide]" value="<?php echo esc_attr($meta['featured_slide']); ?>" class="widefat" placeholder="<?php esc_attr_e('图片 URL,逗号分隔', 'aksrt'); ?>">
|
||||
@@ -359,7 +351,7 @@ class PostMetaBox {
|
||||
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
|
||||
if (!current_user_can('edit_post', $post_id)) return;
|
||||
|
||||
// Zibll show_layout (independent of list layout_override).
|
||||
// Zibll show_layout.
|
||||
$show_layout = isset($_POST['aksrt_show_layout']) ? sanitize_key((string) wp_unslash($_POST['aksrt_show_layout'])) : '';
|
||||
if (!in_array($show_layout, ['no_sidebar', 'sidebar_left', 'sidebar_right'], true)) {
|
||||
$show_layout = '';
|
||||
@@ -391,7 +383,6 @@ class PostMetaBox {
|
||||
$sanitized = [
|
||||
'cover_images' => isset($raw['cover_images']) ? sanitize_text_field($raw['cover_images']) : '',
|
||||
'custom_excerpt' => isset($raw['custom_excerpt']) ? sanitize_textarea_field($raw['custom_excerpt']) : '',
|
||||
'layout_override' => isset($raw['layout_override']) ? sanitize_key($raw['layout_override']) : '',
|
||||
'header_image_mode' => isset($raw['header_image_mode']) ? sanitize_key($raw['header_image_mode']) : '',
|
||||
// New route: '' follow | '1' force on | '0' force off.
|
||||
'show_toc' => isset($raw['show_toc']) && in_array((string) $raw['show_toc'], ['', '0', '1'], true) ? (string) $raw['show_toc'] : '',
|
||||
@@ -417,11 +408,6 @@ class PostMetaBox {
|
||||
'maxheight' => isset($raw['maxheight']) ? max(0, (int) $raw['maxheight']) : 0,
|
||||
];
|
||||
|
||||
$valid_modes = ['', 'card', 'list', 'mini', 'grid-cms'];
|
||||
if (!in_array($sanitized['layout_override'], $valid_modes, true)) {
|
||||
$sanitized['layout_override'] = '';
|
||||
}
|
||||
|
||||
$valid_header_modes = ['', 'featured', 'auto', 'none'];
|
||||
if (!in_array($sanitized['header_image_mode'], $valid_header_modes, true)) {
|
||||
$sanitized['header_image_mode'] = '';
|
||||
@@ -476,10 +462,9 @@ class PostMetaBox {
|
||||
echo esc_html($views > 0 ? (string) $views : '—');
|
||||
} elseif ($column === 'aksrt_likes') {
|
||||
$likes = (int) ($meta['likes'] ?? 0);
|
||||
$layout = esc_attr($meta['layout_override'] ?? '');
|
||||
$toc = esc_attr($meta['show_toc'] ?? '');
|
||||
$mh = (int) ($meta['maxheight'] ?? 0);
|
||||
echo '<span class="aksrt-col-data" data-views="' . (int) ($meta['views'] ?? 0) . '" data-likes="' . $likes . '" data-layout="' . $layout . '" data-toc="' . $toc . '" data-maxheight="' . $mh . '">' . esc_html($likes > 0 ? (string) $likes : '—') . '</span>';
|
||||
echo '<span class="aksrt-col-data" data-views="' . (int) ($meta['views'] ?? 0) . '" data-likes="' . $likes . '" data-toc="' . $toc . '" data-maxheight="' . $mh . '">' . esc_html($likes > 0 ? (string) $likes : '—') . '</span>';
|
||||
} elseif ($column === 'aksrt_sales') {
|
||||
$this->render_sales_column($post_id);
|
||||
}
|
||||
@@ -631,17 +616,6 @@ class PostMetaBox {
|
||||
<span class="title"><?php esc_html_e('点赞数', 'aksrt'); ?></span>
|
||||
<input type="number" name="aksrt_qe_likes" min="0" step="1" value="" class="aksrt-qe-likes">
|
||||
</label>
|
||||
<label class="alignleft">
|
||||
<span class="title"><?php esc_html_e('布局', 'aksrt'); ?></span>
|
||||
<select name="aksrt_qe_layout" class="aksrt-qe-layout">
|
||||
<option value="-1"><?php esc_html_e('— 不更改 —', 'aksrt'); ?></option>
|
||||
<option value=""><?php esc_html_e('跟随全局', 'aksrt'); ?></option>
|
||||
<option value="card"><?php esc_html_e('卡片', 'aksrt'); ?></option>
|
||||
<option value="list"><?php esc_html_e('列表', 'aksrt'); ?></option>
|
||||
<option value="mini"><?php esc_html_e('迷你', 'aksrt'); ?></option>
|
||||
<option value="grid-cms"><?php esc_html_e('CMS网格', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="alignleft">
|
||||
<span class="title"><?php esc_html_e('目录树', 'aksrt'); ?></span>
|
||||
<select name="aksrt_qe_toc" class="aksrt-qe-toc">
|
||||
@@ -771,14 +745,6 @@ class PostMetaBox {
|
||||
? max(0, (int) $_POST['aksrt_qe_likes'])
|
||||
: (int) ($existing['likes'] ?? 0);
|
||||
|
||||
$layout = $existing['layout_override'] ?? '';
|
||||
if (isset($_POST['aksrt_qe_layout']) && $_POST['aksrt_qe_layout'] !== '-1') {
|
||||
$layout = sanitize_key((string) $_POST['aksrt_qe_layout']);
|
||||
if (!in_array($layout, ['', 'card', 'list', 'mini', 'grid-cms'], true)) {
|
||||
$layout = $existing['layout_override'] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
$toc = $existing['show_toc'] ?? '';
|
||||
if (isset($_POST['aksrt_qe_toc']) && $_POST['aksrt_qe_toc'] !== '-1') {
|
||||
$toc_v = sanitize_key((string) $_POST['aksrt_qe_toc']);
|
||||
@@ -791,7 +757,6 @@ class PostMetaBox {
|
||||
|
||||
$existing['views'] = $views;
|
||||
$existing['likes'] = $likes;
|
||||
$existing['layout_override'] = $layout;
|
||||
$existing['show_toc'] = $toc;
|
||||
$existing['maxheight'] = $mh;
|
||||
|
||||
@@ -835,7 +800,6 @@ class PostMetaBox {
|
||||
|
||||
var v = data.getAttribute('data-views') || '';
|
||||
var l = data.getAttribute('data-likes') || '';
|
||||
var layout = data.getAttribute('data-layout') || '';
|
||||
var toc = data.getAttribute('data-toc') || '';
|
||||
var mh = data.getAttribute('data-maxheight') || '';
|
||||
|
||||
@@ -844,8 +808,6 @@ class PostMetaBox {
|
||||
if (qv) qv.value = v;
|
||||
if (ql) ql.value = l;
|
||||
|
||||
var qLayout = form.querySelector('.aksrt-qe-layout');
|
||||
if (qLayout) qLayout.value = layout;
|
||||
var qToc = form.querySelector('.aksrt-qe-toc');
|
||||
if (qToc) qToc.value = toc;
|
||||
var qMh = form.querySelector('.aksrt-qe-maxheight');
|
||||
|
||||
@@ -316,7 +316,7 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
||||
|| is_page_template('templates/pages/page-user-home.php');
|
||||
$is_fixed_homepage = function_exists('aksrt_is_fixed_homepage_request') && aksrt_is_fixed_homepage_request();
|
||||
|
||||
// CMS 形态判定(可能在博客流页面也需要 grid-cms 卡片样式)
|
||||
// CMS route detection.
|
||||
$is_cms_mode = function_exists('aksrt_is_cms_mode') ? aksrt_is_cms_mode() : false;
|
||||
// 首页/归档/搜索:卡片 + 侧栏
|
||||
if ($is_home_or_archive) {
|
||||
@@ -755,10 +755,8 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
||||
$enqueue_module('pages');
|
||||
}
|
||||
|
||||
// grid-cms 卡片样式
|
||||
// Resource archives use the canonical Zibll article-card stylesheet.
|
||||
if ($is_resource_archive || $is_single_resource || ($is_cms_mode && ($is_home_or_archive || $is_static_page) && !$is_fixed_homepage)) {
|
||||
$enqueue_module('post-card-cms');
|
||||
// 确保 post-card 基础样式也加载(若上面分支未加)
|
||||
if (!$is_home_or_archive && !$is_single_post && !$is_static_page) {
|
||||
$enqueue_module('post-card');
|
||||
}
|
||||
@@ -797,7 +795,6 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
||||
$enqueue_module('home-modules');
|
||||
$enqueue_module('post-card'); // 模块内复用
|
||||
$enqueue_module('header-components'); // header components 模块依赖
|
||||
$enqueue_module('post-card-cms'); // grid-cms 卡片依赖
|
||||
|
||||
wp_enqueue_script(
|
||||
'aksrt-cms-home-modules',
|
||||
|
||||
@@ -72,8 +72,9 @@ trait ScriptsPart1c {
|
||||
|
||||
// ===== 7. JS =====
|
||||
|
||||
// Swiper.js(首页/归档/CMS 模块/单篇文章页加载)
|
||||
$needs_swiper = $is_home_or_archive || $is_single_post || $is_single_resource;
|
||||
// Swiper.js(文章列表媒体及单篇资源页加载)
|
||||
$needs_post_list_media = wp_style_is('aksrt-post-card', 'enqueued');
|
||||
$needs_swiper = $needs_post_list_media || $is_home_or_archive || $is_single_post || $is_single_resource;
|
||||
if ($needs_swiper) {
|
||||
wp_enqueue_style(
|
||||
'aksrt-swiper',
|
||||
@@ -119,6 +120,17 @@ trait ScriptsPart1c {
|
||||
true
|
||||
);
|
||||
|
||||
if ($needs_post_list_media) {
|
||||
$grade_js = get_template_directory() . '/assets/js/grade.min.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-grade',
|
||||
$base_uri . '/assets/js/grade.min.js',
|
||||
[],
|
||||
file_exists($grade_js) ? (string) filemtime($grade_js) : $version,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
$notyf_js = get_template_directory() . '/assets/js/notyf.js';
|
||||
wp_enqueue_script(
|
||||
'aksrt-notyf',
|
||||
@@ -173,6 +185,8 @@ trait ScriptsPart1c {
|
||||
$deps = ['aksrt-rehydrate', 'aksrt-runtime'];
|
||||
if ($handle === 'aksrt-core-slider') {
|
||||
$deps = array_merge($deps, $needs_swiper ? ['aksrt-swiper'] : []);
|
||||
} elseif ($handle === 'aksrt-core-misc' && $needs_post_list_media) {
|
||||
$deps[] = 'aksrt-grade';
|
||||
} elseif ($handle === 'aksrt-core-modal-runtime') {
|
||||
$deps = array_merge($deps, [
|
||||
'aksrt-core-modal-telemetry',
|
||||
@@ -558,15 +572,14 @@ trait ScriptsPart1c {
|
||||
'commentPaginationMode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_pagination_mode() : 'numbered',
|
||||
'homepagePostsPerPage' => function_exists('aksrt_homepage_get_tab_posts_per_page') ? aksrt_homepage_get_tab_posts_per_page() : (int) get_option('posts_per_page'),
|
||||
'homepageDefaultSort' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_default_sort() : 'modified',
|
||||
'homepageDefaultView' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_default_view() : 'list',
|
||||
'homepageSortAjax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_sort_ajax_enabled() : true,
|
||||
'homepageStickyTabs' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::homepage_sticky_tabs_enabled() : true,
|
||||
'homePostsListEnabled' => !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_posts_list_enabled(),
|
||||
'homeListSortEnabled' => !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_list_sort_enabled(),
|
||||
'homeListSortDropdown' => class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::home_list_sort_dropdown(),
|
||||
// AJAX 翻页文案
|
||||
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger_text'] ?? '') !== '') ? $t : __('加载更多', 'aksrt'),
|
||||
'ajaxNomore' => (class_exists('\AKSRT\Settings\Settings') && ($n = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_nomore_text'] ?? '') !== '') ? $n : __('没有更多了', 'aksrt'),
|
||||
'ajaxTrigger' => (class_exists('\AKSRT\Settings\Settings') && ($t = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_trigger'] ?? '') !== '') ? $t : '<i class="fa fa-angle-right"></i>加载更多',
|
||||
'ajaxNomore' => (class_exists('\AKSRT\Settings\Settings') && ($n = \AKSRT\Settings\Settings::get_post_list_style_settings()['ajax_nomore'] ?? '') !== '') ? $n : __('没有更多内容了', 'aksrt'),
|
||||
'ajaxLoading' => __('正在加载...', 'aksrt'),
|
||||
'iasMax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['ias_max'] : 3,
|
||||
'commentIasAuto' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias'] : true,
|
||||
@@ -585,10 +598,10 @@ trait ScriptsPart1c {
|
||||
'identity' => true,
|
||||
'badge' => true,
|
||||
],
|
||||
'stickyEnabled' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_enabled'] : true,
|
||||
'stickyPages' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_pages'] : ['home', 'cat'],
|
||||
'badgeShow' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['badge_show'] : true,
|
||||
'badgeTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['badge_types'] : ['pay', 'tag', 'cat'],
|
||||
'stickyEnabled' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s']) : true,
|
||||
'stickyPages' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['sticky_s'] : ['home', 'cat'],
|
||||
'badgeShow' => class_exists('\AKSRT\Settings\Settings') ? !empty(\AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show']) : true,
|
||||
'badgeTypes' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings()['list_badge_show'] : ['pay', 'tag', 'cat'],
|
||||
'search' => [
|
||||
'mode' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::search_mode() : 'default',
|
||||
'placeholder' => function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索...', 'aksrt'),
|
||||
|
||||
@@ -274,10 +274,6 @@ class Shortcodes {
|
||||
* 用统一渲染器输出文章列表,避免内容里手写卡片循环。
|
||||
*/
|
||||
public function render_posts(array $atts = [], string $content = ''): string {
|
||||
if (!function_exists('aksrt_render_post_list')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$a = shortcode_atts([
|
||||
'count' => 6,
|
||||
'cat' => '',
|
||||
@@ -309,10 +305,13 @@ class Shortcodes {
|
||||
$mode = in_array($a['mode'], ['card', 'list', 'mini'], true) ? $a['mode'] : 'card';
|
||||
|
||||
$query = new \WP_Query($query_args);
|
||||
$html = aksrt_render_post_list($query, [
|
||||
'context' => 'widget',
|
||||
'mode' => $mode,
|
||||
], false);
|
||||
if ($mode === 'mini') {
|
||||
$html = aksrt_render_mini_list($query, [], false);
|
||||
} else {
|
||||
$html = aksrt_render_post_list([
|
||||
'type' => $mode === 'card' ? 'card' : 'list',
|
||||
], $query, false);
|
||||
}
|
||||
wp_reset_postdata();
|
||||
|
||||
return '<div class="aksrt-shortcode-posts">' . $html . '</div>';
|
||||
|
||||
@@ -66,7 +66,6 @@ class TermMeta {
|
||||
'header_style' => 'cover',
|
||||
'cover_enabled' => true,
|
||||
'desc_enabled' => true,
|
||||
'list_mode' => 'grid',
|
||||
'filter_bar' => true,
|
||||
'sidebar' => true,
|
||||
'per_page' => 12,
|
||||
@@ -77,25 +76,6 @@ class TermMeta {
|
||||
$saved = [];
|
||||
}
|
||||
|
||||
// Empty term layout_mode means follow global post-list settings (Zibll).
|
||||
// Do not fall back to page-display list_mode=grid which forced card everywhere.
|
||||
$layout_preset = isset($saved['layout_mode']) ? sanitize_key((string) $saved['layout_mode']) : '';
|
||||
if ($layout_preset === '') {
|
||||
$resolved_layout = ['mode' => '', 'card_style' => ''];
|
||||
$layout_mode = '';
|
||||
} else {
|
||||
$layout_mode = $layout_preset;
|
||||
$layout_map = [
|
||||
'grid' => ['mode' => 'card', 'card_style' => 'thumb'],
|
||||
'card' => ['mode' => 'card', 'card_style' => 'thumb'],
|
||||
'list' => ['mode' => 'list', 'card_style' => 'thumb'],
|
||||
'compact' => ['mode' => 'list', 'card_style' => 'compact'],
|
||||
'mini' => ['mode' => 'mini', 'card_style' => 'thumb'],
|
||||
'grid-cms' => ['mode' => 'grid-cms', 'card_style' => 'thumb'],
|
||||
];
|
||||
$resolved_layout = $layout_map[$layout_mode] ?? ['mode' => 'list', 'card_style' => 'thumb'];
|
||||
}
|
||||
|
||||
$header_style = (string) ($global['header_style'] ?? 'simple');
|
||||
if (!in_array($header_style, ['cover', 'simple', 'none'], true)) {
|
||||
$header_style = 'simple';
|
||||
@@ -126,9 +106,6 @@ class TermMeta {
|
||||
|
||||
return [
|
||||
'taxonomy' => $taxonomy,
|
||||
'layout_mode' => $resolved_layout['mode'],
|
||||
'card_style' => $resolved_layout['card_style'],
|
||||
'layout_preset' => $layout_mode,
|
||||
'header_style' => $header_style,
|
||||
'show_sidebar' => $sidebar_enabled,
|
||||
'show_cover' => $header_style === 'cover' && !empty($global['cover_enabled']) && $cover_url !== '',
|
||||
@@ -191,15 +168,6 @@ class TermMeta {
|
||||
<input type="url" name="aksrt_term_meta[cover_url]" id="aksrt_term_cover_url" value="" placeholder="https://...">
|
||||
<p class="description"><?php esc_html_e('分类/标签页顶部封面图,留空则不显示。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<div class="form-field">
|
||||
<label for="aksrt_term_layout"><?php esc_html_e('列表布局', 'aksrt'); ?></label>
|
||||
<select name="aksrt_term_meta[layout_mode]" id="aksrt_term_layout">
|
||||
<option value=""><?php esc_html_e('跟随全局设置', 'aksrt'); ?></option>
|
||||
<option value="card"><?php esc_html_e('卡片模式', 'aksrt'); ?></option>
|
||||
<option value="list"><?php esc_html_e('列表模式', 'aksrt'); ?></option>
|
||||
<option value="mini"><?php esc_html_e('迷你模式', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -223,17 +191,6 @@ class TermMeta {
|
||||
<p class="description"><?php esc_html_e('覆盖默认的分类/标签描述。', 'aksrt'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><label for="aksrt_term_layout"><?php esc_html_e('列表布局', 'aksrt'); ?></label></th>
|
||||
<td>
|
||||
<select name="aksrt_term_meta[layout_mode]" id="aksrt_term_layout">
|
||||
<option value="" <?php selected($meta['layout_mode'], ''); ?>><?php esc_html_e('跟随全局设置', 'aksrt'); ?></option>
|
||||
<option value="card" <?php selected($meta['layout_mode'], 'card'); ?>><?php esc_html_e('卡片模式', 'aksrt'); ?></option>
|
||||
<option value="list" <?php selected($meta['layout_mode'], 'list'); ?>><?php esc_html_e('列表模式', 'aksrt'); ?></option>
|
||||
<option value="mini" <?php selected($meta['layout_mode'], 'mini'); ?>><?php esc_html_e('迷你模式', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="form-field">
|
||||
<th scope="row"><?php esc_html_e('显示设置', 'aksrt'); ?></th>
|
||||
<td>
|
||||
@@ -269,18 +226,11 @@ class TermMeta {
|
||||
$sanitized = [
|
||||
'cover_url' => isset($raw['cover_url']) ? esc_url_raw($raw['cover_url']) : '',
|
||||
'description' => isset($raw['description']) ? sanitize_textarea_field($raw['description']) : '',
|
||||
'layout_mode' => isset($raw['layout_mode']) ? sanitize_key($raw['layout_mode']) : '',
|
||||
'show_sidebar' => isset($raw['show_sidebar']) ? '1' : '',
|
||||
'show_header' => isset($raw['show_header']) ? true : false,
|
||||
'show_featured' => isset($raw['show_featured']) ? true : false,
|
||||
];
|
||||
|
||||
// Only allow valid layout modes
|
||||
$valid_modes = ['', 'card', 'list', 'mini', 'grid-cms'];
|
||||
if (!in_array($sanitized['layout_mode'], $valid_modes, true)) {
|
||||
$sanitized['layout_mode'] = '';
|
||||
}
|
||||
|
||||
update_term_meta($term_id, self::META_KEY, $sanitized);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user