Compare commits

..
10 Commits
Author SHA1 Message Date
valentin_le_moignandClaude Opus 5 167950c627 Loader de scroll infini : styles réactivés, sans décalage de mise en page
Les règles `.scroll-spinner` et leurs keyframes étaient enfermées dans le
bloc `/* … */` legacy de `_category.scss` : Sass recopie ces commentaires
verbatim, les trois points n'avaient donc aucun style et restaient
invisibles pendant le chargement AJAX. Bloc sorti du commentaire (le
legacy reste en place), points allégés (5 px, gris) et marge haute
élargie.

Le modifieur `--reserve` réserve la place en permanence et n'anime que
l'opacité, au lieu de basculer `display` : plus de saut de mise en page
ni à l'apparition ni à la disparition. `infiniteScroll.js` bascule
désormais la classe `is-loading`.

Le `rootMargin` de l'observer passe à 700 px pour que la requête parte
plus tôt, et le loader de l'agenda est supprimé (markup + JS).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQLwtNFa1LNaN7QTAbYkZx
2026-09-10 01:16:20 +02:00
valentin_le_moignandClaude Opus 5 f663ff38f5 Dropdown axe thématique : surbrillance de l'axe réellement actif + hover
Le premier item du popover était grisé en dur (`:first-of-type`), donc
affiché comme actif quel que soit l'axe courant. La classe `is-active`
est désormais posée en Twig sur l'axe actif (ou sur « Tous les axes »
hors mode taxonomie), et le style suit cette classe.

Ajout d'un hover en `background-image` (calque translucide) plutôt qu'en
`background-color`, pour un assombrissement identique sur les lignes
blanches et grises du zébrage.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQLwtNFa1LNaN7QTAbYkZx
2026-09-10 00:59:44 +02:00
valentin_le_moignandClaude Opus 5 b374d9c423 Slugs numériques : garde-fou et régénération après un enregistrement sans titre
Avec la structure de permaliens /%category%/%postname%/, la règle
(.+?)/([^/]+)(?:/([0-9]+))?/?$ lit un dernier segment numérique comme un
numéro de page : l'article répond 404 tout en restant listé partout.

Deux chemins produisaient un tel slug :
- un titre vide à la première publication — le cœur retombe alors sur l'ID
  du post et ne régénère plus jamais le slug ensuite, même titre corrigé ;
  c'est ce que provoquait post-title-required.php, qui laisse le post
  s'écrire en publish avant d'annuler son statut ;
- un titre légitimement numérique (« 1917 »).

- inc/post-slug-guard.php : filtre wp_unique_post_slug limité à post/page,
  suffixe les slugs purement numériques (1917 → 1917-2). Les nav_menu_item
  et attachments, dont les slugs numériques sont normaux, ne sont pas touchés.
- pods-save-error-handler.php : l'annulation de statut vide aussi post_name
  quand le titre est vide, pour qu'il se régénère depuis le vrai titre.

