修复AJAX 引擎
This commit is contained in:
1 parent
c4512f2bc2
commit
616beb8c03
8 files changed
+50
-32
No files matched your search
@@ -9,19 +9,6 @@
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (!function_exists('aksrt_archive_get_list_style_settings')) :
|
||||
/**
|
||||
* Shared list style defaults for archive surfaces.
|
||||
*
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
function aksrt_archive_get_list_style_settings(): array {
|
||||
return class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_post_list_style_settings()
|
||||
: [];
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_resolve_post_list_render_config')) :
|
||||
/**
|
||||
* Build the legacy-shaped arguments used by every list surface.
|
||||
@@ -34,11 +21,14 @@ if (!function_exists('aksrt_resolve_post_list_render_config')) :
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
function aksrt_resolve_post_list_render_config(array $args = []): array {
|
||||
$has_top_level_term_id = array_key_exists('term_id', $args);
|
||||
$args = wp_parse_args($args, [
|
||||
'context' => '',
|
||||
'term_id' => 0,
|
||||
'overrides' => [],
|
||||
]);
|
||||
$overrides = is_array($args['overrides']) ? $args['overrides'] : [];
|
||||
$has_override_term_id = array_key_exists('term_id', $overrides);
|
||||
$context = sanitize_key((string) ($args['context'] ?: ($overrides['context'] ?? '')));
|
||||
if ($context === '') {
|
||||
if (function_exists('is_front_page') && (is_front_page() || is_home())) {
|
||||
@@ -55,17 +45,22 @@ if (!function_exists('aksrt_resolve_post_list_render_config')) :
|
||||
$context = 'archive';
|
||||
}
|
||||
}
|
||||
$term_id = $has_override_term_id ? absint($overrides['term_id']) : absint($args['term_id']);
|
||||
if ($context === 'category' && !$has_top_level_term_id && !$has_override_term_id) {
|
||||
$term_id = absint(get_queried_object_id());
|
||||
}
|
||||
$config = [
|
||||
'context' => $context,
|
||||
'term_id' => $term_id,
|
||||
'is_home' => $context === 'home',
|
||||
'is_category' => $context === 'category',
|
||||
'is_tag' => $context === 'tag',
|
||||
'is_author' => $context === 'author',
|
||||
'is_search' => $context === 'search',
|
||||
];
|
||||
foreach (['type', 'no_author', 'no_margin', 'is_mult_thumb', 'is_no_thumb', 'is_card', 'highlight_query', 'wrapper_class', 'skip_wrapper'] as $key) {
|
||||
foreach (['type', 'term_id', 'no_author', 'no_margin', 'is_mult_thumb', 'is_no_thumb', 'is_card', 'highlight_query', 'wrapper_class', 'skip_wrapper'] as $key) {
|
||||
if (array_key_exists($key, $overrides)) {
|
||||
$config[$key] = $overrides[$key];
|
||||
$config[$key] = $key === 'term_id' ? absint($overrides[$key]) : $overrides[$key];
|
||||
}
|
||||
}
|
||||
return aksrt_renderer_config($config);
|
||||
|
||||
@@ -17,6 +17,7 @@ if (!function_exists('aksrt_renderer_defaults')) {
|
||||
'is_mult_thumb' => false,
|
||||
'is_no_thumb' => false,
|
||||
'is_card' => false,
|
||||
'term_id' => 0,
|
||||
'is_category' => is_category(),
|
||||
'is_search' => is_search(),
|
||||
'is_home' => is_home() || is_front_page(),
|
||||
@@ -57,8 +58,8 @@ if (!function_exists('aksrt_renderer_config')) {
|
||||
|| (!empty($args['is_home']) && !empty($list['list_card_home']))
|
||||
|| (!empty($args['is_author']) && !empty($list['list_card_author']));
|
||||
}
|
||||
if (!$is_forced && !$is_card) {
|
||||
$term_id = (int) get_queried_object_id();
|
||||
if (!$is_forced && !$is_card && !empty($args['is_category'])) {
|
||||
$term_id = absint($args['term_id']);
|
||||
$is_card = $term_id > 0 && in_array($term_id, (array) ($list['list_card_cat'] ?? []), true);
|
||||
}
|
||||
|
||||
@@ -73,8 +74,6 @@ if (!function_exists('aksrt_renderer_config')) {
|
||||
$args['list_type'] = $list_type;
|
||||
$args['style'] = $style;
|
||||
$args['img_position'] = sanitize_key((string) ($list_option['img_position'] ?? 'left')) === 'right' ? 'right' : 'left';
|
||||
$args['list_scale'] = max(50, min(200, (int) ($list_option['scale'] ?? 70)));
|
||||
$args['card_scale'] = max(20, min(200, (int) ($card_option['scale'] ?? 70)));
|
||||
$args['no_margin'] = !empty($args['no_margin']) || (($list['list_show_type'] ?? 'separate') === 'no_margin');
|
||||
$args['no_author'] = !empty($args['no_author']) || !empty($args['is_author']);
|
||||
$args['target_blank'] = !empty($list['target_blank']);
|
||||
@@ -83,7 +82,6 @@ if (!function_exists('aksrt_renderer_config')) {
|
||||
$args['show_time'] = !empty($list['post_list_time']);
|
||||
$args['time_source'] = (string) ($list['post_time_source'] ?? 'modified');
|
||||
$args['list_orderby'] = (string) ($list['list_orderby'] ?? 'modified');
|
||||
$args['mobile_meta'] = (string) ($list['list_meta_show'] ?? 'like');
|
||||
$args['badge_types'] = (array) ($list['list_badge_show'] ?? ['pay', 'cat', 'tag']);
|
||||
$args['mult_thumb_cat'] = (array) ($list['mult_thumb_cat'] ?? []);
|
||||
$args['thumb'] = $thumb;
|
||||
|
||||
Reference in new issue
Block a user