feat(frontend): replace article system with Zibll 9.0
This commit is contained in:
@@ -170,55 +170,8 @@ trait DisplayPageGroups {
|
||||
$filter = self::get_post_filter_settings();
|
||||
|
||||
return [
|
||||
'list' => [
|
||||
'post_card_style' => $list['list_type'] ?? $list['card_style'] ?? 'thumb',
|
||||
'post_list_author' => $list['show_author'],
|
||||
'post_show_date' => $list['show_date'],
|
||||
'post_show_views' => $list['show_views'],
|
||||
'post_show_category' => $list['show_category'],
|
||||
'post_show_comments' => $list['show_comments'],
|
||||
'post_show_likes' => $list['show_likes'],
|
||||
'post_excerpt_length' => $list['excerpt_length'],
|
||||
'paging_ajax_s' => PostDisplay::is_list_paging_ajax() ? '1' : '0',
|
||||
'paging_ajax_ias_s' => PostDisplay::is_list_paging_ajax_ias(),
|
||||
'post_pagination_mode' => self::get_post_pagination_mode(),
|
||||
'render_mode' => $list['render_mode'],
|
||||
'sticky_s' => $list['sticky_pages'],
|
||||
'list_badge_show' => $list['badge_types'],
|
||||
'target_blank' => $list['target_blank'],
|
||||
'item_heading_bold' => $list['heading_bold'],
|
||||
'list_meta_show' => $list['mobile_meta'],
|
||||
'list_show_type' => $list['list_show_type'],
|
||||
'ias_max' => $list['ias_max'],
|
||||
'ajax_trigger' => $list['ajax_trigger_text'],
|
||||
'ajax_nomore' => $list['ajax_nomore_text'],
|
||||
'ajax_nomore_text' => $list['ajax_nomore_text'],
|
||||
'post_list_columns' => $list['columns'],
|
||||
'post_list_per_page' => $list['per_page'],
|
||||
'list_list_style' => $list['list_style'],
|
||||
'list_list_img_position' => $list['list_img_position'],
|
||||
'list_list_scale' => $list['list_scale'],
|
||||
'list_card_style' => $list['card_variant'] ?? '',
|
||||
'list_card_scale' => $list['card_scale'],
|
||||
'list_card_home' => $list['card_home'],
|
||||
'list_card_cat' => $list['card_cat_ids'] ?? [],
|
||||
'list_card_tag' => $list['card_tag'],
|
||||
'list_card_author' => $list['card_author'],
|
||||
],
|
||||
'thumb' => [
|
||||
'thumb_priority' => implode(',', $thumb['priority']),
|
||||
'thumb_fallback' => $thumb['fallback'],
|
||||
'thumb_spare_images' => $thumb['spare_images'],
|
||||
'thumb_aspect_ratio' => $thumb['aspect_ratio'],
|
||||
'thumb_multi_enabled' => $thumb['multi_enabled'],
|
||||
'thumb_multi_count' => $thumb['multi_count'],
|
||||
'list_thumb_fit' => $thumb['fit'],
|
||||
'list_thumb_slides_s' => $thumb['slides_s'],
|
||||
'list_thumb_video_s' => $thumb['video_s'],
|
||||
'list_thumb_video_mute_s' => $thumb['video_mute_s'],
|
||||
'thumb_postfirstimg_s' => $thumb['postfirstimg_s'],
|
||||
'thumb_catimg_s' => $thumb['catimg_s'],
|
||||
],
|
||||
'list' => $list,
|
||||
'thumb' => $thumb,
|
||||
'filter' => [
|
||||
'filter_enabled' => $filter['enabled'],
|
||||
'filter_categories' => $filter['categories'],
|
||||
|
||||
@@ -259,13 +259,11 @@ trait FacadeBulk {
|
||||
'reading_progress' => !isset($settings['post_reading_progress']) || !empty($settings['post_reading_progress']),
|
||||
'breadcrumbs' => !isset($settings['breadcrumbs_single_s']) || !empty($settings['breadcrumbs_single_s']),
|
||||
'breadcrumbs_home' => trim((string) ($settings['breadcrumbs_home_text'] ?? '')) ?: __('首页', 'aksrt'),
|
||||
'related_enabled' => !isset($settings['post_related_enabled']) || !empty($settings['post_related_enabled']),
|
||||
'related_count' => max(1, min(20, (int) ($settings['post_related_count'] ?? 6))),
|
||||
'related_style' => 'img',
|
||||
'related_source' => 'category',
|
||||
'related_type' => 'category',
|
||||
'related_orderby' => 'views',
|
||||
'related_title' => sanitize_text_field((string) ($settings['post_related_title'] ?? '相关推荐')),
|
||||
'related_enabled' => !isset($settings['post_related_s']) || !empty($settings['post_related_s']),
|
||||
'related_count' => max(4, min(12, (int) ($settings['post_related_n'] ?? 6))),
|
||||
'related_style' => in_array(($settings['post_related_type'] ?? 'img'), ['img', 'list', 'text'], true) ? (string) $settings['post_related_type'] : 'img',
|
||||
'related_orderby' => 'views',
|
||||
'related_title' => sanitize_text_field((string) ($settings['related_title'] ?? '相关推荐')),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -212,12 +212,7 @@ class HomeCms {
|
||||
'home_exclude_cats' => $exclude_cats,
|
||||
'home_lists' => self::normalize_homepage_tabs($tabs_raw),
|
||||
|
||||
// AKSRT presentation extras.
|
||||
'homepage_card_style' => isset($s['homepage_card_style']) ? sanitize_key((string) $s['homepage_card_style']) : 'default',
|
||||
'homepage_multi_thumb_enabled' => !empty($s['homepage_multi_thumb_enabled']),
|
||||
'homepage_multi_thumb_min_images' => (int) ($s['homepage_multi_thumb_min_images'] ?? 3),
|
||||
'homepage_sidebar_mini_enabled' => !isset($s['homepage_sidebar_mini_enabled']) || !empty($s['homepage_sidebar_mini_enabled']),
|
||||
'homepage_default_view' => isset($s['homepage_default_view']) ? sanitize_key((string) $s['homepage_default_view']) : 'list',
|
||||
'homepage_sort_ajax_enabled' => !isset($s['homepage_sort_ajax_enabled']) || !empty($s['homepage_sort_ajax_enabled']),
|
||||
'homepage_sticky_tabs_enabled' => !isset($s['homepage_sticky_tabs_enabled']) || !empty($s['homepage_sticky_tabs_enabled']),
|
||||
'home_list_sort_dropdown' => !empty($s['home_list_sort_dropdown']),
|
||||
@@ -227,16 +222,6 @@ class HomeCms {
|
||||
'homepage_module_banner_enabled' => !isset($s['homepage_module_banner_enabled']) || !empty($s['homepage_module_banner_enabled']),
|
||||
];
|
||||
|
||||
if (!in_array($settings['homepage_card_style'], ['default', 'style2', 'style3'], true)) {
|
||||
$settings['homepage_card_style'] = 'default';
|
||||
}
|
||||
|
||||
$settings['homepage_multi_thumb_min_images'] = max(2, min(4, $settings['homepage_multi_thumb_min_images']));
|
||||
|
||||
if (!in_array($settings['homepage_default_view'], ['list', 'card'], true)) {
|
||||
$settings['homepage_default_view'] = 'list';
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
@@ -259,21 +244,6 @@ class HomeCms {
|
||||
return self::homepage_tabs();
|
||||
}
|
||||
|
||||
public static function homepage_card_style(): string {
|
||||
$settings = self::get_homepage_fixed_settings();
|
||||
return $settings['homepage_card_style'];
|
||||
}
|
||||
|
||||
public static function homepage_multi_thumb_enabled(): bool {
|
||||
$settings = self::get_homepage_fixed_settings();
|
||||
return !empty($settings['homepage_multi_thumb_enabled']);
|
||||
}
|
||||
|
||||
public static function homepage_multi_thumb_min_images(): int {
|
||||
$settings = self::get_homepage_fixed_settings();
|
||||
return (int) $settings['homepage_multi_thumb_min_images'];
|
||||
}
|
||||
|
||||
public static function homepage_sidebar_mini_enabled(): bool {
|
||||
$settings = self::get_homepage_fixed_settings();
|
||||
return !empty($settings['homepage_sidebar_mini_enabled']);
|
||||
@@ -284,11 +254,6 @@ class HomeCms {
|
||||
return $settings['home_list1_orderby_option']['orderby'] ?? 'date';
|
||||
}
|
||||
|
||||
public static function homepage_default_view(): string {
|
||||
$settings = self::get_homepage_fixed_settings();
|
||||
return $settings['homepage_default_view'];
|
||||
}
|
||||
|
||||
public static function homepage_sort_ajax_enabled(): bool {
|
||||
$settings = self::get_homepage_fixed_settings();
|
||||
return !empty($settings['homepage_sort_ajax_enabled']);
|
||||
|
||||
@@ -54,29 +54,6 @@ trait HomepageReader {
|
||||
return HomeCms::homepage_tabs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Homepage card view variant.
|
||||
*
|
||||
* @return string default|style2|style3
|
||||
*/
|
||||
public static function homepage_card_style(): string {
|
||||
return HomeCms::homepage_card_style();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether homepage list cards should switch to the multi-thumb layout.
|
||||
*/
|
||||
public static function homepage_multi_thumb_enabled(): bool {
|
||||
return HomeCms::homepage_multi_thumb_enabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Minimum image count required to trigger the multi-thumb layout.
|
||||
*/
|
||||
public static function homepage_multi_thumb_min_images(): int {
|
||||
return HomeCms::homepage_multi_thumb_min_images();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether homepage sidebar widgets should use the compact mini list style.
|
||||
*/
|
||||
@@ -91,13 +68,6 @@ trait HomepageReader {
|
||||
return HomeCms::homepage_default_sort();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default homepage view mode.
|
||||
*/
|
||||
public static function homepage_default_view(): string {
|
||||
return HomeCms::homepage_default_view();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the homepage sortbar should refresh through AJAX.
|
||||
*/
|
||||
|
||||
+93
-227
@@ -11,177 +11,92 @@ class PostDisplay {
|
||||
|
||||
public static function get_post_list_style_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
|
||||
// post_card_style storage key mirrors Zibll list_type.
|
||||
$list_type = sanitize_key((string) ($settings['post_card_style'] ?? 'thumb'));
|
||||
$allowed_list_types = ['thumb', 'compact', 'large_thumb', 'multi_thumb', 'text', 'thumb_if_has', 'card', 'standard'];
|
||||
|
||||
if (!in_array($list_type, $allowed_list_types, true)) {
|
||||
$list_type = sanitize_key((string) ($settings['list_type'] ?? 'thumb'));
|
||||
if (!in_array($list_type, ['text', 'thumb', 'thumb_if_has', 'card'], true)) {
|
||||
$list_type = 'thumb';
|
||||
}
|
||||
// Historical aliases → Zibll list_type tokens.
|
||||
if ($list_type === 'standard') {
|
||||
$list_type = 'thumb';
|
||||
}
|
||||
// Non-Zibll extras stay list-mode variants (never force card grid).
|
||||
if (in_array($list_type, ['compact', 'large_thumb', 'multi_thumb'], true)) {
|
||||
// Keep token for CSS hooks; render as list.
|
||||
}
|
||||
|
||||
// Zibll: only list_type=card is card mode; thumb/text/thumb_if_has are list.
|
||||
$render_mode_map = [
|
||||
'thumb' => 'list',
|
||||
'compact' => 'list',
|
||||
'large_thumb' => 'list',
|
||||
'multi_thumb' => 'list',
|
||||
'text' => 'list',
|
||||
'thumb_if_has' => 'list',
|
||||
'card' => 'card',
|
||||
];
|
||||
$list_option = is_array($settings['list_list_option'] ?? null) ? $settings['list_list_option'] : [];
|
||||
$list_style = sanitize_key((string) ($list_option['style'] ?? 'null'));
|
||||
$list_style = $list_style === 'style2' ? 'style2' : 'null';
|
||||
$list_position = sanitize_key((string) ($list_option['img_position'] ?? 'left'));
|
||||
$list_position = $list_position === 'right' ? 'right' : 'left';
|
||||
|
||||
$sticky_pages_raw = $settings['sticky_s'] ?? null;
|
||||
if (is_array($sticky_pages_raw)) {
|
||||
$allowed_pages = ['home', 'cat', 'tag'];
|
||||
$sticky_pages = array_values(array_intersect(array_map('sanitize_key', $sticky_pages_raw), $allowed_pages));
|
||||
} else {
|
||||
$sticky_pages = ['home', 'cat'];
|
||||
}
|
||||
$card_option = is_array($settings['list_card_option'] ?? null) ? $settings['list_card_option'] : [];
|
||||
$card_style = sanitize_key((string) ($card_option['style'] ?? 'null'));
|
||||
$card_style = $card_style === 'style3' ? 'style3' : 'null';
|
||||
|
||||
$badge_types_raw = $settings['list_badge_show'] ?? null;
|
||||
if (is_array($badge_types_raw)) {
|
||||
$allowed_types = ['pay', 'cat', 'tag'];
|
||||
$badge_types = array_values(array_intersect(array_map('sanitize_key', $badge_types_raw), $allowed_types));
|
||||
} else {
|
||||
$badge_types = ['pay', 'cat', 'tag'];
|
||||
}
|
||||
$sticky_pages = is_array($settings['sticky_s'] ?? null)
|
||||
? array_values(array_intersect(array_map('sanitize_key', $settings['sticky_s']), ['home', 'cat', 'tag']))
|
||||
: ['home', 'cat'];
|
||||
$badge_types = is_array($settings['list_badge_show'] ?? null)
|
||||
? array_values(array_intersect(array_map('sanitize_key', $settings['list_badge_show']), ['pay', 'cat', 'tag']))
|
||||
: ['pay', 'cat', 'tag'];
|
||||
$card_cat_ids = is_array($settings['list_card_cat'] ?? null)
|
||||
? array_values(array_filter(array_map('intval', $settings['list_card_cat'])))
|
||||
: [];
|
||||
|
||||
$show_author = array_key_exists('post_list_author', $settings)
|
||||
? !empty($settings['post_list_author'])
|
||||
: (!isset($settings['post_show_author']) || !empty($settings['post_show_author']));
|
||||
|
||||
$show_date = array_key_exists('post_list_time', $settings)
|
||||
? !empty($settings['post_list_time'])
|
||||
: (!isset($settings['post_show_date']) || !empty($settings['post_show_date']));
|
||||
|
||||
$target_blank = array_key_exists('target_blank', $settings)
|
||||
? !empty($settings['target_blank'])
|
||||
: !empty($settings['post_target_blank']);
|
||||
|
||||
$ajax_trigger = '';
|
||||
if (array_key_exists('ajax_trigger', $settings)) {
|
||||
$ajax_trigger = sanitize_text_field((string) $settings['ajax_trigger']);
|
||||
} elseif (array_key_exists('ajax_trigger_text', $settings)) {
|
||||
$ajax_trigger = sanitize_text_field((string) $settings['ajax_trigger_text']);
|
||||
}
|
||||
|
||||
$ajax_nomore = '';
|
||||
if (array_key_exists('ajax_nomore', $settings)) {
|
||||
$ajax_nomore = sanitize_text_field((string) $settings['ajax_nomore']);
|
||||
} elseif (array_key_exists('ajax_nomore_text', $settings)) {
|
||||
$ajax_nomore = sanitize_text_field((string) $settings['ajax_nomore_text']);
|
||||
}
|
||||
|
||||
$list_style = sanitize_key((string) ($settings['list_list_style'] ?? ''));
|
||||
if (!in_array($list_style, ['', 'style2'], true)) {
|
||||
$list_style = '';
|
||||
}
|
||||
|
||||
$card_variant = sanitize_key((string) ($settings['list_card_style'] ?? ''));
|
||||
if (!in_array($card_variant, ['', 'style3'], true)) {
|
||||
$card_variant = '';
|
||||
}
|
||||
|
||||
$card_cat_ids = [];
|
||||
if (is_array($settings['list_card_cat'] ?? null)) {
|
||||
$card_cat_ids = array_values(array_filter(array_map('intval', $settings['list_card_cat'])));
|
||||
}
|
||||
$time_source = sanitize_key((string) ($settings['post_time_source'] ?? 'modified'));
|
||||
$mobile_meta = sanitize_key((string) ($settings['list_meta_show'] ?? 'like'));
|
||||
$list_show_type = sanitize_key((string) ($settings['list_show_type'] ?? 'separate'));
|
||||
$list_orderby = sanitize_key((string) ($settings['list_orderby'] ?? 'modified'));
|
||||
|
||||
return [
|
||||
// Zibll list_type (storage: post_card_style).
|
||||
'list_type' => $list_type,
|
||||
// Base mode from list_type only (surface card overrides applied by resolver).
|
||||
'render_mode' => $render_mode_map[$list_type] ?? 'list',
|
||||
// List item subtype token for text/thumb_if_has class hooks (not card variant).
|
||||
'list_type_token' => $list_type,
|
||||
// List mode visual variant (Zibll list_list_option.style).
|
||||
'list_style' => $list_style,
|
||||
// Card mode visual variant (Zibll list_card_option.style).
|
||||
'card_variant' => $card_variant,
|
||||
// Back-compat aliases used by older callers (prefer list_type / card_variant).
|
||||
'card_style' => $list_type,
|
||||
'show_author' => $show_author,
|
||||
'show_date' => $show_date,
|
||||
'show_views' => !isset($settings['post_show_views']) || !empty($settings['post_show_views']),
|
||||
'show_category' => !isset($settings['post_show_category']) || !empty($settings['post_show_category']),
|
||||
'show_comments' => !isset($settings['post_meta_comments']) || !empty($settings['post_meta_comments']),
|
||||
'show_likes' => !isset($settings['post_meta_likes']) || !empty($settings['post_meta_likes']),
|
||||
'badge_types' => $badge_types,
|
||||
'badge_show' => !empty($badge_types),
|
||||
'sticky_pages' => $sticky_pages,
|
||||
'sticky_enabled' => !empty($sticky_pages),
|
||||
'target_blank' => $target_blank,
|
||||
'heading_bold' => !empty($settings['item_heading_bold']),
|
||||
'mobile_meta' => in_array(sanitize_key((string) ($settings['list_meta_show'] ?? 'like')), ['view', 'like', 'comm'], true) ? sanitize_key((string) ($settings['list_meta_show'] ?? 'like')) : 'like',
|
||||
'list_show_type' => in_array(sanitize_key((string) ($settings['list_show_type'] ?? 'separate')), ['separate', 'no_margin'], true) ? sanitize_key((string) ($settings['list_show_type'] ?? 'separate')) : 'separate',
|
||||
'excerpt_length' => max(20, min(500, (int) ($settings['post_excerpt_length'] ?? 120))),
|
||||
'ias_max' => max(0, min(10, (int) ($settings['ias_max'] ?? 3))),
|
||||
'paging_ajax' => self::is_list_paging_ajax($settings),
|
||||
'paging_ajax_ias' => self::is_list_paging_ajax_ias($settings),
|
||||
'ajax_trigger_text' => $ajax_trigger,
|
||||
'ajax_nomore_text' => $ajax_nomore,
|
||||
'list_orderby' => in_array(sanitize_key((string) ($settings['list_orderby'] ?? 'modified')), ['modified', 'date', 'default'], true) ? sanitize_key((string) ($settings['list_orderby'] ?? 'modified')) : 'modified',
|
||||
'columns' => max(1, min(3, (int) ($settings['post_list_columns'] ?? 1))),
|
||||
'per_page' => max(4, min(48, (int) ($settings['post_list_per_page'] ?? 12))),
|
||||
'list_img_position' => in_array(sanitize_key((string) ($settings['list_list_img_position'] ?? 'left')), ['left', 'right'], true) ? sanitize_key((string) ($settings['list_list_img_position'] ?? 'left')) : 'left',
|
||||
'list_scale' => max(50, min(200, (int) ($settings['list_list_scale'] ?? 70))),
|
||||
'card_scale' => max(20, min(200, (int) ($settings['list_card_scale'] ?? 70))),
|
||||
'card_home' => !empty($settings['list_card_home']),
|
||||
'card_cat' => !empty($card_cat_ids),
|
||||
'card_cat_ids' => $card_cat_ids,
|
||||
'card_tag' => !empty($settings['list_card_tag']),
|
||||
'card_author' => !empty($settings['list_card_author']),
|
||||
'list_type' => $list_type,
|
||||
'list_orderby' => in_array($list_orderby, ['date', 'modified', 'default'], true) ? $list_orderby : 'modified',
|
||||
'post_time_source' => $time_source === 'date' ? 'date' : 'modified',
|
||||
'sticky_s' => $sticky_pages,
|
||||
'target_blank' => !empty($settings['target_blank']),
|
||||
'item_heading_bold' => !empty($settings['item_heading_bold']),
|
||||
'post_list_author' => !array_key_exists('post_list_author', $settings) || !empty($settings['post_list_author']),
|
||||
'post_list_time' => !array_key_exists('post_list_time', $settings) || !empty($settings['post_list_time']),
|
||||
'paging_ajax_s' => (string) ($settings['paging_ajax_s'] ?? '1') === '1',
|
||||
'paging_ajax_ias_s' => !array_key_exists('paging_ajax_ias_s', $settings) || !empty($settings['paging_ajax_ias_s']),
|
||||
'ias_max' => max(0, min(10, (int) ($settings['ias_max'] ?? 3))),
|
||||
'list_meta_show' => in_array($mobile_meta, ['view', 'like', 'comm'], true) ? $mobile_meta : 'like',
|
||||
'list_badge_show' => $badge_types,
|
||||
'list_show_type' => in_array($list_show_type, ['separate', 'no_margin'], true) ? $list_show_type : 'separate',
|
||||
'list_card_home' => !empty($settings['list_card_home']),
|
||||
'list_card_tag' => !empty($settings['list_card_tag']),
|
||||
'list_card_author' => !empty($settings['list_card_author']),
|
||||
'list_card_cat' => $card_cat_ids,
|
||||
'list_list_option' => [
|
||||
'style' => $list_style,
|
||||
'img_position' => $list_position,
|
||||
'scale' => max(50, min(200, (int) ($list_option['scale'] ?? 70))),
|
||||
],
|
||||
'list_card_option' => [
|
||||
'style' => $card_style,
|
||||
'scale' => max(20, min(200, (int) ($card_option['scale'] ?? 70))),
|
||||
],
|
||||
'mult_thumb_cat' => is_array($settings['mult_thumb_cat'] ?? null) ? array_values(array_filter(array_map('intval', $settings['mult_thumb_cat']))) : [],
|
||||
'ajax_trigger' => wp_kses_post((string) ($settings['ajax_trigger'] ?? '<i class="fa fa-angle-right"></i>加载更多')),
|
||||
'ajax_nomore' => wp_kses_post((string) ($settings['ajax_nomore'] ?? '没有更多内容了')),
|
||||
];
|
||||
}
|
||||
|
||||
public static function get_post_thumb_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
$priority_raw = (string) ($settings['thumb_priority'] ?? 'featured,attachment,resource,custom');
|
||||
$priority = preg_split('/[\s,]+/', strtolower($priority_raw)) ?: [];
|
||||
$priority = array_values(array_unique(array_filter(array_map('sanitize_key', $priority))));
|
||||
$allowed_sources = ['featured', 'attachment', 'resource', 'custom', 'category_cover', 'post_first_img'];
|
||||
$priority = array_values(array_filter($priority, static function (string $source) use ($allowed_sources): bool {
|
||||
return in_array($source, $allowed_sources, true);
|
||||
}));
|
||||
|
||||
if (empty($priority)) {
|
||||
$priority = ['featured', 'attachment', 'resource', 'custom'];
|
||||
public static function get_post_thumb_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
$spare_settings = array_key_exists('spare_thumbnail', $settings)
|
||||
? (array) $settings['spare_thumbnail']
|
||||
: [['img' => get_template_directory_uri() . '/assets/img/thumbnail.svg']];
|
||||
$spare = [];
|
||||
foreach ($spare_settings as $item) {
|
||||
$url = is_array($item) ? (string) ($item['img'] ?? '') : '';
|
||||
if ($url !== '') {
|
||||
$spare[] = esc_url_raw($url);
|
||||
}
|
||||
}
|
||||
|
||||
$fallback = sanitize_key((string) ($settings['thumb_fallback'] ?? 'placeholder'));
|
||||
if (!in_array($fallback, ['placeholder', 'hide', 'random'], true)) {
|
||||
$fallback = 'placeholder';
|
||||
}
|
||||
|
||||
$aspect_ratio = (string) ($settings['thumb_aspect_ratio'] ?? '16:9');
|
||||
if (!in_array($aspect_ratio, ['16:9', '4:3', '1:1', 'auto'], true)) {
|
||||
$aspect_ratio = '16:9';
|
||||
}
|
||||
|
||||
$fit = sanitize_key((string) ($settings['list_thumb_fit'] ?? ''));
|
||||
return [
|
||||
'priority' => $priority,
|
||||
'fallback' => $fallback,
|
||||
'spare_images' => is_array($settings['thumb_spare_images'] ?? null) ? $settings['thumb_spare_images'] : [],
|
||||
'aspect_ratio' => $aspect_ratio,
|
||||
'multi_enabled' => !empty($settings['thumb_multi_enabled']),
|
||||
'multi_count' => max(2, min(6, (int) ($settings['thumb_multi_count'] ?? 3))),
|
||||
'fit' => in_array(sanitize_key((string) ($settings['list_thumb_fit'] ?? 'cover')), ['cover', 'contain'], true) ? sanitize_key((string) ($settings['list_thumb_fit'] ?? 'cover')) : 'cover',
|
||||
'slides_s' => !isset($settings['list_thumb_slides_s']) || !empty($settings['list_thumb_slides_s']),
|
||||
'video_s' => !isset($settings['list_thumb_video_s']) || !empty($settings['list_thumb_video_s']),
|
||||
'video_mute_s' => !isset($settings['list_thumb_video_mute_s']) || !empty($settings['list_thumb_video_mute_s']),
|
||||
'postfirstimg_s' => !isset($settings['thumb_postfirstimg_s']) || !empty($settings['thumb_postfirstimg_s']),
|
||||
'catimg_s' => !isset($settings['thumb_catimg_s']) || !empty($settings['thumb_catimg_s']),
|
||||
'postfirstimg_size'=> in_array(sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')), ['thumbnail', 'medium', 'large', 'full'], true) ? sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')) : 'medium',
|
||||
'mult_thumb_cat_ids' => is_array($settings['mult_thumb_cat'] ?? null) ? array_map('intval', $settings['mult_thumb_cat']) : [],
|
||||
'list_thumb_slides_s' => !array_key_exists('list_thumb_slides_s', $settings) || !empty($settings['list_thumb_slides_s']),
|
||||
'list_thumb_video_s' => !array_key_exists('list_thumb_video_s', $settings) || !empty($settings['list_thumb_video_s']),
|
||||
'list_thumb_video_mute_s' => !array_key_exists('list_thumb_video_mute_s', $settings) || !empty($settings['list_thumb_video_mute_s']),
|
||||
'thumb_postfirstimg_s' => !array_key_exists('thumb_postfirstimg_s', $settings) || !empty($settings['thumb_postfirstimg_s']),
|
||||
'thumb_catimg_s' => !array_key_exists('thumb_catimg_s', $settings) || !empty($settings['thumb_catimg_s']),
|
||||
'list_thumb_fit' => $fit === 'contain' ? 'contain' : '',
|
||||
'thumb_postfirstimg_size' => in_array(sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')), ['thumbnail', 'medium', 'large', 'full'], true) ? sanitize_key((string) ($settings['thumb_postfirstimg_size'] ?? 'medium')) : 'medium',
|
||||
'spare_thumbnail' => $spare,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -262,30 +177,15 @@ class PostDisplay {
|
||||
$maxheight = 1000;
|
||||
}
|
||||
|
||||
// Related: split Zibll display style (img/list/text) from query source (category/tag/random).
|
||||
// Legacy post_related_type held either style (img|list|text) or source (category|tag|random).
|
||||
$raw_related_type = sanitize_key((string) ($settings['post_related_type'] ?? ''));
|
||||
$raw_related_style = sanitize_key((string) ($settings['post_related_style'] ?? ''));
|
||||
$raw_related_source = sanitize_key((string) ($settings['post_related_source'] ?? ''));
|
||||
$related_style = sanitize_key((string) ($settings['post_related_type'] ?? 'img'));
|
||||
if (!in_array($related_style, ['img', 'list', 'text'], true)) {
|
||||
$related_style = 'img';
|
||||
}
|
||||
|
||||
$related_style = 'img';
|
||||
if (in_array($raw_related_style, ['img', 'list', 'text'], true)) {
|
||||
$related_style = $raw_related_style;
|
||||
} elseif (in_array($raw_related_type, ['img', 'list', 'text'], true)) {
|
||||
$related_style = $raw_related_type;
|
||||
}
|
||||
|
||||
$related_source = 'category';
|
||||
if (in_array($raw_related_source, ['category', 'tag', 'random'], true)) {
|
||||
$related_source = $raw_related_source;
|
||||
} elseif (in_array($raw_related_type, ['category', 'tag', 'random'], true)) {
|
||||
$related_source = $raw_related_type;
|
||||
}
|
||||
|
||||
$related_orderby = sanitize_key((string) ($settings['post_related_orderby'] ?? 'views'));
|
||||
if (!in_array($related_orderby, ['rand', 'relevance', 'date', 'views', 'modified'], true)) {
|
||||
$related_orderby = 'views';
|
||||
}
|
||||
$related_orderby = sanitize_key((string) ($settings['post_related_orderby'] ?? 'views'));
|
||||
if (!in_array($related_orderby, ['modified', 'date', 'views', 'like', 'comment_count', 'favorite', 'rand'], true)) {
|
||||
$related_orderby = 'views';
|
||||
}
|
||||
|
||||
return [
|
||||
'toc_enabled' => !isset($settings['post_toc_enabled']) || !empty($settings['post_toc_enabled']),
|
||||
@@ -317,15 +217,11 @@ class PostDisplay {
|
||||
'lightbox_full' => !isset($settings['post_lightbox_full']) || !empty($settings['post_lightbox_full']),
|
||||
'lightbox_down' => !empty($settings['post_lightbox_down']),
|
||||
'lightbox_play' => !empty($settings['post_lightbox_play']),
|
||||
'related_enabled' => !isset($settings['post_related_enabled']) || !empty($settings['post_related_enabled']),
|
||||
'related_count' => max(1, min(20, (int) ($settings['post_related_count'] ?? 6))),
|
||||
// Display style (Zibll img/list/text) + query source (category/tag/random).
|
||||
'related_style' => $related_style,
|
||||
'related_source' => $related_source,
|
||||
// Legacy alias: older code treated related_type as source.
|
||||
'related_type' => $related_source,
|
||||
'related_orderby' => $related_orderby,
|
||||
'related_title' => sanitize_text_field((string) ($settings['post_related_title'] ?? '相关推荐')),
|
||||
'related_enabled' => !isset($settings['post_related_s']) || !empty($settings['post_related_s']),
|
||||
'related_count' => max(4, min(12, (int) ($settings['post_related_n'] ?? 6))),
|
||||
'related_style' => $related_style,
|
||||
'related_orderby' => $related_orderby,
|
||||
'related_title' => sanitize_text_field((string) ($settings['related_title'] ?? '相关推荐')),
|
||||
'like_enabled' => !isset($settings['post_like_enabled']) || !empty($settings['post_like_enabled']),
|
||||
'favorite_enabled' => !isset($settings['post_favorite_enabled']) || !empty($settings['post_favorite_enabled']),
|
||||
// Canonical + legacy share.
|
||||
@@ -534,42 +430,21 @@ class PostDisplay {
|
||||
}
|
||||
|
||||
public static function apply_list_per_page($query): void {
|
||||
if (is_admin() || !$query->is_main_query()) {
|
||||
return;
|
||||
}
|
||||
if (!$query->is_archive() && !$query->is_search() && !$query->is_home()) {
|
||||
return;
|
||||
}
|
||||
$s = Settings::get_all();
|
||||
$per_page = max(4, min(48, (int) ($s['post_list_per_page'] ?? 12)));
|
||||
if ($per_page !== 12) {
|
||||
$query->set('posts_per_page', $per_page);
|
||||
}
|
||||
unset($query);
|
||||
}
|
||||
|
||||
public static function get_archive_layout(): string {
|
||||
$settings = self::get_post_list_style_settings();
|
||||
return $settings['render_mode'];
|
||||
return ($settings['list_type'] ?? 'thumb') === 'card' ? 'card' : 'list';
|
||||
}
|
||||
|
||||
public static function get_post_pagination_mode(): string {
|
||||
$settings = Settings::get_all();
|
||||
|
||||
// Zibll: paging_ajax_s '1' = ajax append, '0' = numeric buttons.
|
||||
if (array_key_exists('paging_ajax_s', $settings)) {
|
||||
$ajax = self::is_list_paging_ajax($settings);
|
||||
if (!$ajax) {
|
||||
return 'numbered';
|
||||
}
|
||||
return self::is_list_paging_ajax_ias($settings) ? 'infinite' : 'load_more';
|
||||
if (!self::is_list_paging_ajax($settings)) {
|
||||
return 'numbered';
|
||||
}
|
||||
|
||||
// Temporary bridge for installs still holding the previous schema key only.
|
||||
$mode = (string) ($settings['post_pagination_mode'] ?? 'numbered');
|
||||
if ($mode === 'numeric') {
|
||||
$mode = 'numbered';
|
||||
}
|
||||
return in_array($mode, ['numbered', 'load_more', 'infinite'], true) ? $mode : 'numbered';
|
||||
return self::is_list_paging_ajax_ias($settings) ? 'infinite' : 'load_more';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -579,12 +454,7 @@ class PostDisplay {
|
||||
*/
|
||||
public static function is_list_paging_ajax(?array $settings = null): bool {
|
||||
$settings = $settings ?? Settings::get_all();
|
||||
if (!array_key_exists('paging_ajax_s', $settings)) {
|
||||
// Fallback from previous 3-mode key.
|
||||
$mode = (string) ($settings['post_pagination_mode'] ?? 'numbered');
|
||||
return in_array($mode, ['load_more', 'infinite', 'ajax'], true);
|
||||
}
|
||||
$raw = $settings['paging_ajax_s'];
|
||||
$raw = $settings['paging_ajax_s'] ?? '1';
|
||||
if (is_bool($raw)) {
|
||||
return $raw;
|
||||
}
|
||||
@@ -601,11 +471,7 @@ class PostDisplay {
|
||||
if (!self::is_list_paging_ajax($settings)) {
|
||||
return false;
|
||||
}
|
||||
if (!array_key_exists('paging_ajax_ias_s', $settings)) {
|
||||
$mode = (string) ($settings['post_pagination_mode'] ?? '');
|
||||
return $mode === 'infinite';
|
||||
}
|
||||
return !empty($settings['paging_ajax_ias_s']);
|
||||
return !array_key_exists('paging_ajax_ias_s', $settings) || !empty($settings['paging_ajax_ias_s']);
|
||||
}
|
||||
|
||||
public static function get_comment_pagination_mode(): string {
|
||||
|
||||
@@ -646,9 +646,9 @@ class Settings {
|
||||
|
||||
|
||||
/**
|
||||
* Post-list card style and meta display settings.
|
||||
*
|
||||
* @return array{card_style:string,render_mode:string,show_author:bool,show_date:bool,show_views:bool,show_category:bool,show_comments:bool,show_likes:bool,excerpt_length:int}
|
||||
* Zibll 9.0 post-list display settings.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function get_post_list_style_settings(): array {
|
||||
return PostDisplay::get_post_list_style_settings();
|
||||
@@ -659,7 +659,7 @@ class Settings {
|
||||
/**
|
||||
* Post-list thumbnail policy settings.
|
||||
*
|
||||
* @return array{priority:string[],fallback:string,aspect_ratio:string,multi_enabled:bool,multi_count:int,lazy:bool}
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
public static function get_post_thumb_settings(): array {
|
||||
return PostDisplay::get_post_thumb_settings();
|
||||
@@ -949,10 +949,7 @@ class Settings {
|
||||
/**
|
||||
* 获取归档布局模式。
|
||||
*
|
||||
* 从 post_list.list schema 的 render_mode 字段读取。
|
||||
* 后台可在 /post-list/list 页面配置。
|
||||
*
|
||||
* @return string grid-cms|list|compact
|
||||
* @return string card|list
|
||||
*/
|
||||
public static function get_archive_layout(): string {
|
||||
return PostDisplay::get_archive_layout();
|
||||
|
||||
Reference in New Issue
Block a user