I am building a custom WordPress plugin where I create a custom list table for entities in a custom database table, extending the WP_List_Table class.
Everything works as expected but I want to style each row based on the value of a specific column of the row that is returned from the DB.
The iteration of the columns for each row happens inside the column_default() function:
/**
* Render a column when no column specific method exists.
*
* @param array $item
* @param string $column_name
*
* @return mixed
*/
public function column_default( $item, $column_name ) {
switch ( $column_name ) {
case 'id':
return $item[$column_name];
default:
return $item[$column_name];
}
}
For example:
If the viw_status column of the current item that is printed on the list table equals 1 ($item['viw_status '] == 1)
, the current item’s row must have green background color otherwise grey something.
Is there a any way to apply a custom css class to a row based on the values of its columns?