feat(forum): plate lists widget payload + REST
Shared query_payload for plate lists and /forum/frontend/widgets/plates for remote refresh.
This commit is contained in:
1 parent
c52651f647
commit
425ca6cd2e
2 files changed
+91
-24
No files matched your search
@@ -252,6 +252,11 @@ class Forum {
|
||||
'callback' => [$this, 'rest_widget_topics'],
|
||||
'permission_callback' => '__return_true',
|
||||
]);
|
||||
register_rest_route('aksrt/v1', '/forum/frontend/widgets/plates', [
|
||||
'methods' => 'GET',
|
||||
'callback' => [$this, 'rest_widget_plates'],
|
||||
'permission_callback' => '__return_true',
|
||||
]);
|
||||
}
|
||||
|
||||
public function rest_widget_topics(\WP_REST_Request $request) {
|
||||
@@ -278,6 +283,24 @@ class Forum {
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function rest_widget_plates(\WP_REST_Request $request) {
|
||||
if (!class_exists('\AKSRT\Widgets\WidgetForumPlateLists')) {
|
||||
return new \WP_REST_Response(['success' => false, 'message' => 'widget unavailable'], 500);
|
||||
}
|
||||
$instance = [
|
||||
'showposts' => max(1, min(30, (int) ($request->get_param('showposts') ?? $request->get_param('count') ?? 8))),
|
||||
'orderby' => sanitize_key((string) ($request->get_param('orderby') ?? 'menu_order')),
|
||||
'style' => sanitize_key((string) ($request->get_param('style') ?? 'default')),
|
||||
'filter' => sanitize_key((string) ($request->get_param('filter') ?? '')),
|
||||
'cat' => sanitize_text_field((string) ($request->get_param('cat') ?? '')),
|
||||
];
|
||||
$payload = \AKSRT\Widgets\WidgetForumPlateLists::query_payload($instance);
|
||||
return new \WP_REST_Response([
|
||||
'success' => true,
|
||||
'html' => (string) ($payload['html'] ?? ''),
|
||||
], 200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function render_board_cards(array $boards): void {
|
||||
|
||||
Reference in new issue
Block a user