fix(list): wire Zibll list/card display chain end-to-end
Resolve post list mode from global list_type + surface card overrides so homepage/archives/AJAX honor admin list and card style settings.
This commit is contained in:
1 parent
b2815614d1
commit
d73a7af25e
17 files changed
+444
-151
No files matched your search
@@ -11,19 +11,26 @@ class AKSRT_Settings_Post_Display {
|
||||
|
||||
public static function get_post_list_style_settings(): array {
|
||||
$settings = AKSRT_Settings::get_all();
|
||||
$card_style = sanitize_key((string) ($settings['post_card_style'] ?? 'thumb'));
|
||||
$allowed_styles = ['thumb', 'compact', 'large_thumb', 'multi_thumb', 'text', 'thumb_if_has', 'card', 'standard'];
|
||||
|
||||
if (!in_array($card_style, $allowed_styles, true)) {
|
||||
$card_style = 'thumb';
|
||||
// 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 = 'thumb';
|
||||
}
|
||||
// historical alias
|
||||
if ($card_style === 'standard') {
|
||||
$card_style = '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' => 'card',
|
||||
'thumb' => 'list',
|
||||
'compact' => 'list',
|
||||
'large_thumb' => 'list',
|
||||
'multi_thumb' => 'list',
|
||||
@@ -74,9 +81,34 @@ class AKSRT_Settings_Post_Display {
|
||||
$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'])));
|
||||
}
|
||||
|
||||
return [
|
||||
'card_style' => in_array(sanitize_key((string) ($settings['list_card_style'] ?? '')), ['', 'style3'], true) ? sanitize_key((string) ($settings['list_card_style'] ?? '')) : '',
|
||||
'render_mode' => $render_mode_map[$card_style] ?? 'card',
|
||||
// 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']),
|
||||
@@ -100,13 +132,12 @@ class AKSRT_Settings_Post_Display {
|
||||
'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_style' => in_array(sanitize_key((string) ($settings['list_list_style'] ?? '')), ['', 'style2'], true) ? sanitize_key((string) ($settings['list_list_style'] ?? '')) : '',
|
||||
'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($settings['list_card_cat']),
|
||||
'card_cat_ids' => is_array($settings['list_card_cat'] ?? null) ? array_map('intval', $settings['list_card_cat']) : [],
|
||||
'card_cat' => !empty($card_cat_ids),
|
||||
'card_cat_ids' => $card_cat_ids,
|
||||
'card_tag' => !empty($settings['list_card_tag']),
|
||||
'card_topics' => !empty($settings['list_card_topics']),
|
||||
'card_author' => !empty($settings['list_card_author']),
|
||||
|
||||
Reference in new issue
Block a user