Add event result filters

This commit is contained in:
Brian Miyaji
2015-10-07 01:14:12 +11:00
parent cf16de8d30
commit f0b30f4048
6 changed files with 20 additions and 30 deletions

View File

@@ -160,7 +160,7 @@ class SP_Admin_CPT_Event extends SP_Admin_CPT {
$team_results = implode( ' | ', $team_results ); $team_results = implode( ' | ', $team_results );
endif; endif;
echo '<a class="sp-result sp-tip" tabindex="10" title="' . $team_results . '" data-team="' . $team_id . '" href="#">' . ( $team_result == '' ? '-' : $team_result ) . '</a>'; echo '<a class="sp-result sp-tip" tabindex="10" title="' . $team_results . '" data-team="' . $team_id . '" href="#">' . ( $team_result == '' ? '-' : apply_filters( 'sportspress_event_team_result_admin', $team_result, $post_id, $team_id ) ) . '</a>';
echo '<input type="text" tabindex="10" class="sp-edit-result hidden small-text" data-team="' . $team_id . '" data-key="' . $main_result . '" value="' . $team_result . '"> '; echo '<input type="text" tabindex="10" class="sp-edit-result hidden small-text" data-team="' . $team_id . '" data-key="' . $main_result . '" value="' . $team_result . '"> ';
echo $team->post_title; echo $team->post_title;
echo '<br>'; echo '<br>';

View File

@@ -146,6 +146,7 @@ class SP_Meta_Box_Calendar_Data {
endif; endif;
if ( $team_result != null ): if ( $team_result != null ):
$team_result = apply_filters( 'sportspress_calendar_team_result_admin', $team_result, $event->ID, $team );
$main_results[] = $team_result; $main_results[] = $team_result;
unset( $team_results['outcome'] ); unset( $team_results['outcome'] );
$team_results = implode( ' | ', $team_results ); $team_results = implode( ' | ', $team_results );

View File

@@ -9,8 +9,6 @@
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$primary_result = get_option( 'sportspress_primary_result', null );
$defaults = array( $defaults = array(
'id' => null, 'id' => null,
'title' => false, 'title' => false,
@@ -82,12 +80,12 @@ if ( $title )
foreach ( $data as $event ): foreach ( $data as $event ):
if ( isset( $limit ) && $i >= $limit ) continue; if ( isset( $limit ) && $i >= $limit ) continue;
$permalink = get_post_permalink( $event, false, true );
$results = get_post_meta( $event->ID, 'sp_results', true ); $results = get_post_meta( $event->ID, 'sp_results', true );
$teams = array_unique( get_post_meta( $event->ID, 'sp_team' ) ); $teams = array_unique( get_post_meta( $event->ID, 'sp_team' ) );
$teams = array_filter( $teams, 'sp_filter_positive' ); $teams = array_filter( $teams, 'sp_filter_positive' );
$logos = array(); $logos = array();
$main_results = array();
$j = 0; $j = 0;
foreach( $teams as $team ): foreach( $teams as $team ):
@@ -100,28 +98,17 @@ if ( $title )
endif; endif;
$logos[] = $logo; $logos[] = $logo;
endif; endif;
$team_results = sp_array_value( $results, $team, null );
if ( $primary_result ):
$team_result = sp_array_value( $team_results, $primary_result, null );
else:
if ( is_array( $team_results ) ):
end( $team_results );
$team_result = prev( $team_results );
else:
$team_result = null;
endif;
endif;
if ( $team_result != null )
$main_results[] = $team_result;
endforeach; endforeach;
?> ?>
<tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>"> <tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>">
<td> <td>
<?php echo implode( $logos, ' ' ); ?> <?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> <time class="sp-event-date" datetime="<?php echo $event->post_date; ?>">
<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 echo sp_add_link( get_the_time( get_option( 'date_format' ), $event ), $permalink, $link_events ); ?>
</time>
<h5 class="sp-event-results">
<?php echo sp_add_link( '<span class="sp-result">' . implode( '</span>-<span class="sp-result">', apply_filters( 'sportspress_event_blocks_team_result_or_time', sp_get_main_results_or_time( $event ), $event->ID ) ), $permalink, $link_events . '</span>' ); ?>
</h5>
<?php if ( $show_league ): $leagues = get_the_terms( $event, 'sp_league' ); if ( $leagues ): $league = array_shift( $leagues ); ?> <?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> <div class="sp-event-league"><?php echo $league->name; ?></div>
<?php endif; endif; ?> <?php endif; endif; ?>
@@ -132,11 +119,7 @@ if ( $title )
<div class="sp-event-venue"><?php echo $venue->name; ?></div> <div class="sp-event-venue"><?php echo $venue->name; ?></div>
<?php endif; endif; ?> <?php endif; endif; ?>
<h4 class="sp-event-title"> <h4 class="sp-event-title">
<?php if ( $link_events ): ?> <?php echo sp_add_link( $event->post_title, $permalink, $link_events ); ?>
<a href="<?php echo get_post_permalink( $event, false, true ); ?>"><?php echo $event->post_title; ?></a>
<?php else: ?>
<?php echo $event->post_title; ?>
<?php endif; ?>
</h4> </h4>
</td> </td>

View File

@@ -155,7 +155,7 @@ endif;
$teams = get_post_meta( $event->ID, 'sp_team' ); $teams = get_post_meta( $event->ID, 'sp_team' );
$video = get_post_meta( $event->ID, 'sp_video', true ); $video = get_post_meta( $event->ID, 'sp_video', true );
$main_results = sp_get_main_results( $event ); $main_results = apply_filters( 'sportspress_event_list_main_results', sp_get_main_results( $event ), $event->ID );
$teams_output = ''; $teams_output = '';
$teams_array = array(); $teams_array = array();

View File

@@ -48,10 +48,12 @@ if ( $teams ):
// Add result // Add result
if ( $show_results ) { if ( $show_results ) {
$team_result = array_shift( $results );
$team_result = apply_filters( 'sportspress_event_logos_team_result', $team_result, $id, $team );
if ( $alt ) { if ( $alt ) {
$logo = '<strong class="sp-team-result">' . array_shift( $results ) . '</strong> ' . $logo; $logo = '<strong class="sp-team-result">' . $team_result . '</strong> ' . $logo;
} else { } else {
$logo .= ' <strong class="sp-team-result">' . array_shift( $results ) . '</strong>'; $logo .= ' <strong class="sp-team-result">' . $team_result . '</strong>';
} }
} }

View File

@@ -131,11 +131,13 @@ if ( is_array( $teams ) ):
$allowed_labels[ $label->post_name ] = $label->post_title; $allowed_labels[ $label->post_name ] = $label->post_title;
} }
$allowed_labels = apply_filters( 'sportspress_event_performance_allowed_labels', $allowed_labels, $position_index );
$sublabels = array_intersect_key( $sublabels, $allowed_labels ); $sublabels = array_intersect_key( $sublabels, $allowed_labels );
} }
if ( sizeof( $subdata ) ) { if ( sizeof( $subdata ) ) {
$subdata = apply_filters( 'sportspress_event_performance_split_team_split_position_subdata', $subdata, $data ); $subdata = apply_filters( 'sportspress_event_performance_split_team_split_position_subdata', $subdata, $data, $position_index );
sp_get_template( 'event-performance-table.php', array( sp_get_template( 'event-performance-table.php', array(
'position' => sp_get_position_caption( $position->term_id ), 'position' => sp_get_position_caption( $position->term_id ),
@@ -210,6 +212,8 @@ if ( is_array( $teams ) ):
} }
} }
$subdata = apply_filters( 'sportspress_event_performance_split_position_subdata', $subdata, $data, $position_index );
if ( sizeof( $subdata ) ) { if ( sizeof( $subdata ) ) {
sp_get_template( 'event-performance-table-combined.php', array( sp_get_template( 'event-performance-table-combined.php', array(
'scrollable' => $scrollable, 'scrollable' => $scrollable,