get_settings(); if ( empty( $settings['show_byline'] ) ) { return []; } $post_id = get_queried_object_id(); if ( ! $post_id ) { return []; } return array_values( array_filter( array_map( static fn( $c ) => (string) ( $c->display_name ?? '' ), $db->get_coauthors_for_post( (int) $post_id ) ) ) ); } /** * Thèmes classiques : « aaa aaa » devient « aaa aaa, bbb bbb ». */ public function enrichir_nom_auteur( $nom ) { $noms = $this->noms_coauteurs(); if ( empty( $noms ) || ! is_string( $nom ) || '' === $nom ) { return $nom; } $this->affiche_en_tete = true; return $nom . ', ' . implode( ', ', $noms ); } /** * Thèmes de blocs (FSE) : le nom de l'auteur passe par `core/post-author-name`, que * `the_author` ne traverse pas. On ajoute les co-auteurs dans le rendu du bloc. */ public function enrichir_bloc_auteur( $html, $bloc ) { $nom_bloc = is_array( $bloc ) ? ( $bloc['blockName'] ?? '' ) : ''; if ( 'core/post-author-name' !== $nom_bloc && 'core/post-author' !== $nom_bloc ) { return $html; } $noms = $this->noms_coauteurs(); if ( empty( $noms ) || ! is_string( $html ) || '' === trim( $html ) ) { return $html; } $this->affiche_en_tete = true; $ajout = '' . esc_html( ', ' . implode( ', ', $noms ) ) . ''; /* on insère AVANT la dernière balise fermante du bloc, pour rester dans son conteneur * (et donc hériter de sa typographie) plutôt que de coller du texte à côté. */ $pos = strrpos( $html, 'affiche_en_tete ) { return $content; } if ( ! class_exists( 'Aiforya_Multi_Author_Db' ) ) { return $content; } $db = Aiforya_Multi_Author_Db::get_instance(); $settings = $db->get_settings(); if ( empty( $settings['show_byline'] ) ) { return $content; } $post_id = get_the_ID(); $coauthors = $db->get_coauthors_for_post( (int) $post_id ); if ( empty( $coauthors ) ) { return $content; } $names = array_filter( array_map( static fn( $c ) => (string) ( $c->display_name ?? '' ), $coauthors ) ); if ( empty( $names ) ) { return $content; } /* * ⛔ LA LIGNE N'AFFICHAIT QUE LES CO-AUTEURS — corrigé le 17/08/2026, relevé par Greg. * * Le réglage qui la commande s'intitule « Show the byline (author and co-authors) on * posts », et son aide précise « the byline shows the MAIN AUTHOR and the co-authors ». * Le rendu, lui, écrivait « With contributions from: » : l'auteur * principal en était absent. Le code marchait ; c'est la PROMESSE qu'il ne tenait pas. * * ⚠ On ne l'affiche toujours QUE s'il y a au moins un co-auteur : sans co-auteur, la * ligne ferait doublon avec le byline du thème (« Written by … »), qui est déjà là. */ $auteur = get_the_author_meta( 'display_name' ); $byline = '

'; if ( '' !== (string) $auteur ) { $byline .= esc_html( sprintf( /* translators: 1: main author, 2: comma-separated co-authors. */ __( 'By %1$s, with %2$s', 'aiforya-multi-author' ), (string) $auteur, implode( ', ', $names ) ) ); } else { $byline .= esc_html( sprintf( /* translators: %s: comma-separated co-authors. */ __( 'With contributions from: %s', 'aiforya-multi-author' ), implode( ', ', $names ) ) ); } $byline .= '

'; return $content . $byline; } }