Add table heading option to widgets

This commit is contained in:
Brian Miyaji
2015-07-17 15:32:29 +10:00
parent f3c6a6878b
commit f7742a69cd
18 changed files with 162 additions and 53 deletions

View File

@@ -12,6 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$defaults = array(
'team' => null,
'id' => null,
'title' => null,
'live' => get_option( 'sportspress_enable_live_countdowns', 'yes' ) == 'yes' ? true : false,
'link_events' => get_option( 'sportspress_link_events', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
@@ -31,6 +32,9 @@ extract( $defaults, EXTR_SKIP );
if ( ! isset( $post ) ) return;
if ( $title )
echo '<h4 class="sp-table-caption">' . $title . '</h4>';
$title = $post->post_title;
if ( $link_events ) $title = '<a href="' . get_post_permalink( $post->ID, false, true ) . '">' . $title . '</a>';
?>

View File

@@ -13,6 +13,7 @@ $primary_result = get_option( 'sportspress_primary_result', null );
$defaults = array(
'id' => null,
'title' => false,
'status' => 'default',
'date' => 'default',
'date_from' => 'default',
@@ -46,13 +47,16 @@ if ( $order != 'default' )
$data = $calendar->data();
$usecolumns = $calendar->columns;
if ( $show_title && false === $title && $id )
$title = get_the_title( $id );
if ( isset( $columns ) ) {
$usecolumns = $columns;
}
if ( $show_title && $id ) {
echo '<h4 class="sp-table-caption">' . get_the_title( $id ) . '</h4>';
}
if ( $title )
echo '<h4 class="sp-table-caption">' . $title . '</h4>';
?>
<div class="sp-template sp-template-event-blocks">
<div class="sp-table-wrapper">
@@ -71,6 +75,7 @@ if ( $show_title && $id ) {
$results = get_post_meta( $event->ID, 'sp_results', true );
$teams = array_unique( get_post_meta( $event->ID, 'sp_team' ) );
$teams = array_filter( $teams, 'sp_filter_positive' );
$logos = array();
$main_results = array();
@@ -79,7 +84,7 @@ if ( $show_title && $id ) {
$j++;
if ( has_post_thumbnail ( $team ) ):
if ( $link_teams ):
$logo = '<a class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" href="' . get_post_permalink( $team, false, true ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</a>';
$logo = '<a class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" href="' . get_permalink( $team, false, true ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</a>';
else:
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon', array( 'class' => 'team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) ) );
endif;
@@ -106,11 +111,7 @@ if ( $show_title && $id ) {
<td>
<?php echo implode( $logos, ' ' ); ?>
<time class="sp-event-date" datetime="<?php echo $event->post_date; ?>"><?php echo get_the_time( get_option( 'date_format' ), $event ); ?></time>
<?php if ( ! empty( $main_results ) ): ?>
<h5 class="sp-event-results"><?php echo implode( $main_results, ' - ' ); ?></h5>
<?php else: ?>
<h5 class="sp-event-time"><?php echo get_the_time( get_option( 'time_format' ), $event ); ?></h5>
<?php endif; ?>
<h5 class="sp-event-results"><span class="sp-result"><?php echo implode( '</span>-<span class="sp-result">', sp_get_main_results_or_time( $event ) ); ?></span></h5>
<?php if ( $show_league ): $leagues = get_the_terms( $event, 'sp_league' ); if ( $leagues ): $league = array_shift( $leagues ); ?>
<div class="sp-event-league"><?php echo $league->name; ?></div>
<?php endif; endif; ?>
@@ -139,6 +140,6 @@ if ( $show_title && $id ) {
</div>
<?php
if ( $id && $show_all_events_link )
echo '<a class="sp-calendar-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
echo '<div class="sp-calendar-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a></div>';
?>
</div>

View File

@@ -217,7 +217,7 @@ if ( $pad != 0 && $pad != 7 )
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>\n\t</div>";
if ( $id && $show_all_events_link )
$calendar_output .= '<a class="sp-calendar-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
$calendar_output .= '<div class="sp-calendar-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a></div>';
?>
<div class="sp-template sp-template-event-calendar">
<?php echo $calendar_output; ?>

View File

@@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$defaults = array(
'id' => null,
'title' => false,
'status' => 'default',
'date' => 'default',
'date_from' => 'default',
@@ -55,9 +56,11 @@ if ( isset( $columns ) ):
$usecolumns = explode( ',', $columns );
endif;
if ( $show_title && $id ) {
echo '<h4 class="sp-table-caption">' . get_the_title( $id ) . '</h4>';
}
if ( $show_title && false === $title && $id )
$title = get_the_title( $id );
if ( $title )
echo '<h4 class="sp-table-caption">' . $title . '</h4>';
?>
<div class="sp-template sp-template-event-list">
<div class="sp-table-wrapper">
@@ -359,6 +362,6 @@ if ( $show_title && $id ) {
</div>
<?php
if ( $id && $show_all_events_link )
echo '<a class="sp-calendar-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a>';
echo '<div class="sp-calendar-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all events', 'sportspress' ) . '</a></div>';
?>
</div>

View File

@@ -10,24 +10,57 @@
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( get_option( 'sportspress_event_show_logos', 'yes' ) === 'no' ) return;
$show_team_names = get_option( 'sportspress_event_logos_show_team_names', 'no' ) === 'yes' ? true : false;
$show_results = get_option( 'sportspress_event_logos_show_results', 'no' ) === 'yes' ? true : false;
if ( ! isset( $id ) )
$id = get_the_ID();
if ( $show_results ) {
$results = sp_get_main_results( $id );
if ( empty( $results ) ) {
$show_results = false;
}
}
$teams = get_post_meta( $id, 'sp_team' );
$teams = array_filter( $teams, 'sp_filter_positive' );
if ( $teams ):
$team_logos = array();
$i = 0;
foreach ( $teams as $team ):
if ( ! has_post_thumbnail( $team ) ) continue;
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon' );
// Add team name
if ( $show_team_names ) {
if ( $i % 2 ) {
$logo .= ' <strong class="sp-team-name">' . get_the_title( $team ) . '</strong>';
} else {
$logo = '<strong class="sp-team-name">' . get_the_title( $team ) . '</strong> ' . $logo;
}
}
// Add link
if ( get_option( 'sportspress_link_teams', 'no' ) == 'yes' ) $logo = '<a href="' . get_post_permalink( $team ) . '">' . $logo . '</a>';
$team_logos[] = $logo;
// Add result
if ( $show_results ) {
if ( $i % 2 ) {
$logo = '<strong class="sp-team-result">' . array_shift( $results ) . '</strong> ' . $logo;
} else {
$logo .= ' <strong class="sp-team-result">' . array_shift( $results ) . '</strong>';
}
}
$team_logos[] = '<span class="sp-team-logo">' . $logo . '</span>';
$i++;
endforeach;
$team_logos = array_filter( $team_logos );
if ( ! empty( $team_logos ) ):
echo '<div class="sp-template sp-template-event-logos sp-event-logos">';
echo '<div class="sp-template sp-template-event-logos"><div class="sp-event-logos">';
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
echo implode( ' ' . $delimiter . ' ', $team_logos );
echo '</div>';
echo '</div></div>';
endif;
endif;

View File

@@ -28,6 +28,9 @@ if ( ! isset( $id ) )
$teams = get_post_meta( $id, 'sp_team', false );
if ( is_array( $teams ) ):
?>
<div class="sp-event-performance-tables sp-event-performance-<?php echo $split_positions ? 'positions' : 'teams'; ?>">
<?php
$event = new SP_Event( $id );
$performance = $event->performance();
@@ -140,7 +143,7 @@ if ( is_array( $teams ) ):
}
sp_get_template( 'event-performance-table.php', array(
'position' => $position->name,
'position' => sp_get_position_caption( $position->term_id ),
'scrollable' => $scrollable,
'sortable' => $sortable,
'show_players' => $show_team_players,
@@ -221,7 +224,7 @@ if ( is_array( $teams ) ):
'show_numbers' => $show_numbers,
'show_extras' => $show_extras,
'show_total' => $show_total,
'caption' => $position->name,
'caption' => sp_get_position_caption( $position->term_id ),
'labels' => $labels,
'mode' => $mode,
'data' => $subdata,
@@ -251,4 +254,9 @@ if ( is_array( $teams ) ):
) );
}
}
do_action( 'sportspress_event_performance' );
?>
</div><!-- .sp-event-performance-tables -->
<?php
endif;

View File

@@ -47,8 +47,8 @@ foreach( $venues as $venue ):
<td<?php if ( $address != null ) { ?> colspan="2"<?php } ?>><?php sp_get_template( 'venue-map.php', array( 'meta' => $meta ) ); ?></td>
</tr>
<?php if ( $address != null ) { ?>
<tr>
<td class="sp-event-venue-address-row"><?php echo $address; ?></td>
<tr class="sp-event-venue-address-row">
<td><?php echo $address; ?></td>
</tr>
<?php } ?>
</tbody>

View File

@@ -15,6 +15,8 @@ $defaults = array(
'columns' => null,
'highlight' => null,
'show_full_table_link' => false,
'title' => false,
'show_title' => get_option( 'sportspress_table_show_title', 'yes' ) == 'yes' ? true : false,
'show_team_logo' => get_option( 'sportspress_table_show_logos', 'yes' ) == 'yes' ? true : false,
'link_posts' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
@@ -29,7 +31,13 @@ if ( ! isset( $highlight ) ) $highlight = get_post_meta( $id, 'sp_highlight', tr
$table = new SP_League_Table( $id );
$output = '<h4 class="sp-table-caption">' . get_the_title( $id ) . '</h4>';
if ( $show_title && false === $title && $id )
$title = get_the_title( $id );
$output = '';
if ( $title )
$output .= '<h4 class="sp-table-caption">' . $title . '</h4>';
$output .= '<div class="sp-table-wrapper">';
@@ -149,7 +157,7 @@ $output .= '</tbody>' . '</table>';
$output .= '</div>';
if ( $show_full_table_link )
$output .= '<a class="sp-league-table-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View full table', 'sportspress' ) . '</a>';
$output .= '<div class="sp-league-table-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View full table', 'sportspress' ) . '</a></div>';
?>
<div class="sp-template sp-template-league-table">

View File

@@ -12,6 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$html5 = current_theme_supports( 'html5', 'gallery' );
$defaults = array(
'id' => get_the_ID(),
'title' => false,
'number' => -1,
'grouping' => null,
'orderby' => 'default',
@@ -71,6 +72,9 @@ else:
uasort( $data, array( $list, 'sort' ) );
endif;
if ( $title )
echo '<h4 class="sp-table-caption">' . $title . '</h4>';
$gallery_style = $gallery_div = '';
if ( apply_filters( 'use_default_gallery_style', ! $html5 ) )
$gallery_style = "
@@ -156,7 +160,7 @@ echo apply_filters( 'gallery_style', $gallery_style . "\n\t\t" );
}
if ( $show_all_players_link ) {
echo '<a class="sp-player-list-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
echo '<div class="sp-player-list-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a></div>';
}
echo "</div>\n";

View File

@@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$defaults = array(
'id' => get_the_ID(),
'title' => false,
'number' => -1,
'grouptag' => 'h4',
'columns' => null,
@@ -18,6 +19,7 @@ $defaults = array(
'orderby' => 'default',
'order' => 'ASC',
'show_all_players_link' => false,
'show_title' => get_option( 'sportspress_list_show_title', 'yes' ) == 'yes' ? true : false,
'show_player_photo' => get_option( 'sportspress_list_show_photos', 'yes' ) == 'yes' ? true : false,
'link_posts' => get_option( 'sportspress_link_players', 'yes' ) == 'yes' ? true : false,
'link_teams' => get_option( 'sportspress_link_teams', 'no' ) == 'yes' ? true : false,
@@ -66,9 +68,15 @@ else:
uasort( $data, array( $list, 'sort' ) );
endif;
$output = '';
if ( $grouping === 'position' ):
$groups = get_terms( 'sp_position', array( 'orderby' => 'slug' ) );
else:
if ( $show_title && false === $title && $id )
get_the_title( $id );
if ( $title )
$output .= '<' . $grouptag . ' class="sp-table-caption">' . $title . '</' . $grouptag . '>';
$group = new stdClass();
$group->term_id = null;
$group->name = null;
@@ -76,9 +84,10 @@ else:
$groups = array( $group );
endif;
$output = '';
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 . '>';
@@ -165,11 +174,12 @@ foreach ( $groups as $group ):
endif; endforeach;
$output .= '</tbody>' . '</table>' . '</div>';
endforeach;
if ( $show_all_players_link )
$output .= '<a class="sp-player-list-link sp-view-all-link" href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a>';
if ( $show_all_players_link ):
$output .= '<div class="sp-player-list-link sp-view-all-link"><a href="' . get_permalink( $id ) . '">' . __( 'View all players', 'sportspress' ) . '</a></div>';
endif;
$output .= '</div>';
endforeach;
?>
<div class="sp-template sp-template-player-list">
<?php echo $output; ?>
</div>
<?php echo $output; ?>