Hide empty positions in player lists and galleries

This commit is contained in:
Brian Miyaji
2016-12-07 17:45:13 +11:00
parent 80b9970627
commit 2f7c215ad9
2 changed files with 54 additions and 39 deletions

View File

@@ -126,13 +126,11 @@ echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
foreach ( $groups as $group ):
$i = 0;
echo '<div class="sp-template sp-template-player-gallery sp-template-gallery">';
echo '<div class="sp-player-gallery-wrapper">';
$gallery = '';
if ( ! empty( $group->name ) ):
echo '<a name="group-' . $group->slug . '" id="group-' . $group->slug . '"></a>';
echo '<' . $grouptag . ' class="player-group-name player-gallery-group-name">' . $group->name . '</' . $grouptag . '>';
$gallery .= '<a name="group-' . $group->slug . '" id="group-' . $group->slug . '"></a>';
$gallery .= '<' . $grouptag . ' class="player-group-name player-gallery-group-name">' . $group->name . '</' . $grouptag . '>';
endif;
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 = trim( $caption );
ob_start();
sp_get_template( 'player-gallery-thumbnail.php', array(
'id' => $player_id,
'itemtag' => $itemtag,
@@ -152,11 +152,21 @@ echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
'link_posts' => $link_posts,
) );
$gallery .= ob_get_clean();
$i++;
endif; endforeach;
$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 ) {
echo '<br style="clear: both" />';