FEATURE Refactoring and optimizing admin columns for thematiques
This commit is contained in:
parent
6f277c7c83
commit
12a3af83ed
|
|
@ -271,7 +271,47 @@ function build_page_chapter_index($blocks)
|
|||
}
|
||||
|
||||
/* -------------------------------------------
|
||||
GET PARCOURS PREVIOUS/NEXT POSTS
|
||||
GET ALL THEMATIQUES ORGANIZED BY PARENTS
|
||||
---------------------------------------------*/
|
||||
function getAllThematiquesTermsByParents()
|
||||
{
|
||||
// Récupérer tous les termes de la taxonomie 'thematiques' avec une hiérarchie
|
||||
$ThematiquesTerms = get_terms([
|
||||
'taxonomy' => 'thematiques',
|
||||
'orderby' => 'name',
|
||||
'order' => 'ASC',
|
||||
'hide_empty' => true,
|
||||
]);
|
||||
|
||||
$terms_by_parent = [];
|
||||
$child_terms = [];
|
||||
|
||||
if ($ThematiquesTerms) {
|
||||
|
||||
// Boucle pour organiser les termes en fonction de leurs parents
|
||||
foreach ($ThematiquesTerms as $term) {
|
||||
if ($term->parent == 0) {
|
||||
// Si c'est un parent, on le place dans le tableau des parents
|
||||
$terms_by_parent[$term->term_id] = ['term' => $term, 'children' => []];
|
||||
} else {
|
||||
$child_terms[$term->parent][] = $term;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Réunir les termes parents et leurs enfants
|
||||
foreach ($terms_by_parent as $parent_id => &$parent_data) {
|
||||
// Ajouter les enfants au parent
|
||||
if (isset($child_terms[$parent_id])) {
|
||||
$parent_data['children'] = $child_terms[$parent_id];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $terms_by_parent;
|
||||
}
|
||||
|
||||
/* -------------------------------------------
|
||||
GET PARCOURS PREVIOUS/NEXT POSTS
|
||||
---------------------------------------------*/
|
||||
|
||||
function get_parcours_previous_next_posts($post)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user