I'm curious how an attachment would have no author, but both wp_prepare_attachment_for_js()
and attachment_submitbox_metadata()
have a "(no author)" text string for that possibility.
A quick way to reproduce an empty link in the list table would be to add a filter:
add_filter( 'the_author', '__return_empty_string' );
if ( ! empty( get_the_author() ) ) { }
could wrap the code in column_author()
methods:
- around
printf()
function in media list tables
- around
$args
and the echo
line in general post tables
The methods could also have an else
condition to print "(no author)" instead of an empty cell, either as visible text or by showing an em dash (as it does for posts with no comments or no tags):
public function column_author( $post ) {
if ( ! empty( get_the_author() ) ) {
printf(
'<a href="%s">%s</a>',
esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ),
get_the_author()
);
} else {
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . __( '(no author)' ) . '</span>';
}
}