From 9f51d473ef4d0b71d2fe591b8756b29effff7ec1 Mon Sep 17 00:00:00 2001 From: joedolson Date: Mon, 17 Mar 2025 18:54:27 +0000 Subject: [PATCH] Administration: A11y: Prevent empty author link in list tables. If the author display name is unknown, show an `emdash` and screen reader text `(no author)`, consistent with other cases where information is unknown. Fix an issue where an unknown author name displayed as an invisible link with no text. Props kkmuffme, hdkothari81, shailu25, snehapatil02, sabernhardt, faisal03, rishavdutta, sumitbagthariya16, joedolson. Fixes #62913. Built from https://develop.svn.wordpress.org/trunk@60032 git-svn-id: http://core.svn.wordpress.org/trunk@59368 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-media-list-table.php | 17 ++++++++++++----- wp-admin/includes/class-wp-posts-list-table.php | 17 ++++++++++++----- wp-includes/version.php | 2 +- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/wp-admin/includes/class-wp-media-list-table.php b/wp-admin/includes/class-wp-media-list-table.php index fb0d67d705..b0a421586c 100644 --- a/wp-admin/includes/class-wp-media-list-table.php +++ b/wp-admin/includes/class-wp-media-list-table.php @@ -503,15 +503,22 @@ class WP_Media_List_Table extends WP_List_Table { * Handles the author column output. * * @since 4.3.0 + * @since 6.8.0 Added fallback text when author's name is unknown. * * @param WP_Post $post The current WP_Post object. */ public function column_author( $post ) { - printf( - '%s', - esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ), - get_the_author() - ); + $author = get_the_author(); + + if ( ! empty( $author ) ) { + printf( + '%s', + esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ), + esc_html( $author ) + ); + } else { + echo '' . __( '(no author)' ) . ''; + } } /** diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index aff267b97c..3d25b2f7ff 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -1277,15 +1277,22 @@ class WP_Posts_List_Table extends WP_List_Table { * Handles the post author column output. * * @since 4.3.0 + * @since 6.8.0 Added fallback text when author's name is unknown. * * @param WP_Post $post The current WP_Post object. */ public function column_author( $post ) { - $args = array( - 'post_type' => $post->post_type, - 'author' => get_the_author_meta( 'ID' ), - ); - echo $this->get_edit_link( $args, get_the_author() ); + $author = get_the_author(); + + if ( ! empty( $author ) ) { + $args = array( + 'post_type' => $post->post_type, + 'author' => get_the_author_meta( 'ID' ), + ); + echo $this->get_edit_link( $args, esc_html( $author ) ); + } else { + echo '' . __( '(no author)' ) . ''; + } } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 6c402b5723..01573f078a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-beta2-60031'; +$wp_version = '6.8-beta2-60032'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.