From 93d4b0c223cbd2f5fc67cc73795f19354cb36095 Mon Sep 17 00:00:00 2001 From: scribu Date: Thu, 16 Sep 2010 20:07:39 +0000 Subject: [PATCH] Add default display_rows() and single_row() methods to WP_List_Table. See #14579 git-svn-id: http://svn.automattic.com/wordpress/trunk@15622 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/list-table.php | 48 +++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/list-table.php b/wp-admin/includes/list-table.php index 7551686d43..8a7a728d84 100644 --- a/wp-admin/includes/list-table.php +++ b/wp-admin/includes/list-table.php @@ -698,7 +698,53 @@ class WP_List_Table { * @access protected */ function display_rows() { - die( 'function WP_List_Table::display_rows() must be over-ridden in a sub-class.' ); + foreach ( $this->items as $item ) + $this->single_row( $item ); + } + + /** + * Generates content for a single row of the table + * + * @since 3.1.0 + * @access protected + * + * @param $object $item The current item + */ + function single_row( $item ) { + static $row_class = ''; + $row_class = ( $row_class == '' ? ' class="alternate"' : '' ); + + echo ''; + + list( $columns, $hidden ) = $this->get_column_headers(); + + foreach ( $columns as $column_name => $column_display_name ) { + $class = "class=\"$column_name column-$column_name\""; + + $style = ''; + if ( in_array( $column_name, $hidden ) ) + $style = ' style="display:none;"'; + + $attributes = "$class$style"; + + if ( 'cb' == $column_name ) { + echo ''; + echo $this->column_cb( $item ); + echo ''; + } + elseif ( method_exists( $this, 'column_' . $column_name ) ) { + echo ""; + echo call_user_func( array( $this, 'column_' . $column_name ), $item ); + echo ""; + } + else { + echo ""; + echo $this->column_default( $item, $column_name ); + echo ""; + } + } + + echo ''; } /**