feat(widgets): number paginate for hot/paid/forum lists
Extend aksrt_get_ajax_number_paginate to HotPosts, PaidPosts, forum hot/topic lists and product tabs; REST accepts number + paid filters.
This commit is contained in:
1 parent
22f7e7ecf5
commit
1a92adbaf1
6 files changed
+88
-44
No files matched your search
@@ -125,10 +125,16 @@ class WidgetAjax {
|
||||
if (!class_exists('\AKSRT\Widgets\WidgetPaidPosts')) {
|
||||
return $this->fail();
|
||||
}
|
||||
$paginate = sanitize_key((string) ($request->get_param('paginate') ?? 'ajax'));
|
||||
if (!in_array($paginate, ['none', 'ajax', 'number'], true)) {
|
||||
$paginate = 'ajax';
|
||||
}
|
||||
$instance = [
|
||||
'count' => max(1, min(20, (int) ($request->get_param('count') ?? 6))),
|
||||
'orderby' => sanitize_key((string) ($request->get_param('orderby') ?? 'date')),
|
||||
'paginate' => sanitize_key((string) ($request->get_param('paginate') ?? 'ajax')),
|
||||
'count' => max(1, min(20, (int) ($request->get_param('count') ?? 6))),
|
||||
'orderby' => sanitize_key((string) ($request->get_param('orderby') ?? 'date')),
|
||||
'cat' => max(0, (int) ($request->get_param('cat') ?? 0)),
|
||||
'limit_day' => max(0, (int) ($request->get_param('limit_day') ?? 0)),
|
||||
'paginate' => $paginate,
|
||||
];
|
||||
$page = max(1, (int) ($request->get_param('page') ?? $request->get_param('paged') ?? 1));
|
||||
return $this->payload(\AKSRT\Widgets\WidgetPaidPosts::query_payload($instance, $page), $page);
|
||||
@@ -187,12 +193,16 @@ class WidgetAjax {
|
||||
if (!class_exists('\AKSRT\Widgets\HotPostsWidget')) {
|
||||
return $this->fail();
|
||||
}
|
||||
$paginate = sanitize_key((string) ($request->get_param('paginate') ?? 'ajax'));
|
||||
if (!in_array($paginate, ['none', 'ajax', 'number'], true)) {
|
||||
$paginate = 'ajax';
|
||||
}
|
||||
$instance = [
|
||||
'count' => max(1, min(20, (int) ($request->get_param('count') ?? 5))),
|
||||
'order_by' => sanitize_key((string) ($request->get_param('order_by') ?? 'views')),
|
||||
'days' => max(0, (int) ($request->get_param('days') ?? 30)),
|
||||
'show_thumb' => $request->get_param('show_thumb') === null ? 1 : (int) $request->get_param('show_thumb'),
|
||||
'paginate' => sanitize_key((string) ($request->get_param('paginate') ?? 'ajax')),
|
||||
'paginate' => $paginate,
|
||||
];
|
||||
$page = max(1, (int) ($request->get_param('page') ?? 1));
|
||||
return $this->payload(\AKSRT\Widgets\HotPostsWidget::query_payload($instance, $page), $page);
|
||||
@@ -260,7 +270,7 @@ class WidgetAjax {
|
||||
'orderby' => sanitize_key((string) ($request->get_param('orderby') ?? 'views')),
|
||||
'style' => $style,
|
||||
'plate' => max(0, (int) ($request->get_param('plate') ?? $request->get_param('plate_id') ?? 0)),
|
||||
'paginate' => sanitize_key((string) ($request->get_param('paginate') ?? 'ajax')),
|
||||
'paginate' => in_array(sanitize_key((string) ($request->get_param('paginate') ?? 'ajax')), ['none', 'ajax', 'number'], true) ? sanitize_key((string) ($request->get_param('paginate') ?? 'ajax')) : 'ajax',
|
||||
];
|
||||
$page = max(1, (int) ($request->get_param('page') ?? 1));
|
||||
return $this->payload(\AKSRT\Widgets\WidgetForumHotTopics::query_payload($instance, $page), $page);
|
||||
|
||||
Reference in new issue
Block a user