feat(homepage): consume Zibll homepage keys on frontend queries
Point homepage getters and tab queries at home_lists / home_exclude_* / index_list_title / list1 orderby. Support category+topics tab terms via tax_query, expand the homepage term picker API, and keep facade method names for existing templates without dual-writing storage keys.
This commit is contained in:
@@ -263,7 +263,16 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
|
||||
];
|
||||
|
||||
if ($term_id > 0) {
|
||||
$args['cat'] = $term_id;
|
||||
$term = get_term($term_id);
|
||||
$taxonomy = ($term && !is_wp_error($term)) ? (string) $term->taxonomy : 'category';
|
||||
if (!in_array($taxonomy, ['category', 'topics'], true)) {
|
||||
$taxonomy = 'category';
|
||||
}
|
||||
$args['tax_query'] = [[
|
||||
'taxonomy' => $taxonomy,
|
||||
'field' => 'term_id',
|
||||
'terms' => [$term_id],
|
||||
]];
|
||||
}
|
||||
|
||||
$exclude_ids = class_exists('AKSRT_Settings')
|
||||
@@ -327,11 +336,43 @@ class AKSRT_Admin_Global_Controller extends AKSRT_Admin_Controller_Base {
|
||||
}
|
||||
|
||||
public function rest_homepage_categories(): WP_REST_Response {
|
||||
$cats = get_categories(['hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC']);
|
||||
$data = [];
|
||||
|
||||
$cats = get_categories(['hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC']);
|
||||
foreach ($cats as $cat) {
|
||||
$data[] = ['id' => $cat->term_id, 'name' => $cat->name, 'slug' => $cat->slug, 'count' => $cat->count, 'parent' => $cat->parent];
|
||||
$data[] = [
|
||||
'id' => (int) $cat->term_id,
|
||||
'term_id' => (int) $cat->term_id,
|
||||
'name' => $cat->name,
|
||||
'slug' => $cat->slug,
|
||||
'count' => (int) $cat->count,
|
||||
'parent' => (int) $cat->parent,
|
||||
'taxonomy' => 'category',
|
||||
];
|
||||
}
|
||||
|
||||
if (taxonomy_exists('topics')) {
|
||||
$topics = get_terms([
|
||||
'taxonomy' => 'topics',
|
||||
'hide_empty' => false,
|
||||
'orderby' => 'name',
|
||||
'order' => 'ASC',
|
||||
]);
|
||||
if (!is_wp_error($topics)) {
|
||||
foreach ($topics as $term) {
|
||||
$data[] = [
|
||||
'id' => (int) $term->term_id,
|
||||
'term_id' => (int) $term->term_id,
|
||||
'name' => $term->name,
|
||||
'slug' => $term->slug,
|
||||
'count' => (int) $term->count,
|
||||
'parent' => (int) $term->parent,
|
||||
'taxonomy' => 'topics',
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success(['data' => $data]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user