Add icons module

This commit is contained in:
Brian Miyaji
2015-09-17 12:33:16 +10:00
parent 98990c0995
commit d0e77dcb4d
16 changed files with 404 additions and 123 deletions

View File

@@ -32,9 +32,11 @@ if ( $teams ):
if ( ! has_post_thumbnail( $team ) ) continue;
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon' );
$alt = sizeof( $teams ) == 2 && $i % 2;
// Add team name
if ( $show_team_names ) {
if ( $i % 2 ) {
if ( $alt ) {
$logo .= ' <strong class="sp-team-name">' . get_the_title( $team ) . '</strong>';
} else {
$logo = '<strong class="sp-team-name">' . get_the_title( $team ) . '</strong> ' . $logo;
@@ -46,7 +48,7 @@ if ( $teams ):
// Add result
if ( $show_results ) {
if ( $i % 2 ) {
if ( $alt ) {
$logo = '<strong class="sp-team-result">' . array_shift( $results ) . '</strong> ' . $logo;
} else {
$logo .= ' <strong class="sp-team-result">' . array_shift( $results ) . '</strong>';
@@ -58,7 +60,7 @@ if ( $teams ):
endforeach;
$team_logos = array_filter( $team_logos );
if ( ! empty( $team_logos ) ):
echo '<div class="sp-template sp-template-event-logos"><div class="sp-event-logos">';
echo '<div class="sp-template sp-template-event-logos"><div class="sp-event-logos sp-event-logos-' . sizeof( $teams ) . '">';
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
echo implode( ' ' . $delimiter . ' ', $team_logos );
echo '</div></div>';

View File

@@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Initialize totals
$totals = array();
?>
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?>">
<div class="sp-template sp-template-event-performance sp-template-event-performance-combined sp-template-event-performance-<?php echo $mode; ?>">
<?php if ( $caption ): ?>
<h4 class="sp-table-caption"><?php echo $caption; ?></h4>
<?php endif; ?>
@@ -94,9 +94,11 @@ $totals = array();
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
$icons = '';
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
endif;
endforeach;
@@ -142,9 +144,11 @@ $totals = array();
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
$icons = '';
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
endif;
endforeach;

View File

@@ -11,8 +11,12 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
// Initialize totals
$totals = array();
// Set null
if ( ! isset( $position ) ) $position = null;
if ( ! isset( $class ) ) $class = null;
?>
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?>">
<div class="sp-template sp-template-event-performance sp-template-event-performance-<?php echo $mode; ?><?php if ( isset( $class ) ) { echo ' ' . $class; } ?>">
<?php if ( $caption ): ?>
<h4 class="sp-table-caption"><?php echo $caption; ?></h4>
<?php endif; ?>
@@ -54,6 +58,8 @@ $totals = array();
$lineup_sub_relation[ sp_array_value( $sub, 'sub', 0 ) ] = $sub_id;
endforeach;
$data = apply_filters( 'sportspress_event_performance_players', $data, $lineups, $subs );
$i = 0;
foreach ( $data as $player_id => $row ):
@@ -131,9 +137,11 @@ $totals = array();
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
$icons = '';
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
endif;
endforeach;
@@ -147,111 +155,62 @@ $totals = array();
?>
</tbody>
<?php endif; ?>
<?php if ( $show_total || $show_extras ): ?>
<?php if ( $show_total ): ?>
<<?php echo ( $show_players ? 'tfoot' : 'tbody' ); ?>>
<?php
if ( $show_extras ) {
$row = sp_array_value( $data, -1, array() );
$row = array_filter( $row );
$row = array_intersect_key( $row, $labels );
if ( ! empty( $row ) ) {
?>
<tr class="sp-extras-row <?php echo ( $i % 2 == 0 ? 'odd' : 'even' ); ?>">
<?php
if ( $show_players ):
if ( $show_numbers ) {
echo '<td class="data-number">&nbsp;</td>';
}
echo '<td class="data-name">' . __( 'Extras', 'sportspress' ) . '</td>';
endif;
do_action( 'sportspress_event_performance_table_footer', $data, $labels, $position, $performance_ids );
if ( ! $primary || sizeof( array_intersect_key( $totals, array_flip( (array) $primary ) ) ) ) {
?>
<tr class="sp-total-row <?php echo ( $i % 2 == 0 ? 'odd' : 'even' ); ?>">
<?php
if ( $show_players ):
if ( $show_numbers ) {
echo '<td class="data-number">&nbsp;</td>';
}
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
endif;
$row = sp_array_value( $data, -1, array() );
$row = sp_array_value( $data, 0, array() );
if ( $mode == 'icons' ) echo '<td class="sp-performance-icons">';
if ( $mode == 'icons' ) echo '<td class="sp-performance-icons">';
foreach ( $labels as $key => $label ):
if ( 'name' == $key )
continue;
if ( isset( $position ) && 'position' == $key )
continue;
if ( $key == 'position' ):
foreach ( $labels as $key => $label ):
if ( 'name' == $key )
continue;
if ( isset( $position ) && 'position' == $key )
continue;
if ( $key == 'position' ):
$value = '&nbsp;';
else:
if ( $primary && $key !== $primary ):
$value = '&nbsp;';
elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = '&nbsp;';
$value = apply_filters( 'sportspress_event_performance_table_total_value', sp_array_value( $totals, $key, 0 ), $data, $key );
endif;
if ( $mode == 'values' ):
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
endif;
endforeach;
if ( $mode == 'icons' ) echo '</td>';
?>
</tr>
<?php
$i++;
}
}
if ( $show_total ) {
if ( ! $primary || sizeof( array_intersect_key( $totals, array_flip( (array) $primary ) ) ) ) {
?>
<tr class="sp-total-row <?php echo ( $i % 2 == 0 ? 'odd' : 'even' ); ?>">
<?php
if ( $show_players ):
if ( $show_numbers ) {
echo '<td class="data-number">&nbsp;</td>';
}
echo '<td class="data-name">' . __( 'Total', 'sportspress' ) . '</td>';
endif;
$row = sp_array_value( $data, 0, array() );
if ( $mode == 'icons' ) echo '<td class="sp-performance-icons">';
foreach ( $labels as $key => $label ):
if ( 'name' == $key )
continue;
if ( isset( $position ) && 'position' == $key )
continue;
if ( $key == 'position' ):
$value = '&nbsp;';
else:
if ( $primary && $key !== $primary ):
$value = '&nbsp;';
elseif ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
$value = $row[ $key ];
else:
$value = sp_array_value( $totals, $key, 0 );
if ( $show_extras ) {
$value += sp_array_value( sp_array_value( $data, -1, array() ), $key, 0 );
}
endif;
if ( $mode == 'values' ):
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
$icons = '';
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
$icons = str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
echo apply_filters( 'sportspress_event_performance_icons', $icons, $performance_id, $value );
endif;
endforeach;
if ( $mode == 'values' ):
echo '<td class="data-' . $key . '">' . $value . '</td>';
elseif ( intval( $value ) && $mode == 'icons' ):
$performance_id = sp_array_value( $performance_ids, $key, null );
if ( $performance_id && has_post_thumbnail( $performance_id ) ):
echo str_repeat( get_the_post_thumbnail( $performance_id, 'sportspress-fit-mini' ) . ' ', $value );
endif;
endif;
endforeach;
if ( $mode == 'icons' ) echo '</td>';
?>
</tr>
<?php } ?>
if ( $mode == 'icons' ) echo '</td>';
?>
</tr>
<?php } ?>
</<?php echo ( $show_players ? 'tfoot' : 'tbody' ); ?>>
<?php endif; ?>
</table>
</div>
</div>
</div>
<?php do_action( 'sportspress_after_event_performance_table', $data, $lineups, $subs, $class ); ?>

View File

@@ -11,16 +11,15 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$show_players = get_option( 'sportspress_event_show_players', 'yes' ) === 'yes' ? true : false;
$show_staff = get_option( 'sportspress_event_show_staff', 'yes' ) === 'yes' ? true : false;
$show_extras = get_option( 'sportspress_event_show_extras', 'no' ) === 'yes' ? true : false;
$show_total = get_option( 'sportspress_event_show_total', 'yes' ) === 'yes' ? true : false;
$show_numbers = get_option( 'sportspress_event_show_player_numbers', 'yes' ) === 'yes' ? true : false;
$split_positions = get_option( 'sportspress_event_split_players_by_position', 'no' ) === 'yes' ? true : false;
$split_teams = get_option( 'sportspress_event_split_players_by_team', 'yes' ) === 'yes' ? true : false;
$reverse_teams = get_option( 'sportspress_event_performance_reverse_teams', 'no' ) === 'yes' ? true : false;
$primary = get_option( 'sportspress_primary_performance', null );
$primary = sp_get_main_performance_option();
$total = get_option( 'sportspress_event_total_performance', 'all');
if ( ! $show_players && ! $show_staff && ! $show_extras && ! $show_total ) return;
if ( ! $show_players && ! $show_staff && ! $show_total ) return;
if ( ! isset( $id ) )
$id = get_the_ID();
@@ -72,9 +71,7 @@ if ( is_array( $teams ) ):
$players = sp_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $index );
$has_players = sizeof( $players ) > 1;
if ( $show_extras ) {
$players[] = -1;
}
$players = apply_filters( 'sportspress_event_performance_split_team_players', $players );
$show_team_players = $show_players && $has_players;
@@ -91,9 +88,9 @@ if ( is_array( $teams ) ):
$data = sp_array_value( array_values( $performance ), $index );
}
if ( ! $show_team_players && ! $show_staff && ! $show_extras && ! $show_total ) continue;
if ( ! $show_team_players && ! $show_staff && ! $show_total ) continue;
if ( $show_team_players || $show_extras || $show_total ) {
if ( $show_team_players || $show_total ) {
if ( $split_positions ) {
$positions = get_terms( 'sp_position', array(
'orderby' => 'slug',
@@ -138,9 +135,7 @@ if ( is_array( $teams ) ):
}
if ( sizeof( $subdata ) ) {
if ( $show_extras ) {
$subdata[-1] = sp_array_value( $data, -1 );
}
$subdata = apply_filters( 'sportspress_event_performance_split_team_split_position_subdata', $subdata, $data );
sp_get_template( 'event-performance-table.php', array(
'position' => sp_get_position_caption( $position->term_id ),
@@ -148,7 +143,6 @@ if ( is_array( $teams ) ):
'sortable' => $sortable,
'show_players' => $show_team_players,
'show_numbers' => $show_numbers,
'show_extras' => $show_extras,
'show_total' => $show_total,
'caption' => 0 == $position_index && $team_id ? get_the_title( $team_id ) : null,
'labels' => $sublabels,
@@ -158,6 +152,7 @@ if ( is_array( $teams ) ):
'link_posts' => $link_posts,
'performance_ids' => isset( $performance_ids ) ? $performance_ids : null,
'primary' => 'primary' == $total ? $primary : null,
'class' => 'sp-template-event-performance-team-' . $index . '-position-' . $position_index,
) );
}
}
@@ -167,7 +162,6 @@ if ( is_array( $teams ) ):
'sortable' => $sortable,
'show_players' => $show_team_players,
'show_numbers' => $show_numbers,
'show_extras' => $show_extras,
'show_total' => $show_total,
'caption' => $team_id ? get_the_title( $team_id ) : null,
'labels' => $labels,
@@ -222,7 +216,6 @@ if ( is_array( $teams ) ):
'sortable' => $sortable,
'show_players' => $show_players,
'show_numbers' => $show_numbers,
'show_extras' => $show_extras,
'show_total' => $show_total,
'caption' => sp_get_position_caption( $position->term_id ),
'labels' => $labels,
@@ -241,9 +234,8 @@ if ( is_array( $teams ) ):
'sortable' => $sortable,
'show_players' => $show_players,
'show_numbers' => $show_numbers,
'show_extras' => $show_extras,
'show_total' => $show_total,
'caption' => __( 'Performance', 'sportspress' ),
'caption' => __( 'Box Score', 'sportspress' ),
'labels' => $labels,
'mode' => $mode,
'data' => $data,