fix(widgets): restore article list rendering and reference styles
This commit is contained in:
1 parent
4ea00f1322
commit
fc04bf65e6
18 files changed
+345
-97
No files matched your search
@@ -24,7 +24,7 @@ final class PostQuery {
|
||||
'ignore_sticky_posts' => true,
|
||||
'no_found_rows' => false,
|
||||
];
|
||||
if (array_key_exists('paginate', $config) && in_array((string) $config['paginate'], ['', 'none'], true)) {
|
||||
if (isset($config['paginate']) && $config['paginate'] === '') {
|
||||
$args['no_found_rows'] = true;
|
||||
$args['paged'] = 1;
|
||||
}
|
||||
@@ -33,13 +33,22 @@ final class PostQuery {
|
||||
// category_ids remains available only to the unrelated generic posts
|
||||
// widgets; a tab segment must never fall back to it.
|
||||
$is_reference_segment = array_key_exists('cat', $segment);
|
||||
$cat_raw = array_key_exists('cat', $config) ? (string) $config['cat'] : ($is_reference_segment ? '' : (string) ($config['category_ids'] ?? ''));
|
||||
$categories = self::signed_ids($cat_raw);
|
||||
if (!empty($config['category_id'])) $categories = [(int) $config['category_id']];
|
||||
$cat_in = array_values(array_filter($categories, static fn(int $id): bool => $id > 0));
|
||||
$cat_not = array_values(array_map('abs', array_filter($categories, static fn(int $id): bool => $id < 0)));
|
||||
if ($cat_in) $args['category__in'] = $cat_in;
|
||||
if ($cat_not) $args['category__not_in'] = $cat_not;
|
||||
if (array_key_exists('cat', $config)) {
|
||||
// WP_Query's `cat` expands included parents to descendants and
|
||||
// applies negative IDs with the same reference-theme semantics.
|
||||
$categories = self::signed_ids((string) $config['cat']);
|
||||
if ($categories) {
|
||||
$args['cat'] = implode(',', $categories);
|
||||
}
|
||||
} else {
|
||||
// Generic widgets retain their explicit category ID/list behavior.
|
||||
$categories = self::signed_ids((string) ($config['category_ids'] ?? ''));
|
||||
if (!empty($config['category_id'])) $categories = [(int) $config['category_id']];
|
||||
$cat_in = array_values(array_filter($categories, static fn(int $id): bool => $id > 0));
|
||||
$cat_not = array_values(array_map('abs', array_filter($categories, static fn(int $id): bool => $id < 0)));
|
||||
if ($cat_in) $args['category__in'] = $cat_in;
|
||||
if ($cat_not) $args['category__not_in'] = $cat_not;
|
||||
}
|
||||
$tags = $is_reference_segment ? [] : RendererHelpers::ids((string) ($config['tag_ids'] ?? ''));
|
||||
if ($tags) {
|
||||
$args['tag__in'] = $tags;
|
||||
@@ -47,14 +56,15 @@ final class PostQuery {
|
||||
|
||||
$days = max(0, (int) ($config['limit_day'] ?? 0));
|
||||
if ($days > 0) {
|
||||
$now = function_exists('current_time') ? current_time('timestamp') : time();
|
||||
$format = static function (int $timestamp): string {
|
||||
return function_exists('wp_date') ? wp_date('Y-m-d H:i:s', $timestamp) : date('Y-m-d H:i:s', $timestamp);
|
||||
};
|
||||
$args['date_query'] = [['after' => $format($now - ($days * DAY_IN_SECONDS)), 'before' => $format($now), 'inclusive' => true]];
|
||||
$now = current_datetime();
|
||||
$args['date_query'] = [[
|
||||
'after' => $now->modify('-' . $days . ' days')->format('Y-m-d H:i:s'),
|
||||
'before' => $now->format('Y-m-d H:i:s'),
|
||||
'inclusive' => true,
|
||||
]];
|
||||
}
|
||||
self::apply_order($args, (string) ($config['orderby'] ?? 'date'), (string) ($config['order'] ?? 'DESC'));
|
||||
$pay = $is_reference_segment ? ($config['zibpay_type'] ?? []) : ($config['pay_type'] ?? '');
|
||||
$pay = array_key_exists('zibpay_type', $config) ? $config['zibpay_type'] : ($config['pay_type'] ?? '');
|
||||
self::apply_pay_type($args, $pay);
|
||||
return $args;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user