fix: prevent empty author names from displaying as 'Unknown'

Enhanced lead author display logic to ensure that an empty string
is not shown as the author's name. Addresses instances where an
empty array element could bypass previous checks, leading to
inaccurate 'Unknown' labels.
This commit is contained in:
Kumi 2024-08-08 21:32:15 +02:00
parent e9857658fc
commit 0a31885c8a
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -1138,7 +1138,7 @@ function custom_article_column($column, $post_id)
{
if ($column == 'lead_author') {
$authors = get_post_meta($post_id, 'article_authors', true);
if (!empty($authors) && is_array($authors)) {
if (!empty($authors) && is_array($authors) && !empty($authors[0])) {
echo esc_html($authors[0]);
} else {
echo __('Unknown', 'duck-behavior-journal');
@ -1165,7 +1165,7 @@ function custom_letter_column($column, $post_id)
{
if ($column == 'lead_author') {
$authors = get_post_meta($post_id, 'article_authors', true);
if (!empty($authors) && is_array($authors)) {
if (!empty($authors) && is_array($authors) && !empty($authors[0])) {
echo esc_html($authors[0]);
} else {
echo __('Unknown', 'duck-behavior-journal');