mirror of
git://develop.git.wordpress.org/
synced 2025-03-24 13:59:48 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60032 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4a12552742
commit
d6e3b8a9e2
@ -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(
|
||||
'<a href="%s">%s</a>',
|
||||
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(
|
||||
'<a href="%s">%s</a>',
|
||||
esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ),
|
||||
esc_html( $author )
|
||||
);
|
||||
} else {
|
||||
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . __( '(no author)' ) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 '<span aria-hidden="true">—</span><span class="screen-reader-text">' . __( '(no author)' ) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user