WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 3 months ago

#49962 new enhancement

Remove hardcoded strong definition from title (admin) column

Reported by: Beee Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: 2nd-opinion
Focuses: css, administration Cc:

Description

Reason for ticket
In wp-admin/includes/class-wp-posts-list-table.php on line 1013 and 1039 there are 2 hardcoded strong definitions.

What happened?
When I decided to change the default column with the filter list_table_primary_column, I noticed the title was still bolded, which I didn't want.

-=-

When I looked at the source code I saw a hardcoded definition, hence why I made a dynamic suggestion to fix this.

  • remove strong on line 1013
  • remove /strong on line 1039
  • add on line 1018
$column       = apply_filters( 'list_table_primary_column', WP_List_Table::get_default_primary_column_name(), $this->screen->id );
$bolded_class = ( 'title' === $column ) ? 'bolded-class' : false;
  • change printf statement to
    printf(
    	'<a class="row-title%s" href="%s" aria-label="%s">%s%s</a>',
             $bolded_class,
    	get_edit_post_link( $post->ID ),
    	/* translators: %s: Post title. */
    	esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $title ) ),
    	$pad,
    	$title
    );
    
  • add after $label, originally on line 1201
    $default_column = WP_List_Table::get_default_primary_column_name();
    $bolded_class   = ( $column_name === $default_column ) ? 'bolded-class' : false;
    
  • change $term_links, originally on line 1203
    $term_links[]   = $this->get_edit_link( $posts_in_term_qv, $label );
    
  • To
    $term_links[]   = $this->get_edit_link( $posts_in_term_qv, $label, $bolded_class );
    
  • add to css (don’t know which file)
    .bolded-class {
        font-weight: strong;
    }
    

Any feedback is welcome.

Something similar is happening on

  • line 420 in class-wp-terms-list-table.php
  • line 192 in class-wp-links-list-table.php

but I didn't look into that yet.

Change History (1)

This ticket was mentioned in PR #245 on WordPress/wordpress-develop by Beee4life.


3 months ago

There is a hardcoded strong definition to 'bold' the title column in posts list table.

If you use the filter to define another column as default, the bolding stays on the title, why that might not be what you want (like in my case).

With my change the hardcoded strong definition is removed from the title column and dynamically added.

Trac ticket: https://core.trac.wordpress.org/ticket/49962

Note: See TracTickets for help on using tickets.