Hide empty positions in player lists and galleries
This commit is contained in:
@@ -126,13 +126,11 @@ echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
|
|||||||
foreach ( $groups as $group ):
|
foreach ( $groups as $group ):
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
echo '<div class="sp-template sp-template-player-gallery sp-template-gallery">';
|
$gallery = '';
|
||||||
|
|
||||||
echo '<div class="sp-player-gallery-wrapper">';
|
|
||||||
|
|
||||||
if ( ! empty( $group->name ) ):
|
if ( ! empty( $group->name ) ):
|
||||||
echo '<a name="group-' . $group->slug . '" id="group-' . $group->slug . '"></a>';
|
$gallery .= '<a name="group-' . $group->slug . '" id="group-' . $group->slug . '"></a>';
|
||||||
echo '<' . $grouptag . ' class="player-group-name player-gallery-group-name">' . $group->name . '</' . $grouptag . '>';
|
$gallery .= '<' . $grouptag . ' class="player-group-name player-gallery-group-name">' . $group->name . '</' . $grouptag . '>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach( $data as $player_id => $performance ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ):
|
foreach( $data as $player_id => $performance ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ):
|
||||||
@@ -142,6 +140,8 @@ echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
|
|||||||
$caption = get_the_title( $player_id );
|
$caption = get_the_title( $player_id );
|
||||||
$caption = trim( $caption );
|
$caption = trim( $caption );
|
||||||
|
|
||||||
|
ob_start();
|
||||||
|
|
||||||
sp_get_template( 'player-gallery-thumbnail.php', array(
|
sp_get_template( 'player-gallery-thumbnail.php', array(
|
||||||
'id' => $player_id,
|
'id' => $player_id,
|
||||||
'itemtag' => $itemtag,
|
'itemtag' => $itemtag,
|
||||||
@@ -152,12 +152,22 @@ echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
|
|||||||
'link_posts' => $link_posts,
|
'link_posts' => $link_posts,
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
$gallery .= ob_get_clean();
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
endif; endforeach;
|
endif; endforeach;
|
||||||
|
|
||||||
$j++;
|
$j++;
|
||||||
|
|
||||||
|
if ( $i === 0 ) continue;
|
||||||
|
|
||||||
|
echo '<div class="sp-template sp-template-player-gallery sp-template-gallery">';
|
||||||
|
|
||||||
|
echo '<div class="sp-player-gallery-wrapper">';
|
||||||
|
|
||||||
|
echo $gallery;
|
||||||
|
|
||||||
if ( ! $html5 && $columns > 0 && ++$i % $columns == 0 ) {
|
if ( ! $html5 && $columns > 0 && ++$i % $columns == 0 ) {
|
||||||
echo '<br style="clear: both" />';
|
echo '<br style="clear: both" />';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,37 +98,13 @@ else:
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach ( $groups as $group ):
|
foreach ( $groups as $group ):
|
||||||
|
|
||||||
$output .= '<div class="sp-template sp-template-player-list">';
|
|
||||||
|
|
||||||
if ( ! empty( $group->name ) ):
|
|
||||||
$output .= '<a name="group-' . $group->slug . '" id="group-' . $group->slug . '"></a>';
|
|
||||||
$output .= '<' . $grouptag . ' class="sp-table-caption player-group-name player-list-group-name">' . $group->name . '</' . $grouptag . '>';
|
|
||||||
endif;
|
|
||||||
|
|
||||||
$output .= '<div class="sp-table-wrapper">' .
|
|
||||||
'<table class="sp-player-list sp-data-table' . ( $sortable ? ' sp-sortable-table' : '' ) . ( $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>';
|
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
if ( intval( $number ) > 0 )
|
if ( intval( $number ) > 0 )
|
||||||
$limit = $number;
|
$limit = $number;
|
||||||
|
|
||||||
|
$tbody = '';
|
||||||
|
|
||||||
foreach( $data as $player_id => $row ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ):
|
foreach( $data as $player_id => $row ): if ( empty( $group->term_id ) || has_term( $group->term_id, 'sp_position', $player_id ) ):
|
||||||
|
|
||||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||||
@@ -136,14 +112,14 @@ foreach ( $groups as $group ):
|
|||||||
$name = sp_array_value( $row, 'name', null );
|
$name = sp_array_value( $row, 'name', null );
|
||||||
if ( ! $name ) continue;
|
if ( ! $name ) continue;
|
||||||
|
|
||||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
$tbody .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||||
|
|
||||||
// Rank or number
|
// Rank or number
|
||||||
if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ):
|
if ( ! is_array( $labels ) || array_key_exists( 'number', $labels ) ):
|
||||||
if ( isset( $orderby ) && $orderby != 'number' ):
|
if ( isset( $orderby ) && $orderby != 'number' ):
|
||||||
$output .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
$tbody .= '<td class="data-rank">' . ( $i + 1 ) . '</td>';
|
||||||
else:
|
else:
|
||||||
$output .= '<td class="data-number">' . sp_array_value( $row, 'number', ' ' ) . '</td>';
|
$tbody .= '<td class="data-number">' . sp_array_value( $row, 'number', ' ' ) . '</td>';
|
||||||
endif;
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
@@ -173,7 +149,7 @@ foreach ( $groups as $group ):
|
|||||||
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
$name = '<a href="' . $permalink . '">' . $name . '</a>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$output .= '<td class="data-name' . $name_class . '">' . $name . '</td>';
|
$tbody .= '<td class="data-name' . $name_class . '">' . $name . '</td>';
|
||||||
|
|
||||||
if ( array_key_exists( 'team', $labels ) ):
|
if ( array_key_exists( 'team', $labels ) ):
|
||||||
$team = sp_array_value( $row, 'team', get_post_meta( $id, 'sp_team', true ) );
|
$team = sp_array_value( $row, 'team', get_post_meta( $id, 'sp_team', true ) );
|
||||||
@@ -181,7 +157,7 @@ foreach ( $groups as $group ):
|
|||||||
if ( $link_teams && false !== get_post_status( $team ) ):
|
if ( $link_teams && false !== get_post_status( $team ) ):
|
||||||
$team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
$team_name = '<a href="' . get_post_permalink( $team ) . '">' . $team_name . '</a>';
|
||||||
endif;
|
endif;
|
||||||
$output .= '<td class="data-team">' . $team_name . '</td>';
|
$tbody .= '<td class="data-team">' . $team_name . '</td>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( array_key_exists( 'position', $labels ) ):
|
if ( array_key_exists( 'position', $labels ) ):
|
||||||
@@ -192,22 +168,51 @@ foreach ( $groups as $group ):
|
|||||||
$position_term = get_term_by( 'id', $position, 'sp_position', ARRAY_A );
|
$position_term = get_term_by( 'id', $position, 'sp_position', ARRAY_A );
|
||||||
$positions = sp_array_value( $position_term, 'name', '—' );
|
$positions = sp_array_value( $position_term, 'name', '—' );
|
||||||
endif;
|
endif;
|
||||||
$output .= '<td class="data-position">' . $positions . '</td>';
|
$tbody .= '<td class="data-position">' . $positions . '</td>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
foreach( $labels as $key => $value ):
|
foreach( $labels as $key => $value ):
|
||||||
if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) )
|
if ( in_array( $key, array( 'number', 'name', 'team', 'position' ) ) )
|
||||||
continue;
|
continue;
|
||||||
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
|
if ( ! is_array( $columns ) || in_array( $key, $columns ) )
|
||||||
$output .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '—' ) . '</td>';
|
$tbody .= '<td class="data-' . $key . '">' . sp_array_value( $row, $key, '—' ) . '</td>';
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
$output .= '</tr>';
|
$tbody .= '</tr>';
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
endif; endforeach;
|
endif; endforeach;
|
||||||
|
|
||||||
|
if ( $i === 0 ) continue;
|
||||||
|
|
||||||
|
$output .= '<div class="sp-template sp-template-player-list">';
|
||||||
|
|
||||||
|
if ( ! empty( $group->name ) ):
|
||||||
|
$output .= '<a name="group-' . $group->slug . '" id="group-' . $group->slug . '"></a>';
|
||||||
|
$output .= '<' . $grouptag . ' class="sp-table-caption player-group-name player-list-group-name">' . $group->name . '</' . $grouptag . '>';
|
||||||
|
endif;
|
||||||
|
|
||||||
|
$output .= '<div class="sp-table-wrapper">' .
|
||||||
|
'<table class="sp-player-list sp-data-table' . ( $sortable ? ' sp-sortable-table' : '' ) . ( $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>';
|
||||||
|
|
||||||
|
$output .= $tbody;
|
||||||
|
|
||||||
$output .= '</tbody>' . '</table>' . '</div>';
|
$output .= '</tbody>' . '</table>' . '</div>';
|
||||||
|
|
||||||
if ( $show_all_players_link ):
|
if ( $show_all_players_link ):
|
||||||
|
|||||||
Reference in New Issue
Block a user