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
This commit is contained in:
scribu 2010-09-16 20:07:39 +00:00
parent 91ab066e89
commit 93d4b0c223
1 changed files with 47 additions and 1 deletions

View File

@ -698,7 +698,53 @@ class WP_List_Table {
* @access protected * @access protected
*/ */
function display_rows() { 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 '<tr' . $row_class . '>';
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 '<th scope="row" class="check-column">';
echo $this->column_cb( $item );
echo '</th>';
}
elseif ( method_exists( $this, 'column_' . $column_name ) ) {
echo "<td $attributes>";
echo call_user_func( array( $this, 'column_' . $column_name ), $item );
echo "</td>";
}
else {
echo "<td $attributes>";
echo $this->column_default( $item, $column_name );
echo "</td>";
}
}
echo '</tr>';
} }
/** /**