[wp-trac] [WordPress Trac] #43844: Inline documentation for WP_List_Table::get_sortable_columns is wrong

WordPress Trac noreply at wordpress.org
Tue Apr 24 12:50:14 UTC 2018


#43844: Inline documentation for WP_List_Table::get_sortable_columns is wrong
----------------------------------+-----------------------------
 Reporter:  javorszky             |      Owner:  (none)
     Type:  defect (bug)          |     Status:  new
 Priority:  normal                |  Milestone:  Awaiting Review
Component:  Administration        |    Version:
 Severity:  minor                 |   Keywords:
  Focuses:  docs, administration  |
----------------------------------+-----------------------------
 The inline docs for the method as of 24th April, 2018:

 {{{#!php
         /**
          * Get a list of sortable columns. The format is:
          * 'internal-name' => 'orderby'
          * or
          * 'internal-name' => array( 'orderby', true )
          *
          * The second format will make the initial sorting order be
 descending
          *
          * @since 3.1.0
          *
          * @return array
          */
         protected function get_sortable_columns() {
                 return array();
         }
 }}}

 See https://github.com/WordPress/WordPress/blob/master/wp-admin/includes
 /class-wp-list-table.php

 The problem is that if I define the sortable columns as the first one,
 with

 {{{#!php
 class My_List_Table extends WP_List_Table {

     protected function get_sortable_columns() {
         return array(
             'my-column' => 'my-column',
         );
     }
 }
 }}}

 Then the `list` call when building the table list header / footer will not
 have the `orderby` variable defined. See
 https://github.com/WordPress/WordPress/blob/master/wp-admin/includes
 /class-wp-list-table.php#L1117

 If however I use

 {{{#!php
 class My_List_Table extends WP_List_Table {

     protected function get_sortable_columns() {
         return array(
             'my-column' => array( 'my-column' ),
         );
     }
 }
 }}}

 everything works as expected.

 Diff incoming shortly.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43844>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list