Catégories résolues par slug et IDs Pods par nom, tests
This commit is contained in:
@@ -37,13 +37,27 @@ class Thalim_NL_Post_Query {
|
||||
*/
|
||||
private const SEANCE_WINDOW_MARGIN_DAYS = 5;
|
||||
|
||||
/** Categories to exclude from the newsletter UI */
|
||||
private const EXCLUDED_CATS = [
|
||||
9, // Vie du labo (intranet)
|
||||
12, // Séance de séminaire
|
||||
20, // Newsletter
|
||||
31, // Non classé
|
||||
];
|
||||
/**
|
||||
* Categories to exclude from the newsletter UI, résolues par slug
|
||||
* (fallback sur les IDs historiques si un slug est introuvable).
|
||||
*/
|
||||
private static function excluded_cats(): array {
|
||||
static $ids = null;
|
||||
if ($ids === null) {
|
||||
$map = [
|
||||
'vie-du-labo-intranet' => 9, // Vie du labo (intranet)
|
||||
'seance-de-seminaire' => 12, // Séance de séminaire
|
||||
'newsletter' => 20, // Newsletter
|
||||
'non-classe' => 31, // Non classé
|
||||
];
|
||||
$ids = [];
|
||||
foreach ($map as $slug => $fallback) {
|
||||
$term = get_term_by('slug', $slug, 'category');
|
||||
$ids[] = $term ? (int) $term->term_id : $fallback;
|
||||
}
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all newsletter-eligible categories, grouped by parent.
|
||||
@@ -61,7 +75,7 @@ class Thalim_NL_Post_Query {
|
||||
$parents = [];
|
||||
|
||||
foreach ($all_cats as $cat) {
|
||||
if (in_array($cat->term_id, self::EXCLUDED_CATS, true)) {
|
||||
if (in_array($cat->term_id, self::excluded_cats(), true)) {
|
||||
continue;
|
||||
}
|
||||
if ($cat->parent == 0) {
|
||||
@@ -74,7 +88,7 @@ class Thalim_NL_Post_Query {
|
||||
}
|
||||
|
||||
foreach ($all_cats as $cat) {
|
||||
if (in_array($cat->term_id, self::EXCLUDED_CATS, true)) {
|
||||
if (in_array($cat->term_id, self::excluded_cats(), true)) {
|
||||
continue;
|
||||
}
|
||||
if ($cat->parent == 0) {
|
||||
|
||||
Reference in New Issue
Block a user