Merge pull request #290 from ThemeBoy/feature-statistics-icons

Feature statistics icons
This commit is contained in:
Brian Miyaji
2018-08-28 23:35:23 +10:00
committed by GitHub
10 changed files with 159 additions and 28 deletions

View File

@@ -53,7 +53,7 @@ if ( isset( $columns ) && null !== $columns ):
endif;
$data = $list->data();
// The first row should be column labels
// The first row should be labels
$labels = $data[0];
//Create a unique identifier based on the current time in microseconds
@@ -62,7 +62,7 @@ $identifier = uniqid( 'playerlist_' );
if ( true == $responsive ){
//sportspress_responsive_tables_css( $identifier );
}
// Remove the first row to leave us with the actual data
// Remove the first row and 'head' row to leave us with the actual data
unset( $data[0] );
if ( $grouping === null || $grouping === 'default' ):
@@ -122,6 +122,25 @@ foreach ( $groups as $group ):
if ( intval( $number ) > 0 )
$limit = $number;
$thead = '<thead>' . '<tr>';
if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ):
if ( in_array( $orderby, array( 'number', 'name' ) ) ):
$thead .= '<th class="data-number">#</th>';
else:
$thead .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
endif;
endif;
foreach( $labels as $key => $label ):
if ( $key !== 'number' && ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) )
$thead .= '<th class="data-' . $key . '">'. $label . '</th>';
if ( preg_match ( "/title=\"(.*?)\"/", $label, $new_label ) )
$labels[$key] = $label[1];
endforeach;
$thead .= '</tr>' . '</thead>';
$tbody = '';
foreach( $data as $player_id => $row ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ):
@@ -213,22 +232,9 @@ foreach ( $groups as $group ):
endif;
$output .= '<div class="sp-table-wrapper">' .
'<table class="sp-player-list sp-data-table' . ( $sortable ? ' sp-sortable-table' : '' ). ( $responsive ? ' sp-responsive-table '.$identifier : '' ) . ( $scrollable ? ' sp-scrollable-table' : '' ) . ( $paginated ? ' sp-paginated-table' : '' ) . '" data-sp-rows="' . $rows . '">' . '<thead>' . '<tr>';
if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ):
if ( in_array( $orderby, array( 'number', 'name' ) ) ):
$output .= '<th class="data-number">#</th>';
else:
$output .= '<th class="data-rank">' . __( 'Rank', 'sportspress' ) . '</th>';
endif;
endif;
foreach( $labels as $key => $label ):
if ( $key !== 'number' && ( ! is_array( $columns ) || $key == 'name' || in_array( $key, $columns ) ) )
$output .= '<th class="data-' . $key . '">'. $label . '</th>';
endforeach;
$output .= '</tr>' . '</thead>' . '<tbody>';
'<table class="sp-player-list sp-data-table' . ( $sortable ? ' sp-sortable-table' : '' ). ( $responsive ? ' sp-responsive-table '.$identifier : '' ) . ( $scrollable ? ' sp-scrollable-table' : '' ) . ( $paginated ? ' sp-paginated-table' : '' ) . '" data-sp-rows="' . $rows . '">';
$output .= $thead . '<tbody>';
$output .= $tbody;