Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #62913


Ignore:
Timestamp:
02/06/2025 05:09:37 PM (2 months ago)
Author:
sabernhardt
Comment:

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:

  1. around printf() function in media list tables
  2. 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">&#8212;</span><span class="screen-reader-text">' . __( '(no author)' ) . '</span>';
		}
	}

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #62913

    • Property Keywords needs-patch added
    • Property Focuses accessibility administration added
    • Property Component changed from Upload to Administration
    • Property Summary changed from "a" without text in uploads to Prevent empty author links in list tables
  • Ticket #62913 – Description

    initial v1  
    1 /wp-admin/upload.php?mode=list
     1`/wp-admin/upload.php?mode=list`
    22
    33In some cases when there is no image author for whatever reason (unrelated), there is an empty "a" element, which causes unexpected behavior in e.g. keyboard navigation or for accessibility tools