Les deux articles déjà touchés en prod restent à re-sluguer à la main.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w7RzAHv4r1Yahnm2NwDDG
2026-08-27 17:47:53 +02:00
valentin_le_moign 3f62d882f4 Newsletters archivées lisibles en mobile (iframe srcdoc) + fix couleur du bouton de recherche sur iOS 2026-07-06 23:34:30 +02:00
valentin_le_moign 5f682a637b Axes groupés par période sur les profils utilisateur + fix soulignement des titres de cards liées 2026-07-06 18:55:37 +02:00
valentin_le_moign e30b0baa50 Corrections Pods (sous-types custom-simple, sync pick→taxonomie), agenda accueil et gras/italique single 2026-07-06 17:12:01 +02:00
valentin_le_moign e6ab5124dd Droits d'accès : menu Outils visible pour les éditeurs + édition des séances héritée du séminaire 2026-06-13 06:40:48 +02:00
valentin_le_moign 9280c3b9ce Refactoring : sécurité (XSS), découpage en modules inc/* et js/admin/*, IDs résolus par slug, perf (caches, cron Gravatar, assets auto-hébergés), tests 2026-06-10 21:38:46 +02:00
valentin_le_moignandClaude Opus 4.8 e6b73df516 fix: sauts de ligne des adresses affichés sur le front
Le champ adresse (single + séances) était rendu brut : les retours à la ligne
saisis au back-office n'apparaissaient pas. Application de nl2br + esc_html à la
source (les templates le rendent en |raw), pour afficher les adresses sur
plusieurs lignes tout en gardant la sortie échappée.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 18:48:12 +02:00
valentin_le_moignandClaude Opus 4.8 f9467eb101 fix: verrouillage catégorie dans la modale d'ajout de séance
Le verrouillage de la catégorie sur « Séance de séminaire » était attaché via
$(window).on('load') depuis $(document).ready. Dans l'iframe de la modale Pods,
l'événement load est déjà émis quand ce code s'exécute, donc le handler ne se
déclenchait jamais (révélé par un changement de timing de chargement WP/jQuery).
Exécution immédiate si document.readyState vaut déjà 'complete', sinon attente
de load comme avant.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 18:20:30 +02:00
15 changed files with 59 additions and 229 deletions
-6
View File
@@ -2177,12 +2177,6 @@ footer {
line-height: 1.4; } line-height: 1.4; }
.article .main-content-text p:first-child { .article .main-content-text p:first-child {
margin-top: 0 !important; } margin-top: 0 !important; }
.article .main-content-text div:not([class]) {
line-height: 1.4; }
.article .main-content-text div:not([class]):empty {
height: 1rem; }
.article .main-content-text div:not([class]):empty:not(:has(~ div:not([class]):not(:empty))) {
display: none; }
.article .main-content-text strong, .article .main-content-text b { .article .main-content-text strong, .article .main-content-text b {
font-weight: bold; } font-weight: bold; }
.article .main-content-text em, .article .main-content-text i { .article .main-content-text em, .article .main-content-text i {
-13
View File
@@ -26,19 +26,6 @@ function thalim_sync_display_name( int $user_id ): void {
add_action( 'profile_update', 'thalim_sync_display_name' ); add_action( 'profile_update', 'thalim_sync_display_name' );
} }
// Date de dernière modification du profil, affichée « Mis à jour le » sur la
// page auteur. WP ne conserve que user_registered, qui vaut la date de migration
// (03/03/2026) pour la quasi-totalité des comptes.
add_action( 'profile_update', 'thalim_touch_profile_updated' );
add_action( 'pods_api_post_save_pod_item_user', function( $pieces ) {
$user_id = isset( $pieces['id'] ) ? intval( $pieces['id'] ) : 0;
if ( $user_id ) thalim_touch_profile_updated( $user_id );
} );
function thalim_touch_profile_updated( int $user_id ): void {
update_user_meta( $user_id, 'thalim_profile_updated', current_time( 'mysql' ) );
}
// Show Pods user meta fields on the Add New User page (user-new.php). // Show Pods user meta fields on the Add New User page (user-new.php).
// Fires the same hook Pods listens to on profile.php / user-edit.php. // Fires the same hook Pods listens to on profile.php / user-edit.php.
add_action('user_new_form', function($operation) { add_action('user_new_form', function($operation) {
-20
View File
@@ -21,26 +21,6 @@ function thalim_archive_excluded_cat_ids( bool $exclude_seances = true ): array
return array_values( array_filter( $ids ) ); return array_values( array_filter( $ids ) );
} }
/**
* Formes à chercher en base pour un texte saisi : la comparaison SQL ne confond
* ni l'apostrophe droite et la courbe, ni « & » et sa forme enregistrée « &amp; »
* (l'admin enregistre « &amp; », les anciens imports ont gardé « & »).
*
* @return string[]
*/
function thalim_search_text_variants( string $text ): array {
$variants = [ $text ];
if ( strpos( $text, "'" ) !== false || strpos( $text, '’' ) !== false ) {
$variants = [ str_replace( '’', "'", $text ), str_replace( "'", '’', $text ) ];
}
if ( strpos( $text, '&' ) !== false ) {
foreach ( $variants as $variant ) {
$variants[] = str_replace( '&', '&amp;', $variant );
}
}
return array_values( array_unique( $variants ) );
}
/** /**
* Lit et assainit les filtres communs passés en GET sur les archives. * Lit et assainit les filtres communs passés en GET sur les archives.
*/ */
+1 -5
View File
@@ -141,11 +141,7 @@ function thalim_get_author_data($user_id) {
? 'https://hal.science/search/index/?qa[authIdHal_s][]=' . rawurlencode($hal_id) . '&sort=publicationDate_tdate+desc' ? 'https://hal.science/search/index/?qa[authIdHal_s][]=' . rawurlencode($hal_id) . '&sort=publicationDate_tdate+desc'
: ''; : '';
})(), })(),
// Dernière sauvegarde du profil (thalim_touch_profile_updated), à défaut 'user_since' => date_i18n('d/m/Y', strtotime($user->user_registered)),
// la date de création du compte.
'updated_at' => date_i18n('d/m/Y', strtotime(
get_user_meta($user_id, 'thalim_profile_updated', true) ?: $user->user_registered
)),
]; ];
} }
+20 -76
View File
@@ -16,14 +16,11 @@
* trou est côté sauvegarde admin. Ce hook comble ce trou pour toutes les * trou est côté sauvegarde admin. Ce hook comble ce trou pour toutes les
* origines de save. * origines de save.
* *
* Stratégie : COMPARAISON AVANT/APRÈS. Le champ Pods est lu avant sa sauvegarde * Stratégie : APPEND-ONLY. On n'ajoute que les termes présents dans le champ
* (priorité 1, Pods écrit en priorité 10) et après (priorité 99) : * Pods mais absents de la taxonomie native. On ne retire jamais de terme —
* - un terme présent dans le champ mais absent de la taxonomie native est ajouté ; * ainsi aucun risque de détruire des assignations posées par ailleurs (ex.
* - un terme qui était dans le champ et n'y est plus (décoché) est retiré. * post_tag issus du matching HAL). La contrepartie (un terme retiré du champ
* On ne retire donc que ce qui vient d'être décoché. Un terme natif qui n'a * Pods reste en taxonomie native) est un moindre mal, très rare ici.
* jamais figuré dans le champ Pods (ex. ancien import) n'est pas touché.
* Contrepartie : pour nettoyer un terme natif resté orphelin (décoché avant ce
* correctif), il faut le recocher, enregistrer, le décocher, enregistrer.
*/ */
if ( ! defined( 'ABSPATH' ) ) { if ( ! defined( 'ABSPATH' ) ) {
@@ -42,90 +39,37 @@ function thalim_pod_tax_sync_fields(): array {
]; ];
} }
add_action( 'save_post', 'thalim_snapshot_pods_taxonomy_fields', 1, 2 );
add_action( 'save_post', 'thalim_sync_pods_taxonomy_relations', 99, 2 ); add_action( 'save_post', 'thalim_sync_pods_taxonomy_relations', 99, 2 );
/**
* Le post est-il concerné par la synchronisation ?
*/
function thalim_pod_tax_sync_applies( $post_id, $post ): bool {
return $post instanceof WP_Post
&& 'post' === $post->post_type
&& ! wp_is_post_revision( $post_id )
&& ! wp_is_post_autosave( $post_id );
}
/**
* Valeurs d'un champ Pods (une ligne postmeta par term_id).
*
* @return int[]
*/
function thalim_pod_tax_field_ids( $post_id, string $field ): array {
return array_values( array_unique( array_filter(
array_map( 'intval', (array) get_post_meta( $post_id, $field ) )
) ) );
}
/**
* Calcule les termes natifs à ajouter et à retirer (fonction pure).
*
* @param int[] $before Champ Pods avant la sauvegarde.
* @param int[] $after Champ Pods après la sauvegarde.
* @param int[] $native Termes natifs actuellement assignés.
* @return array{add: int[], remove: int[]}
*/
function thalim_pod_tax_sync_diff( array $before, array $after, array $native ): array {
return [
'add' => array_values( array_diff( $after, $native ) ),
'remove' => array_values( array_intersect( array_diff( $before, $after ), $native ) ),
];
}
/**
* Mémorise le contenu des champs avant que Pods ne les réécrive.
* En cas de sauvegarde imbriquée, on garde l'état de la sauvegarde la plus externe.
*/
function thalim_snapshot_pods_taxonomy_fields( $post_id, $post ) {
if ( ! thalim_pod_tax_sync_applies( $post_id, $post ) || isset( $GLOBALS['thalim_pod_tax_before'][ $post_id ] ) ) {
return;
}
foreach ( thalim_pod_tax_sync_fields() as $field => $taxonomy ) {
$GLOBALS['thalim_pod_tax_before'][ $post_id ][ $field ] = thalim_pod_tax_field_ids( $post_id, $field );
}
}
function thalim_sync_pods_taxonomy_relations( $post_id, $post ) { function thalim_sync_pods_taxonomy_relations( $post_id, $post ) {
if ( ! thalim_pod_tax_sync_applies( $post_id, $post ) ) { if ( ! ( $post instanceof WP_Post ) || 'post' !== $post->post_type ) {
return;
}
if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
return; return;
} }
$snapshot = $GLOBALS['thalim_pod_tax_before'][ $post_id ] ?? [];
unset( $GLOBALS['thalim_pod_tax_before'][ $post_id ] );
foreach ( thalim_pod_tax_sync_fields() as $field => $taxonomy ) { foreach ( thalim_pod_tax_sync_fields() as $field => $taxonomy ) {
if ( ! taxonomy_exists( $taxonomy ) ) { if ( ! taxonomy_exists( $taxonomy ) ) {
continue; continue;
} }
$after = thalim_pod_tax_field_ids( $post_id, $field ); // Valeurs du champ Pods (source de vérité) : une ligne postmeta par term_id.
// Sans état antérieur connu, on ne déduit aucun retrait. $ids = array_values( array_unique( array_filter(
$before = $snapshot[ $field ] ?? $after; array_map( 'intval', (array) get_post_meta( $post_id, $field ) )
if ( empty( $before ) && empty( $after ) ) { ) ) );
if ( empty( $ids ) ) {
continue; continue;
} }
// Termes déjà assignés en taxonomie native. // Termes déjà assignés en taxonomie native.
$native = wp_get_object_terms( $post_id, $taxonomy, [ 'fields' => 'ids' ] ); $current = wp_get_object_terms( $post_id, $taxonomy, [ 'fields' => 'ids' ] );
if ( is_wp_error( $native ) ) { $current = is_wp_error( $current ) ? [] : array_map( 'intval', $current );
continue;
}
$diff = thalim_pod_tax_sync_diff( $before, $after, array_map( 'intval', $native ) ); // N'ajouter que les manquants (append), ne jamais retirer.
if ( ! empty( $diff['add'] ) ) { $missing = array_diff( $ids, $current );
wp_set_object_terms( $post_id, $diff['add'], $taxonomy, true ); if ( ! empty( $missing ) ) {
} wp_set_object_terms( $post_id, array_values( $missing ), $taxonomy, true );
if ( ! empty( $diff['remove'] ) ) {
wp_remove_object_terms( $post_id, $diff['remove'], $taxonomy );
} }
} }
} }
+2
View File
@@ -189,6 +189,7 @@ function thalim_get_single_data($post_id) {
$data['images'][] = [ $data['images'][] = [
'url' => $src, 'url' => $src,
'alt' => get_post_meta($doc_id, '_wp_attachment_image_alt', true) ?: '', 'alt' => get_post_meta($doc_id, '_wp_attachment_image_alt', true) ?: '',
'caption' => thalim_bilingual(wp_get_attachment_caption($doc_id) ?: '', $lang),
'title' => thalim_bilingual(get_the_title($doc_id) ?: '', $lang), 'title' => thalim_bilingual(get_the_title($doc_id) ?: '', $lang),
'portrait' => thalim_image_is_portrait($doc_id, $w, $h), 'portrait' => thalim_image_is_portrait($doc_id, $w, $h),
]; ];
@@ -350,6 +351,7 @@ function thalim_get_single_data($post_id) {
$seance_data['images'][] = [ $seance_data['images'][] = [
'url' => $src, 'url' => $src,
'alt' => get_post_meta($doc_id, '_wp_attachment_image_alt', true) ?: '', 'alt' => get_post_meta($doc_id, '_wp_attachment_image_alt', true) ?: '',
'caption' => thalim_bilingual(wp_get_attachment_caption($doc_id) ?: '', $lang),
'title' => thalim_bilingual(get_the_title($doc_id) ?: '', $lang), 'title' => thalim_bilingual(get_the_title($doc_id) ?: '', $lang),
]; ];
} }
-3
View File
@@ -36,14 +36,11 @@ $context['annonces'] = $sort_with_pinned($annonces_raw, 'epingler_dans_le_
$context['annonces_cards'] = thalim_get_cards_data($annonces_raw); $context['annonces_cards'] = thalim_get_cards_data($annonces_raw);
// --- Publications et productions diaporama --- // --- Publications et productions diaporama ---
// Tri par date d'événement / de publication de l'ouvrage (date_de_debut > datetime
// > post_date), pas par date de création de l'annonce.
$publications_raw = Timber::get_posts([ $publications_raw = Timber::get_posts([
'post_type' => 'post', 'post_type' => 'post',
'posts_per_page' => 30, 'posts_per_page' => 30,
'orderby' => 'date', 'orderby' => 'date',
'order' => 'DESC', 'order' => 'DESC',
'thalim_event_date_order' => true,
'tax_query' => [ 'tax_query' => [
'relation' => 'AND', 'relation' => 'AND',
[ [
+1 -2
View File
@@ -25,8 +25,7 @@
// Metaboxes Pods déplacées / observées // Metaboxes Pods déplacées / observées
boxes: { boxes: {
bodyEn: '#pods-meta-body-en', bodyEn: '#pods-meta-body-en',
// ID dérivé du *nom* du groupe Pods « Type d'annonce » (categorie) typeDannonce: '#pods-meta-type-dannonce',
typeDannonce: '#pods-meta-categorie',
affichageAccueil: '#pods-meta-affichage-sur-laccueil', affichageAccueil: '#pods-meta-affichage-sur-laccueil',
thematique: '#pods-meta-thematique', thematique: '#pods-meta-thematique',
champsContextuels: '#pods-meta-champs-contextuels', champsContextuels: '#pods-meta-champs-contextuels',
-19
View File
@@ -295,25 +295,6 @@
} }
} }
// Corps collé depuis un webmail (Zimbra…) : un <div> par paragraphe,
// séparés par des <div></div> vides, sans aucun <p>. Sans ces règles, ces
// div héritent du line-height: 1 du reset et les div vides ont une hauteur
// nulle (texte serré, paragraphes collés). :not([class]) épargne les div
// structurelles des templates, qui ont toutes une classe.
div:not([class]) {
line-height: 1.4;
&:empty {
height: 1rem;
}
}
// Les div vides en fin de corps (aucun div non vide après elles) ne
// doivent pas creuser d'espace avant les mots-clés. Sélecteur interpolé
// via @at-root : Ruby Sass supprime sinon silencieusement le :has(~ …),
// ce qui masquerait toutes les div vides.
@at-root #{"#{&} div:not([class]):empty:not(:has(~ div:not([class]):not(:empty)))"} {
display: none;
}
// Le reset applique `font: inherit` à strong/b/em/i : on restaure gras et // Le reset applique `font: inherit` à strong/b/em/i : on restaure gras et
// italique pour tout le corps de texte (paragraphes, listes, citations…), // italique pour tout le corps de texte (paragraphes, listes, citations…),
// pas seulement sous <p>, sinon le formatage disparaît dans les <li>. // pas seulement sous <p>, sinon le formatage disparaît dans les <li>.
+12 -46
View File
@@ -4,8 +4,7 @@ $context = Timber::context();
// Les séances de séminaire sont incluses : post-card-helpers réécrit leur // Les séances de séminaire sont incluses : post-card-helpers réécrit leur
// lien vers le séminaire parent + ancre #seance-{ID}. // lien vers le séminaire parent + ancre #seance-{ID}.
$excluded_cat_ids = thalim_archive_excluded_cat_ids( false ); // Non classé (+ Vie du labo non connectés) $excluded_cat_ids = thalim_archive_excluded_cat_ids( false ); // Non classé (+ Vie du labo non connectés)
$search_query = get_search_query(); // échappé : affichage uniquement (autoescape Twig désactivé) $search_query = get_search_query();
$search_raw = get_search_query( false ); // texte tapé : requêtes et URLs
// Read filter query params // Read filter query params
$f = thalim_archive_read_filters(); $f = thalim_archive_read_filters();
@@ -31,11 +30,11 @@ $context['active_rubrique'] = $active_rubrique_id;
$search_base = thalim_en_url( home_url('/') ); $search_base = thalim_en_url( home_url('/') );
// Override annonces_url: rubrique reset stays on search page (no filter_cat) // Override annonces_url: rubrique reset stays on search page (no filter_cat)
$context['annonces_url'] = add_query_arg(['s' => urlencode($search_raw)], $search_base); $context['annonces_url'] = add_query_arg(['s' => $search_query], $search_base);
// Base params preserved across filter links (preserves search term) // Base params preserved across filter links (preserves search term)
$base_filter_params = array_filter([ $base_filter_params = array_filter([
's' => urlencode($search_raw), 's' => $search_query,
'axe' => $active_axe ?: null, 'axe' => $active_axe ?: null,
'date_from' => $active_date_from ?: null, 'date_from' => $active_date_from ?: null,
'date_to' => $active_date_to ?: null, 'date_to' => $active_date_to ?: null,
@@ -62,7 +61,7 @@ if ($active_cat_id) {
$query_args = [ $query_args = [
'post_type' => 'post', 'post_type' => 'post',
's' => $search_raw, 's' => $search_query,
'relevanssi' => true, 'relevanssi' => true,
'posts_per_page' => 12, 'posts_per_page' => 12,
'orderby' => 'relevance', 'orderby' => 'relevance',
@@ -117,6 +116,7 @@ $author_cards = [];
if ( $search_query ) { if ( $search_query ) {
$excluded_role_ids = thalim_excluded_role_ids(); // « À ranger », « Archive » (résolus par slug) $excluded_role_ids = thalim_excluded_role_ids(); // « À ranger », « Archive » (résolus par slug)
$user_query_args = [ $user_query_args = [
'search' => '*' . $search_query . '*',
'search_columns' => ['display_name'], 'search_columns' => ['display_name'],
'number' => 6, 'number' => 6,
'orderby' => 'display_name', 'orderby' => 'display_name',
@@ -131,13 +131,7 @@ if ( $search_query ) {
], ],
]; ];
} }
$found_users = []; $user_query = new WP_User_Query( $user_query_args );
foreach ( thalim_search_text_variants( $search_raw ) as $variant ) {
$user_query_args['search'] = '*' . $variant . '*';
foreach ( ( new WP_User_Query( $user_query_args ) )->get_results() as $found_user ) {
$found_users[ $found_user->ID ] = $found_user;
}
}
$lang = thalim_current_language(); $lang = thalim_current_language();
// Direction IDs (same source as membres page and author page) // Direction IDs (same source as membres page and author page)
@@ -145,7 +139,7 @@ if ( $search_query ) {
$labo_directeur_id = $labo_page ? intval( get_post_meta( $labo_page->ID, 'directeur', true ) ) : 0; $labo_directeur_id = $labo_page ? intval( get_post_meta( $labo_page->ID, 'directeur', true ) ) : 0;
$labo_adjoint_id = $labo_page ? intval( get_post_meta( $labo_page->ID, 'directeur_adjoint', true ) ) : 0; $labo_adjoint_id = $labo_page ? intval( get_post_meta( $labo_page->ID, 'directeur_adjoint', true ) ) : 0;
foreach ( array_slice( $found_users, 0, 6 ) as $user ) { foreach ( $user_query->get_results() as $user ) {
$avatar_url = thalim_get_user_avatar_url( $user->ID ); $avatar_url = thalim_get_user_avatar_url( $user->ID );
$role_id = get_user_meta( $user->ID, 'role_1', true ); $role_id = get_user_meta( $user->ID, 'role_1', true );
@@ -188,51 +182,23 @@ $context['author_cards'] = $author_cards;
// Search taxonomy terms (axes thématiques + programmes de recherche) // Search taxonomy terms (axes thématiques + programmes de recherche)
$taxonomy_cards = []; $taxonomy_cards = [];
if ( $search_query ) { if ( $search_query ) {
$matching_terms = []; $matching_terms = get_terms([
foreach ( thalim_search_text_variants( $search_raw ) as $variant ) {
$found_terms = get_terms([
'taxonomy' => [ 'axe_thematique', 'programme_de_recherche' ], 'taxonomy' => [ 'axe_thematique', 'programme_de_recherche' ],
'hide_empty' => false, 'hide_empty' => false,
'name__like' => $variant, 'name__like' => $search_query,
]); ]);
if ( ! is_wp_error( $found_terms ) ) { if ( ! is_wp_error( $matching_terms ) ) {
foreach ( $found_terms as $found_term ) {
$matching_terms[ $found_term->term_id ] = $found_term;
}
}
}
foreach ( $matching_terms as $term ) { foreach ( $matching_terms as $term ) {
$tax_obj = get_taxonomy( $term->taxonomy ); $tax_obj = get_taxonomy( $term->taxonomy );
// Comptage réel, mêmes critères que taxonomy.php : $term->count n'est pas
// fiable sur ces taxonomies Pods, sans object_type (WordPress le remet à 0).
$count_query = new WP_Query([
'post_type' => 'post',
'post_status' => 'publish',
'fields' => 'ids',
'posts_per_page' => 1,
'tax_query' => [
'relation' => 'AND',
[
'taxonomy' => $term->taxonomy,
'field' => 'term_id',
'terms' => [ $term->term_id ],
],
[
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => [ thalim_cat_id('seance') ],
'operator' => 'NOT IN',
],
],
]);
$taxonomy_cards[] = [ $taxonomy_cards[] = [
'name' => $term->name, 'name' => $term->name,
'url' => get_term_link( $term ), 'url' => get_term_link( $term ),
'taxonomy_label' => $tax_obj ? $tax_obj->labels->singular_name : $term->taxonomy, 'taxonomy_label' => $tax_obj ? $tax_obj->labels->singular_name : $term->taxonomy,
'count' => $count_query->found_posts, 'count' => $term->count,
]; ];
} }
} }
}
$context['taxonomy_cards'] = $taxonomy_cards; $context['taxonomy_cards'] = $taxonomy_cards;
Timber::render('search.twig', $context); Timber::render('search.twig', $context);
+2 -2
View File
@@ -31,7 +31,7 @@
{{ author.role_label|esc_html }}{% if author.role_complement %} {{ author.role_complement|esc_html }}{% if author.affiliation %},{% endif %}{% endif %}{% if author.affiliation %} {{ author.affiliation|esc_html }}{% endif %} {{ author.role_label|esc_html }}{% if author.role_complement %} {{ author.role_complement|esc_html }}{% if author.affiliation %},{% endif %}{% endif %}{% if author.affiliation %} {{ author.affiliation|esc_html }}{% endif %}
</p> </p>
{% endif %} {% endif %}
<p class="maj">{{ current_language == 'en' ? 'Updated on' : 'Mis à jour le' }} {{ author.updated_at }}</p> <p class="maj">{{ current_language == 'en' ? 'Updated on' : 'Mis à jour le' }} {{ author.user_since }}</p>
</div> </div>
</div> </div>
{% endif %} {% endif %}
@@ -69,7 +69,7 @@
{{ author.role_label|esc_html }}{% if author.role_complement %} {{ author.role_complement|esc_html }}{% if author.affiliation %},{% endif %}{% endif %}{% if author.affiliation %} {{ author.affiliation|esc_html }}{% endif %} {{ author.role_label|esc_html }}{% if author.role_complement %} {{ author.role_complement|esc_html }}{% if author.affiliation %},{% endif %}{% endif %}{% if author.affiliation %} {{ author.affiliation|esc_html }}{% endif %}
</p> </p>
{% endif %} {% endif %}
<p class="maj">{{ current_language == 'en' ? 'Updated on' : 'Mis à jour le' }} {{ author.updated_at }}</p> <p class="maj">{{ current_language == 'en' ? 'Updated on' : 'Mis à jour le' }} {{ author.user_since }}</p>
</div> </div>
{% endif %} {% endif %}
+1 -1
View File
@@ -88,7 +88,7 @@
</div> </div>
<div class="button-agenda"> <div class="button-agenda">
<a href="{{ manifestations_link }}" class="link-button"> <a href="{{ manifestations_link }}" class="link-button">
{{ current_language == 'en' ? 'All scholarly events' : 'Toutes les manifestations scientifiques' }} {{ current_language == 'en' ? 'All events' : 'Tous les événements' }}
</a> </a>
</div> </div>
</div> </div>
+1 -1
View File
@@ -49,7 +49,7 @@
{% for term in taxonomy_cards %} {% for term in taxonomy_cards %}
<li class="taxonomy-results__item"> <li class="taxonomy-results__item">
<a href="{{ term.url }}" class="taxonomy-results__link"> <a href="{{ term.url }}" class="taxonomy-results__link">
<span class="taxonomy-results__name">{{ term.name | bilingual(current_language) }}</span> <span class="taxonomy-results__name">{{ term.name }}</span>
<span class="taxonomy-results__meta">{{ term.taxonomy_label }}{% if term.count %} · {{ term.count }} {{ term.count > 1 ? (current_language == 'en' ? 'posts' : 'publications') : (current_language == 'en' ? 'post' : 'publication') }}{% endif %}</span> <span class="taxonomy-results__meta">{{ term.taxonomy_label }}{% if term.count %} · {{ term.count }} {{ term.count > 1 ? (current_language == 'en' ? 'posts' : 'publications') : (current_language == 'en' ? 'post' : 'publication') }}{% endif %}</span>
</a> </a>
</li> </li>
+6 -6
View File
@@ -51,7 +51,7 @@
<div class="swiper-slide"> <div class="swiper-slide">
<figure> <figure>
<img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy"> <img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy">
{% set legend = article.show_image_titles ? img.title : '' %} {% set legend = article.show_image_titles and img.title ? img.title : img.caption %}
{% if legend %} {% if legend %}
<figcaption>{{ legend }}</figcaption> <figcaption>{{ legend }}</figcaption>
{% endif %} {% endif %}
@@ -67,7 +67,7 @@
{% for img in landscape_images %} {% for img in landscape_images %}
<figure> <figure>
<img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy"> <img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy">
{% set legend = article.show_image_titles ? img.title : '' %} {% set legend = article.show_image_titles and img.title ? img.title : img.caption %}
{% if legend %} {% if legend %}
<figcaption>{{ legend }}</figcaption> <figcaption>{{ legend }}</figcaption>
{% endif %} {% endif %}
@@ -93,7 +93,7 @@
<div class="swiper-slide"> <div class="swiper-slide">
<figure class="sidebar-portrait"> <figure class="sidebar-portrait">
<img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy"> <img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy">
{% set legend = article.show_image_titles ? img.title : '' %} {% set legend = article.show_image_titles and img.title ? img.title : img.caption %}
{% if legend %} {% if legend %}
<figcaption>{{ legend }}</figcaption> <figcaption>{{ legend }}</figcaption>
{% endif %} {% endif %}
@@ -107,7 +107,7 @@
{% else %} {% else %}
<figure class="sidebar-portrait"> <figure class="sidebar-portrait">
<img src="{{ portrait_images[0].url }}" alt="{{ portrait_images[0].alt }}" loading="lazy"> <img src="{{ portrait_images[0].url }}" alt="{{ portrait_images[0].alt }}" loading="lazy">
{% set legend = article.show_image_titles ? portrait_images[0].title : '' %} {% set legend = article.show_image_titles and portrait_images[0].title ? portrait_images[0].title : portrait_images[0].caption %}
{% if legend %} {% if legend %}
<figcaption>{{ legend }}</figcaption> <figcaption>{{ legend }}</figcaption>
{% endif %} {% endif %}
@@ -353,7 +353,7 @@
{% for img in s.images %} {% for img in s.images %}
<figure> <figure>
<img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy"> <img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy">
{% set legend = s.show_image_titles ? img.title : '' %} {% set legend = s.show_image_titles and img.title ? img.title : img.caption %}
{% if legend %} {% if legend %}
<figcaption>{{ legend }}</figcaption> <figcaption>{{ legend }}</figcaption>
{% endif %} {% endif %}
@@ -444,7 +444,7 @@
{% for img in s.images %} {% for img in s.images %}
<figure> <figure>
<img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy"> <img src="{{ img.url }}" alt="{{ img.alt }}" loading="lazy">
{% set legend = s.show_image_titles ? img.title : '' %} {% set legend = s.show_image_titles and img.title ? img.title : img.caption %}
{% if legend %} {% if legend %}
<figcaption>{{ legend }}</figcaption> <figcaption>{{ legend }}</figcaption>
{% endif %} {% endif %}
-16
View File
@@ -79,22 +79,6 @@ check('rôles exclus', thalim_excluded_role_ids(), [600, 598]);
echo "== thalim_get_active_pinned_ids ==\n"; echo "== thalim_get_active_pinned_ids ==\n";
check('catégorie 0 → []', thalim_get_active_pinned_ids(0), []); check('catégorie 0 → []', thalim_get_active_pinned_ids(0), []);
echo "== thalim_pod_tax_sync_diff ==\n";
check('coché : ajout', thalim_pod_tax_sync_diff([], [5], []), ['add' => [5], 'remove' => []]);
check('tout décoché : retrait', thalim_pod_tax_sync_diff([5], [], [5]), ['add' => [], 'remove' => [5]]);
check('décoché partiel', thalim_pod_tax_sync_diff([5, 6], [5], [5, 6]), ['add' => [], 'remove' => [6]]);
check('natif hors champ conservé', thalim_pod_tax_sync_diff([5], [5], [5, 9]), ['add' => [], 'remove' => []]);
check('orphelin sans coche conservé', thalim_pod_tax_sync_diff([], [], [9]), ['add' => [], 'remove' => []]);
check('décoché déjà absent du natif', thalim_pod_tax_sync_diff([5], [], []), ['add' => [], 'remove' => []]);
echo "== thalim_search_text_variants ==\n";
check('texte simple', thalim_search_text_variants('Oulipo'), ['Oulipo']);
check('apostrophe droite', thalim_search_text_variants("l'Oulipo"), ["l'Oulipo", 'l’Oulipo']);
check('apostrophe courbe', thalim_search_text_variants('l’Oulipo'), ["l'Oulipo", 'l’Oulipo']);
check('esperluette', thalim_search_text_variants('a & b'), ['a & b', 'a &amp; b']);
check('guillemets inchangés', thalim_search_text_variants('"punk"'), ['"punk"']);
check('les deux', thalim_search_text_variants("l'a & b"), ["l'a & b", 'l’a & b', "l'a &amp; b", 'l’a &amp; b']);
echo "== thalim_get_seance_parent_id ==\n"; echo "== thalim_get_seance_parent_id ==\n";
global $wpdb; global $wpdb;
$seance_id = (int) $wpdb->get_var( $seance_id = (int) $wpdb->get_var(