Make WordPress Core

Changeset 33104


Ignore:
Timestamp:
07/07/2015 03:11:54 PM (11 years ago)
Author:
helen
Message:

List tables: Add a fallback for the primary column.

Without a primary column defined, nothing shows in the responsive view at all, which is bad.

props mordauk.
see #25408.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r33016 r33104  
    833833         */
    834834        protected function get_default_primary_column_name() {
    835                 return '';
     835                $columns = $this->get_columns();
     836                $column = '';
     837
     838                // We need a primary defined so responsive views show something,
     839                // so let's fall back to the first non-checkbox column.
     840                foreach( $columns as $col => $column_name ) {
     841                        if ( 'cb' === $col ) {
     842                                continue;
     843                        }
     844
     845                        $column = $col;
     846                        break;
     847                }
     848
     849                return $column;
    836850        }
    837851
    … …  
    879893                        // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
    880894                        // In 4.3, we added a fourth argument for primary column.
    881                         $column_headers = array( array(), array(), array(), '' );
     895                        $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
    882896                        foreach ( $this->_column_headers as $key => $value ) {
    883897                                $column_headers[ $key ] = $value;
Note: See TracChangeset for help on using the changeset viewer.