Add option to display team logos in event list close #87

This commit is contained in:
Brian Miyaji
2014-12-09 18:54:53 +11:00
parent 98db060a5a
commit 3bce7b8595
4 changed files with 58 additions and 28 deletions

View File

@@ -202,9 +202,16 @@
.sp-event-list .data-article a .dashicons { .sp-event-list .data-article a .dashicons {
padding-right: 3px; padding-right: 3px;
} }
.sp-event-list .data-time { .sp-event-list .data-time,
.sp-event-list .data-results {
white-space: nowrap; white-space: nowrap;
} }
.sp-event-list .data-teams img,
.sp-event-list .data-home img,
.sp-event-list .data-away img {
display: inline-block;
vertical-align: middle;
}
/* Event Blocks */ /* Event Blocks */
.sp-event-blocks thead { .sp-event-blocks thead {

View File

@@ -63,6 +63,7 @@ class SP_Meta_Box_Calendar_Data {
?> ?>
</label> </label>
</th> </th>
<?php if ( in_array( $time_format, array( 'combined', 'separate', 'time' ) ) ) { ?>
<th class="column-time"> <th class="column-time">
<label for="sp_columns_time"> <label for="sp_columns_time">
<input type="checkbox" name="sp_columns[]" value="time" id="sp_columns_time" <?php checked( ! is_array( $usecolumns ) || in_array( 'time', $usecolumns ) ); ?>> <input type="checkbox" name="sp_columns[]" value="time" id="sp_columns_time" <?php checked( ! is_array( $usecolumns ) || in_array( 'time', $usecolumns ) ); ?>>
@@ -75,6 +76,7 @@ class SP_Meta_Box_Calendar_Data {
?> ?>
</label> </label>
</th> </th>
<?php } ?>
<?php if ( in_array( $time_format, array( 'separate', 'results' ) ) ) { ?> <?php if ( in_array( $time_format, array( 'separate', 'results' ) ) ) { ?>
<th class="column-results"> <th class="column-results">
<label for="sp_columns_results"> <label for="sp_columns_results">

View File

@@ -174,6 +174,14 @@ class SP_Settings_Events extends SP_Settings_Page {
array( 'title' => __( 'Event List', 'sportspress' ), 'type' => 'title', 'id' => 'event_list_options' ), array( 'title' => __( 'Event List', 'sportspress' ), 'type' => 'title', 'id' => 'event_list_options' ),
array(
'title' => __( 'Teams', 'sportspress' ),
'desc' => __( 'Display logos', 'sportspress' ),
'id' => 'sportspress_event_list_show_logos',
'default' => 'no',
'type' => 'checkbox',
),
array( array(
'title' => __( 'Title Format', 'sportspress' ), 'title' => __( 'Title Format', 'sportspress' ),
'id' => 'sportspress_event_list_title_format', 'id' => 'sportspress_event_list_title_format',

View File

@@ -16,6 +16,7 @@ $defaults = array(
'date_from' => 'default', 'date_from' => 'default',
'date_to' => 'default', 'date_to' => 'default',
'number' => -1, 'number' => -1,
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false, 'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
'link_venues' => get_option( 'sportspress_link_venues', 'yes' ) == 'yes' ? true : false, 'link_venues' => get_option( 'sportspress_link_venues', 'yes' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false, 'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
@@ -93,30 +94,35 @@ if ( $id ) {
switch ( $time_format ) { switch ( $time_format ) {
case 'separate': case 'separate':
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>'; echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>'; echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>';
break; break;
case 'time': case 'time':
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>'; echo '<th class="data-time">' . __( 'Time', 'sportspress' ) . '</th>';
break; break;
case 'results': case 'results':
if ( sp_column_active( $usecolumns, 'results' ) )
echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>'; echo '<th class="data-results">' . __( 'Results', 'sportspress' ) . '</th>';
break; break;
default: default:
if ( sp_column_active( $usecolumns, 'time' ) )
echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>'; echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>';
} }
} }
if ( $usecolumns == null || in_array( 'league', $usecolumns ) ) if ( sp_column_active( $usecolumns, 'league' ) )
echo '<th class="data-league">' . __( 'Competition', 'sportspress' ) . '</th>'; echo '<th class="data-league">' . __( 'Competition', 'sportspress' ) . '</th>';
if ( $usecolumns == null || in_array( 'season', $usecolumns ) ) if ( sp_column_active( $usecolumns, 'season' ) )
echo '<th class="data-season">' . __( 'Season', 'sportspress' ) . '</th>'; echo '<th class="data-season">' . __( 'Season', 'sportspress' ) . '</th>';
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ) if ( sp_column_active( $usecolumns, 'venue' ) )
echo '<th class="data-venue">' . __( 'Venue', 'sportspress' ) . '</th>'; echo '<th class="data-venue">' . __( 'Venue', 'sportspress' ) . '</th>';
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ) if ( sp_column_active( $usecolumns, 'article' ) )
echo '<th class="data-article">' . __( 'Article', 'sportspress' ) . '</th>'; echo '<th class="data-article">' . __( 'Article', 'sportspress' ) . '</th>';
?> ?>
</tr> </tr>
@@ -138,11 +144,18 @@ if ( $id ) {
$teams_output = ''; $teams_output = '';
$teams_array = array(); $teams_array = array();
$team_logos = array();
if ( $teams ): if ( $teams ):
foreach ( $teams as $team ): foreach ( $teams as $team ):
$name = get_the_title( $team ); $name = get_the_title( $team );
if ( $name ): if ( $name ):
if ( $show_team_logo ):
$name = sp_get_logo( $team, 'mini' ) . ' ' . $name;
$team_logos[] = sp_get_logo( $team, 'mini' );
endif;
if ( $link_teams ): if ( $link_teams ):
$team_output = '<a href="' . get_post_permalink( $team ) . '">' . $name . '</a>'; $team_output = '<a href="' . get_post_permalink( $team ) . '">' . $name . '</a>';
else: else:
@@ -207,9 +220,9 @@ if ( $id ) {
default: default:
if ( sp_column_active( $usecolumns, 'event' ) ) { if ( sp_column_active( $usecolumns, 'event' ) ) {
if ( $title_format == 'teams' ) if ( $title_format == 'teams' )
echo '<td class="data-event">' . $teams_output . '</td>'; echo '<td class="data-event data-teams">' . $teams_output . '</td>';
else else
echo '<td class="data-event"><a href="' . get_permalink( $event->ID ) . '">' . $event->post_title . '</a></td>'; echo '<td class="data-event"><a href="' . get_permalink( $event->ID ) . '">' . implode( ' ', $team_logos ) . ' ' . $event->post_title . '</a></td>';
} }
switch ( $time_format ) { switch ( $time_format ) {
@@ -260,7 +273,7 @@ if ( $id ) {
} }
} }
if ( $usecolumns == null || in_array( 'league', $usecolumns ) ): if ( sp_column_active( $usecolumns, 'league' ) ):
echo '<td class="data-league">'; echo '<td class="data-league">';
$leagues = get_the_terms( $event->ID, 'sp_league' ); $leagues = get_the_terms( $event->ID, 'sp_league' );
if ( $leagues ): foreach ( $leagues as $league ): if ( $leagues ): foreach ( $leagues as $league ):
@@ -269,7 +282,7 @@ if ( $id ) {
echo '</td>'; echo '</td>';
endif; endif;
if ( $usecolumns == null || in_array( 'season', $usecolumns ) ): if ( sp_column_active( $usecolumns, 'season' ) ):
echo '<td class="data-season">'; echo '<td class="data-season">';
$seasons = get_the_terms( $event->ID, 'sp_season' ); $seasons = get_the_terms( $event->ID, 'sp_season' );
if ( $seasons ): foreach ( $seasons as $season ): if ( $seasons ): foreach ( $seasons as $season ):
@@ -278,7 +291,7 @@ if ( $id ) {
echo '</td>'; echo '</td>';
endif; endif;
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ): if ( sp_column_active( $usecolumns, 'venue' ) ):
echo '<td class="data-venue">'; echo '<td class="data-venue">';
if ( $link_venues ): if ( $link_venues ):
the_terms( $event->ID, 'sp_venue' ); the_terms( $event->ID, 'sp_venue' );
@@ -291,7 +304,7 @@ if ( $id ) {
echo '</td>'; echo '</td>';
endif; endif;
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ): if ( sp_column_active( $usecolumns, 'article' ) ):
echo '<td class="data-article"> echo '<td class="data-article">
<a href="' . get_permalink( $event->ID ) . '">'; <a href="' . get_permalink( $event->ID ) . '">';