Make WordPress Core


Ignore:
Timestamp:
09/16/2010 08:07:39 PM (16 years ago)
Author:
scribu
Message:

Add default display_rows() and single_row() methods to WP_List_Table. See #14579

File:
1 edited

Legend:

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

    r15578 r15622  
    699699         */
    700700        function display_rows() {
    701                 die( 'function WP_List_Table::display_rows() must be over-ridden in a sub-class.' );
     701                foreach ( $this->items as $item )
     702                        $this->single_row( $item );
     703        }
     704
     705        /**
     706         * Generates content for a single row of the table
     707         *
     708         * @since 3.1.0
     709         * @access protected
     710         *
     711         * @param $object $item The current item
     712         */
     713        function single_row( $item ) {
     714                static $row_class = '';
     715                $row_class = ( $row_class == '' ? ' class="alternate"' : '' );
     716
     717                echo '<tr' . $row_class . '>';
     718
     719                list( $columns, $hidden ) = $this->get_column_headers();
     720
     721                foreach ( $columns as $column_name => $column_display_name ) {
     722                        $class = "class=\"$column_name column-$column_name\"";
     723
     724                        $style = '';
     725                        if ( in_array( $column_name, $hidden ) )
     726                                $style = ' style="display:none;"';
     727
     728                        $attributes = "$class$style";
     729
     730                        if ( 'cb' == $column_name ) {
     731                                echo '<th scope="row" class="check-column">';
     732                                echo $this->column_cb( $item );
     733                                echo '</th>';
     734                        }
     735                        elseif ( method_exists( $this, 'column_' . $column_name ) ) {
     736                                echo "<td $attributes>";
     737                                echo call_user_func( array( $this, 'column_' . $column_name ), $item );
     738                                echo "</td>";
     739                        }
     740                        else {
     741                                echo "<td $attributes>";
     742                                echo $this->column_default( $item, $column_name );
     743                                echo "</td>";
     744                        }
     745                }
     746
     747                echo '</tr>';
    702748        }
    703749
Note: See TracChangeset for help on using the changeset viewer.