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:
@@ -226,7 +226,10 @@ class AKSRT_Admin {
|
||||
public static function sanitize_public_render_config(array $config): array {
|
||||
$clean = [];
|
||||
if (isset($config['mode'])) {
|
||||
$clean['mode'] = sanitize_key((string) $config['mode']);
|
||||
$mode = sanitize_key((string) $config['mode']);
|
||||
if (in_array($mode, ['list', 'card', 'mini', 'grid-cms'], true)) {
|
||||
$clean['mode'] = $mode;
|
||||
}
|
||||
}
|
||||
if (isset($config['context'])) {
|
||||
$clean['context'] = sanitize_key((string) $config['context']);
|
||||
@@ -234,9 +237,49 @@ class AKSRT_Admin {
|
||||
if (isset($config['query_context'])) {
|
||||
$clean['query_context'] = sanitize_key((string) $config['query_context']);
|
||||
}
|
||||
if (isset($config['style'])) {
|
||||
$style = sanitize_key((string) $config['style']);
|
||||
if (in_array($style, ['', 'style2', 'style3'], true)) {
|
||||
$clean['style'] = $style;
|
||||
}
|
||||
}
|
||||
if (isset($config['card_style'])) {
|
||||
$card_style = sanitize_key((string) $config['card_style']);
|
||||
$allowed = ['thumb', 'text', 'thumb_if_has', 'card', 'compact', 'large_thumb', 'multi_thumb', 'standard'];
|
||||
if (in_array($card_style, $allowed, true)) {
|
||||
$clean['card_style'] = $card_style;
|
||||
}
|
||||
}
|
||||
if (isset($config['list_show_type'])) {
|
||||
$v = sanitize_key((string) $config['list_show_type']);
|
||||
if (in_array($v, ['separate', 'no_margin'], true)) {
|
||||
$clean['list_show_type'] = $v;
|
||||
}
|
||||
}
|
||||
if (isset($config['list_img_position'])) {
|
||||
$v = sanitize_key((string) $config['list_img_position']);
|
||||
if (in_array($v, ['left', 'right'], true)) {
|
||||
$clean['list_img_position'] = $v;
|
||||
}
|
||||
}
|
||||
foreach (['thumb_if_has', 'show_thumb', 'show_author', 'show_date', 'show_views', 'show_comments', 'show_likes', 'show_excerpt', 'heading_bold', 'target_blank', 'badge_show', 'multi_thumb_enabled', 'skip_wrapper'] as $bool_key) {
|
||||
if (array_key_exists($bool_key, $config)) {
|
||||
$clean[$bool_key] = !empty($config[$bool_key]);
|
||||
}
|
||||
}
|
||||
if (isset($config['multi_thumb_limit'])) {
|
||||
$clean['multi_thumb_limit'] = max(1, min(6, (int) $config['multi_thumb_limit']));
|
||||
}
|
||||
if (isset($config['multi_thumb_min'])) {
|
||||
$clean['multi_thumb_min'] = max(1, min(6, (int) $config['multi_thumb_min']));
|
||||
}
|
||||
if (isset($config['excerpt_words'])) {
|
||||
$clean['excerpt_words'] = max(0, min(200, (int) $config['excerpt_words']));
|
||||
}
|
||||
return $clean;
|
||||
}
|
||||
|
||||
|
||||
public function ajax_load_more_posts(): void {
|
||||
check_ajax_referer('aksrt_public_nonce', 'nonce');
|
||||
$page = max(1, (int) ($_POST['page'] ?? 1));
|
||||
@@ -244,6 +287,18 @@ class AKSRT_Admin {
|
||||
$render_config = json_decode(wp_unslash((string) ($_POST['render_config'] ?? '{}')), true);
|
||||
$query_vars = is_array($query_vars) ? self::sanitize_public_query_vars($query_vars) : [];
|
||||
$render_config = is_array($render_config) ? self::sanitize_public_render_config($render_config) : [];
|
||||
// Prefer server-side resolution so AJAX matches SSR styles even if client config is slim.
|
||||
if (function_exists('aksrt_resolve_post_list_render_config')) {
|
||||
$context = sanitize_key((string) ($render_config['context'] ?? 'archive'));
|
||||
if ($context === '') {
|
||||
$context = 'archive';
|
||||
}
|
||||
$resolved = aksrt_resolve_post_list_render_config([
|
||||
'context' => $context,
|
||||
'overrides' => $render_config,
|
||||
]);
|
||||
$render_config = array_merge($resolved, $render_config);
|
||||
}
|
||||
$query_vars['paged'] = $page;
|
||||
|
||||
$query = new WP_Query($query_vars);
|
||||
|
||||
Reference in New Issue
Block a user