Craze Collective
Forum Replies Created
-
Can you guys implement a setting in a future release so you can toggle how the position sorting is done if it is not ‘always incremental’?
Update: by adding brackets between the total points calculations ( at the start and ) before the divided by operator, this now works!
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] Player Page EditsI had to edit the previous code i replied with because it was ruining how player lists displayed in calendar view, now this new code treats calendar player lists and player profile player lists differently.
<?php
/**
* Unified Event List Template
*
* Works for both Player and Calendar pages.
* Player page: Date | Season | Event | Outcome
* Calendar page: Date | Event | Season
*
* @author Crazecollective
* @package SportsPress/Templates
* @version 1.4
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// Detect if we are on a player page
$is_player_page = is_singular('sp_player');
// Ensure $player is set
if ( ! isset( $player ) && $is_player_page ) {
$player = get_the_ID();
}
// Defaults
$defaults = array(
'id' => null,
'title' => false,
'status' => 'default',
'format' => 'default',
'date' => 'default',
'date_from' => 'default',
'date_to' => 'default',
'date_past' => 'default',
'date_future' => 'default',
'date_relative' => 'default',
'day' => 'default',
'league' => null,
'season' => null,
'venue' => null,
'team' => null,
'teams_past' => null,
'date_before' => null,
'player' => $is_player_page ? $player : null,
'number' => -1,
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == '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,
'link_venues' => get_option( 'sportspress_link_venues', 'yes' ) == 'yes' ? true : false,
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'no' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false,
'paginated' => get_option( 'sportspress_event_list_paginated', 'no' ) == 'yes' ? true : false,
'rows' => get_option( 'sportspress_event_list_rows', 10 ),
'order' => 'default',
'columns' => null,
'show_all_events_link' => false,
'show_title' => get_option( 'sportspress_event_list_show_title', 'yes' ) == 'yes' ? true : false,
'title_format' => get_option( 'sportspress_event_list_title_format', 'title' ),
'time_format' => get_option( 'sportspress_event_list_time_format', 'combined' ),
);
extract( $defaults, EXTR_SKIP );
// Get the calendar object
$calendar = new SP_Calendar( $id );
if ( $status != 'default' ) $calendar->status = $status;
if ( $format != 'default' ) $calendar->event_format = $format;
if ( $date != 'default' ) $calendar->date = $date;
if ( $date_from != 'default' ) $calendar->from = $date_from;
if ( $date_to != 'default' ) $calendar->to = $date_to;
if ( $date_past != 'default' ) $calendar->past = $date_past;
if ( $date_future != 'default' ) $calendar->future = $date_future;
if ( $date_relative != 'default' ) $calendar->relative = $date_relative;
if ( $league ) $calendar->league = $league;
if ( $season ) $calendar->season = $season;
if ( $venue ) $calendar->venue = $venue;
if ( $team ) $calendar->team = $team;
if ( $teams_past ) $calendar->teams_past = $teams_past;
if ( $date_before ) $calendar->date_before = $date_before;
if ( $player && $is_player_page ) $calendar->player = $player;
if ( $order != 'default' ) $calendar->order = $order;
if ( $day != 'default' ) $calendar->day = $day;
// Get event data
$data = $calendar->data();
$usecolumns = $calendar->columns;
// Columns explicitly set
if ( isset( $columns ) ) :
if ( is_array( $columns ) ) {
$usecolumns = $columns;
} else {
$usecolumns = explode( ',', $columns );
}
endif;
// Ensure outcome column present for player page
if ( $is_player_page && ! in_array( 'outcome', $usecolumns, true ) ) {
$usecolumns[] = 'outcome';
}
// Title
if ( $show_title && false === $title && $id ) :
$caption = $calendar->caption;
$title = $caption ? $caption : get_the_title( $id );
endif;
$identifier = uniqid( 'eventlist_' );
?>
<div class="sp-template sp-template-event-list">
<?php if ( $show_title ) : ?>
<h3 class="sp-widget-title" style="margin-bottom:12px;"><?php esc_html_e( 'Events competed in:', 'sportspress' ); ?></h3>
<?php if ( $title ) : ?>
<h4 class="sp-table-caption"><?php echo wp_kses_post( $title ); ?></h4>
<?php endif; ?>
<?php endif; ?>
<div class="sp-table-wrapper">
<table class="sp-event-list sp-event-list-format-<?php echo esc_attr( $title_format ); ?> sp-data-table
<?php if ( $paginated ) echo ' sp-paginated-table'; ?>
<?php if ( $sortable ) echo ' sp-sortable-table'; ?>
<?php if ( $responsive ) echo ' sp-responsive-table ' . esc_attr( $identifier ); ?>
<?php if ( $scrollable ) echo ' sp-scrollable-table'; ?>" data-sp-rows="<?php echo esc_attr( $rows ); ?>">
<thead>
<tr>
<th class="data-date"><?php esc_html_e( 'Date', 'sportspress' ); ?></th>
<?php if ( $is_player_page ) : ?>
<th class="data-season"><?php esc_html_e( 'Season', 'sportspress' ); ?></th>
<th class="data-event"><?php esc_html_e( 'Event', 'sportspress' ); ?></th>
<th class="data-outcome"><?php esc_html_e( 'Outcome', 'sportspress' ); ?></th>
<?php else : ?>
<th class="data-event"><?php esc_html_e( 'Event', 'sportspress' ); ?></th>
<th class="data-season"><?php esc_html_e( 'Season', 'sportspress' ); ?></th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php
$i = 0;
if ( is_numeric( $number ) && $number > 0 ) $limit = $number;
foreach ( $data as $event ) :
if ( isset( $limit ) && $i >= $limit ) continue;
$event_obj = new SP_Event( $event->ID );
// Date
$date_html = get_post_time( get_option( 'date_format' ), false, $event, true );
if ( $link_events ) $date_html = '<a href="' . get_post_permalink( $event->ID ) . '">' . $date_html . '</a>';
// Season
$seasons = get_the_terms( $event->ID, 'sp_season' );
$season_html = !empty($seasons) && !is_wp_error($seasons) ? implode(', ', wp_list_pluck($seasons,'name')) : '—';
// Event title + optional logos
$teams = get_post_meta( $event->ID, 'sp_team' );
$team_logos = array();
if ( $teams && $show_team_logo ) {
foreach ( $teams as $t ) {
if ( has_post_thumbnail( $t ) ) {
$team_logos[] = '<span class="team-logo">' . sp_get_logo( $t, 'mini', array( 'itemprop' => 'url' ) ) . '</span>';
}
}
}
$title_html = implode(' ', $team_logos) . ' ' . $event->post_title;
if ( $link_events ) $title_html = '<a href="' . get_post_permalink( $event->ID, false, true ) . '" itemprop="url name">' . $title_html . '</a>';
// Outcome only for player page
$outcome = '—';
if ( $is_player_page ) {
$event_results = $event_obj->results();
foreach ( $event_results as $competitor_id => $result ) {
if ( (int)$competitor_id === (int)$player ) {
$player_outcome = sp_array_value( $result, 'outcome' );
if ( is_array($player_outcome) ) {
$outcomes = array();
foreach ( $player_outcome as $oc ) {
$the_outcome = get_page_by_path( $oc, OBJECT, 'sp_outcome' );
$outcomes[] = is_object($the_outcome) ? $the_outcome->post_title : $oc;
}
$outcome = implode(', ', $outcomes);
} elseif ( ! empty($player_outcome) ) {
$outcome = esc_html($player_outcome);
}
break;
}
}
}
?>
<tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>" itemscope itemtype="http://schema.org/SportsEvent">
<td class="data-date" itemprop="startDate" content="<?php echo esc_attr( mysql2date( 'Y-m-d\TH:i:sP', $event->post_date ) ); ?>">
<?php echo wp_kses_post( $date_html ); ?>
</td>
<?php if ( $is_player_page ) : ?>
<td class="data-season"><?php echo wp_kses_post( $season_html ); ?></td>
<td class="data-event" itemprop="name"><?php echo wp_kses_post( $title_html ); ?></td>
<td class="data-outcome"><?php echo wp_kses_post( $outcome ); ?></td>
<?php else : ?>
<td class="data-event" itemprop="name"><?php echo wp_kses_post( $title_html ); ?></td>
<td class="data-season"><?php echo wp_kses_post( $season_html ); ?></td>
<?php endif; ?>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<?php if ( $responsive ) {
// sportspress_responsive_tables_css( $identifier );
} ?>
<?php if ( $id && $show_all_events_link ) : ?>
<div class="sp-calendar-link sp-view-all-link">
<a href="<?php echo esc_url( get_permalink( $id ) ); ?>"><?php esc_html_e( 'View all events', 'sportspress' ); ?></a>
</div>
<?php endif; ?>
</div>was able to fix this by editing class-sp-league-table.php
new code as seen here.
<?php
/**
* League Table Class
*
* The SportsPress league table class handles individual league table data.
*
* @class SP_League_Table
* @version 2.7.26
* @package SportsPress/Classes
* @category Class
* @author ThemeBoy & crazecollective
*/
class SP_League_Table extends SP_Secondary_Post {
/** @var array The sort priorities array. */
public $priorities;
/** @var int Position of team in the table. */
public $pos;
/** @var int Incremental value for team position. */
public $counter;
/** @var array Teams to check for tiebreakers. */
public $tiebreakers = array();
// ** @var strings
public $orderby;
public $orderbyorder;
public $compare;
/** @var int Last position for dense ranking */
public static $last_pos = 0;
/** @var array Last compared team columns for dense ranking */
public static $last_compare = null;
/** @var int Show Published events. */
public $show_published_events;
/** @var int Show Scheduled events. */
public $show_future_events;
/**
* Returns formatted data
*
* @access public
* @param bool $admin
* @return array
*/
public function data( $admin = false, $team_ids = null ) {
// Reset dense ranking counters for new table
self::$last_pos = 0;
self::$last_compare = null;
$this->pos = 0;
$this->counter = 0;
$league_ids = sp_get_the_term_ids( $this->ID, 'sp_league' );
$season_ids = sp_get_the_term_ids( $this->ID, 'sp_season' );
$table_stats = (array) get_post_meta( $this->ID, 'sp_teams', true );
$usecolumns = get_post_meta( $this->ID, 'sp_columns', true );
$adjustments = get_post_meta( $this->ID, 'sp_adjustments', true );
$select = get_post_meta( $this->ID, 'sp_select', true );
$this->orderby = get_post_meta( $this->ID, 'sp_orderby', true );
$this->orderbyorder = get_post_meta( $this->ID, 'sp_order', true );
$link_events = get_option( 'sportspress_link_events', 'yes' ) === 'yes' ? true : false;
$form_limit = (int) get_option( 'sportspress_form_limit', 5 );
$this->date = $this->__get( 'date' );
if ( ! $this->date ) {
$this->date = 0;
}
// Apply defaults
if ( empty( $this->orderby ) ) {
$this->orderby = 'default';
}
if ( empty( $this->orderbyorder ) ) {
$this->orderbyorder = 'ASC';
}
if ( empty( $select ) ) {
$select = 'auto';
}
if ( 'range' == $this->date ) {
$this->relative = get_post_meta( $this->ID, 'sp_date_relative', true );
if ( $this->relative ) {
$this->past = get_post_meta( $this->ID, 'sp_date_past', true );
} else {
$this->from = get_post_meta( $this->ID, 'sp_date_from', true );
$this->to = get_post_meta( $this->ID, 'sp_date_to', true );
}
}
// Get labels from result variables
$result_labels = (array) sp_get_var_labels( 'sp_result' );
// Get labels from outcome variables
$outcome_labels = (array) sp_get_var_labels( 'sp_outcome' );
// Get post type
$post_type = sp_get_post_mode_type( $this->ID );
// Determine if main loop
if ( $team_ids ) {
$is_main_loop = false;
} else {
// Get teams automatically if set to auto
if ( 'auto' == $select ) {
$team_ids = array();
$args = array(
'post_type' => $post_type,
'numberposts' => -1,
'posts_per_page' => -1,
'order' => 'ASC',
'tax_query' => array(
'relation' => 'AND',
),
'fields' => 'ids',
);
if ( $league_ids ) :
$args['tax_query'][] = array(
'taxonomy' => 'sp_league',
'field' => 'term_id',
'terms' => $league_ids,
);
endif;
if ( $season_ids ) :
$args['tax_query'][] = array(
'taxonomy' => 'sp_season',
'field' => 'term_id',
'terms' => $season_ids,
);
endif;
$team_ids = get_posts( $args );
} else {
$team_ids = (array) get_post_meta( $this->ID, 'sp_team', false );
}
$is_main_loop = true;
}
// Get all leagues populated with stats where available
$tempdata = sp_array_combine( $team_ids, $table_stats );
// Create entry for each team in totals
$totals = array();
$placeholders = array();
// Initialize incremental counter
$this->pos = 0;
$this->counter = 0;
// Initialize team compare
$this->compare = null;
// Initialize streaks counter
$streaks = array();
// Initialize form counter
$forms = array();
// Initialize last counters
$last5s = array();
$last10s = array();
// Initialize record counters
$homerecords = array();
$awayrecords = array();
foreach ( $team_ids as $team_id ) :
if ( ! $team_id ) {
continue;
}
// Initialize team streaks counter
$streaks[ $team_id ] = array(
'name' => '',
'count' => 0,
'fire' => 1,
);
// Initialize team form counter
$forms[ $team_id ] = array();
// Initialize team last counters
$last5s[ $team_id ] = array();
$last10s[ $team_id ] = array();
// Initialize team record counters
$homerecords[ $team_id ] = array();
$awayrecords[ $team_id ] = array();
// Add outcome types to team last and record counters
foreach ( $outcome_labels as $key => $value ) :
$last5s[ $team_id ][ $key ] = 0;
$last10s[ $team_id ][ $key ] = 0;
$homerecords[ $team_id ][ $key ] = 0;
$awayrecords[ $team_id ][ $key ] = 0;
endforeach;
// Initialize team totals
$totals[ $team_id ] = array(
'eventsplayed' => 0,
'eventsplayed_home' => 0,
'eventsplayed_away' => 0,
'eventsplayed_venue' => 0,
'eventminutes' => 0,
'eventminutes_home' => 0,
'eventminutes_away' => 0,
'eventminutes_venue' => 0,
'streak' => 0,
'streak_home' => 0,
'streak_away' => 0,
'streak_venue' => 0,
);
foreach ( $result_labels as $key => $value ) :
$totals[ $team_id ][ $key . 'for' ] = 0;
$totals[ $team_id ][ $key . 'for_home' ] = 0;
$totals[ $team_id ][ $key . 'for_away' ] = 0;
$totals[ $team_id ][ $key . 'for_venue' ] = 0;
$totals[ $team_id ][ $key . 'against' ] = 0;
$totals[ $team_id ][ $key . 'against_home' ] = 0;
$totals[ $team_id ][ $key . 'against_away' ] = 0;
$totals[ $team_id ][ $key . 'against_venue' ] = 0;
endforeach;
foreach ( $outcome_labels as $key => $value ) :
$totals[ $team_id ][ $key ] = 0;
$totals[ $team_id ][ $key . '_home' ] = 0;
$totals[ $team_id ][ $key . '_away' ] = 0;
$totals[ $team_id ][ $key . '_venue' ] = 0;
endforeach;
// Get static stats
$static = get_post_meta( $team_id, 'sp_columns', true );
if ( 'yes' == get_option( 'sportspress_team_column_editing', 'no' ) && $league_ids && $season_ids ) :
// Add static stats to placeholders
foreach ( $league_ids as $league_id ) :
foreach ( $season_ids as $season_id ) :
$placeholders[ $team_id ] = (array) sp_array_value( sp_array_value( $static, $league_id, array() ), $season_id, array() );
endforeach;
endforeach;
endif;
endforeach;
// Get which event status to include
$event_status = get_post_meta( $this->ID, 'sp_event_status', true );
if ( empty( $event_status ) ) {
$event_status = array( 'publish', 'future' );
}
if ( isset( $this->show_published_events ) ) { // If an attribute was pass through shortcode
if ( $this->show_published_events == '1' ) {
$event_status[] = 'publish';
} else {
if ( ( $status_key = array_search( 'publish', $event_status ) ) !== false ) {
unset( $event_status[ $status_key ] );
}
}
}
if ( isset( $this->show_future_events ) ) { // If an attribute was pass through shortcode
if ( $this->show_future_events == '1' ) {
$event_status[] = 'future';
} else {
if ( ( $status_key = array_search( 'future', $event_status ) ) !== false ) {
unset( $event_status[ $status_key ] );
}
}
}
// Make sure to have unique values in the array
$event_status = array_unique( $event_status );
$args = array(
'post_type' => 'sp_event',
'post_status' => $event_status,
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'post_date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => 'sp_format',
'value' => apply_filters( 'sportspress_competitive_event_formats', array( 'league' ) ),
'compare' => 'IN',
),
),
'tax_query' => array(
'relation' => 'AND',
),
);
if ( $league_ids ) :
$args['tax_query'][] = array(
'taxonomy' => 'sp_league',
'field' => 'term_id',
'terms' => $league_ids,
);
endif;
if ( $season_ids ) :
$args['tax_query'][] = array(
'taxonomy' => 'sp_season',
'field' => 'term_id',
'terms' => $season_ids,
);
endif;
if ( $this->date !== 0 ) :
if ( $this->date == 'w' ) :
$args['year'] = date_i18n( 'Y' );
$args['w'] = date_i18n( 'W' );
elseif ( $this->date == 'day' ) :
$args['year'] = date_i18n( 'Y' );
$args['day'] = date_i18n( 'j' );
$args['monthnum'] = date_i18n( 'n' );
elseif ( $this->date == 'range' ) :
if ( $this->relative ) :
add_filter( 'posts_where', array( $this, 'relative' ) );
else :
add_filter( 'posts_where', array( $this, 'range' ) );
endif;
endif;
endif;
$args = apply_filters( 'sportspress_table_data_event_args', $args );
if ( ! $is_main_loop ) :
if ( sizeof( $team_ids ) ) :
$args['meta_query'][] = array(
'key' => 'sp_team',
'value' => $team_ids,
'compare' => 'IN',
);
endif;
endif;
$events = get_posts( $args );
// Remove range filters
remove_filter( 'posts_where', array( $this, 'range' ) );
remove_filter( 'posts_where', array( $this, 'relative' ) );
$e = 0;
// Event loop
foreach ( $events as $event ) :
$teams = (array) get_post_meta( $event->ID, 'sp_team', false );
$teams = array_filter( $teams );
if ( ! $is_main_loop && sizeof( array_diff( $teams, $team_ids ) ) ) {
continue;
}
$results = (array) get_post_meta( $event->ID, 'sp_results', true );
$minutes = (int) get_post_meta( $event->ID, 'sp_minutes', true );
$minutes = $minutes ? $minutes : (int) get_option( 'sportspress_event_minutes', 90 );
$i = 0;
foreach ( $results as $team_id => $team_result ) :
if ( ! in_array( $team_id, $teams ) ) {
continue;
}
if ( ! in_array( $team_id, $team_ids ) ) {
$i++;
continue;
}
if ( $team_result ) :
foreach ( $team_result as $key => $value ) :
if ( $key == 'outcome' ) :
if ( ! is_array( $value ) ) :
$value = array( $value );
endif;
foreach ( $value as $outcome ) :
// Increment events played and outcome count
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $outcome, $totals[ $team_id ] ) ) :
$totals[ $team_id ]['eventsplayed'] ++;
$totals[ $team_id ]['eventminutes'] = (int) $totals[ $team_id ]['eventminutes'] + $minutes;
$totals[ $team_id ][ $outcome ] ++;
// Add to home or away stats
if ( 0 === $i ) :
$totals[ $team_id ]['eventsplayed_home'] ++;
$totals[ $team_id ]['eventminutes_home'] = (int) $totals[ $team_id ]['eventminutes_home'] + $minutes;
$totals[ $team_id ][ $outcome . '_home' ] ++;
else :
$totals[ $team_id ]['eventsplayed_away'] ++;
$totals[ $team_id ]['eventminutes_away'] = (int) $totals[ $team_id ]['eventminutes_away'] + $minutes;
$totals[ $team_id ][ $outcome . '_away' ] ++;
endif;
// Add to venue stats
if ( sp_is_home_venue( $team_id, $event->ID ) ) :
$totals[ $team_id ]['eventsplayed_venue'] ++;
$totals[ $team_id ]['eventminutes_venue'] = (int) $totals[ $team_id ]['eventminutes_venue'] + $minutes;
$totals[ $team_id ][ $outcome . '_venue' ] ++;
endif;
endif;
if ( $outcome && $outcome != '-1' ) :
// Add to streak counter
if ( $streaks[ $team_id ]['fire'] && ( $streaks[ $team_id ]['name'] == '' || $streaks[ $team_id ]['name'] == $outcome ) ) :
$streaks[ $team_id ]['name'] = $outcome;
$streaks[ $team_id ]['count'] ++;
else :
$streaks[ $team_id ]['fire'] = 0;
endif;
// Add to form counter
$forms[ $team_id ][] = array(
'id' => $event->ID,
'outcome' => $outcome,
);
// Add to last 5 counter if sum is less than 5
if ( array_key_exists( $team_id, $last5s ) && array_key_exists( $outcome, $last5s[ $team_id ] ) && array_sum( $last5s[ $team_id ] ) < 5 ) :
$last5s[ $team_id ][ $outcome ] ++;
endif;
// Add to last 10 counter if sum is less than 10
if ( array_key_exists( $team_id, $last10s ) && array_key_exists( $outcome, $last10s[ $team_id ] ) && array_sum( $last10s[ $team_id ] ) < 10 ) :
$last10s[ $team_id ][ $outcome ] ++;
endif;
// Add to home or away record
if ( 0 === $i ) {
if ( array_key_exists( $team_id, $homerecords ) && array_key_exists( $outcome, $homerecords[ $team_id ] ) ) {
$homerecords[ $team_id ][ $outcome ] ++;
}
} else {
if ( array_key_exists( $team_id, $awayrecords ) && array_key_exists( $outcome, $awayrecords[ $team_id ] ) ) {
$awayrecords[ $team_id ][ $outcome ] ++;
}
}
endif;
endforeach;
else :
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $key . 'for', $totals[ $team_id ] ) ) :
// Get numeric value
$value = floatval( $value );
$totals[ $team_id ][ $key . 'for' ] += $value;
$totals[ $team_id ][ $key . 'for' . ( $e + 1 ) ] = $value;
// Add to home or away stats
if ( 0 === $i ) :
$totals[ $team_id ][ $key . 'for_home' ] += $value;
else :
$totals[ $team_id ][ $key . 'for_away' ] += $value;
endif;
// Add to venue stats
if ( sp_is_home_venue( $team_id, $event->ID ) ) :
$totals[ $team_id ][ $key . 'for_venue' ] += $value;
endif;
foreach ( $results as $other_team_id => $other_result ) :
if ( $other_team_id != $team_id && array_key_exists( $key . 'against', $totals[ $team_id ] ) ) :
// Get numeric value of other team's result
$value = floatval( sp_array_value( $other_result, $key, 0 ) );
$totals[ $team_id ][ $key . 'against' ] += $value;
$totals[ $team_id ][ $key . 'against' . ( $e + 1 ) ] = $value;
// Add to home or away stats
if ( 0 === $i ) :
$totals[ $team_id ][ $key . 'against_home' ] += $value;
else :
$totals[ $team_id ][ $key . 'against_away' ] += $value;
endif;
// Add to venue stats
if ( sp_is_home_venue( $team_id, $event->ID ) ) :
$totals[ $team_id ][ $key . 'against_venue' ] += $value;
endif;
endif;
endforeach;
endif;
endif;
endforeach;
endif;
$i++;
endforeach;
$e++;
endforeach;
// Get outcomes
$outcomes = array();
$args = array(
'post_type' => 'sp_outcome',
'post_status' => 'publish',
'posts_per_page' => -1,
);
$posts = get_posts( $args );
if ( $posts ) :
foreach ( $posts as $post ) :
// Get ID
$id = $post->ID;
// Get title
$title = $post->post_title;
// Get abbreviation
$abbreviation = get_post_meta( $id, 'sp_abbreviation', true );
if ( ! $abbreviation ) :
$abbreviation = substr( $title, 0, 1 );
endif;
// Get color
$color = get_post_meta( $id, 'sp_color', true );
if ( '' === $color ) {
$color = '#888888';
}
$outcomes[ $post->post_name ] = array(
'id' => $id,
'title' => $title,
'abbreviation' => $abbreviation,
'color' => $color,
);
endforeach;
endif;
foreach ( $streaks as $team_id => $streak ) :
// Compile streaks counter and add to totals
if ( $streak['name'] ) :
$outcome = sp_array_value( $outcomes, $streak['name'], false );
if ( $outcome ) :
$color = $outcome['color'];
$totals[ $team_id ]['streak'] = '<span style="color:' . $color . '">' . $outcome['abbreviation'] . $streak['count'] . '</span>';
else :
$totals[ $team_id ]['streak'] = null;
endif;
else :
$totals[ $team_id ]['streak'] = null;
endif;
endforeach;
foreach ( $forms as $team_id => $form ) :
// Apply form limit
if ( $form_limit && sizeof( $form ) > $form_limit ) :
$form = array_slice( $form, 0, $form_limit );
endif;
// Initialize team form array
$team_form = array();
// Reverse form array to display in chronological order
$form = array_reverse( $form );
// Loop through event form
foreach ( $form as $form_event ) :
if ( $form_event['id'] ) :
$outcome = sp_array_value( $outcomes, $form_event['outcome'], false );
if ( $outcome ) :
$abbreviation = $outcome['abbreviation'];
$color = $outcome['color'];
if ( $link_events ) :
$abbreviation = '<a class="sp-form-event-link" href="' . get_post_permalink( $form_event['id'], false, true ) . '" style="background-color:' . $color . '">' . $abbreviation . '</a>';
else :
$abbreviation = '<span class="sp-form-event-link" style="background-color:' . $color . '">' . $abbreviation . '</span>';
endif;
// Add to team form
$team_form[] = $abbreviation;
endif;
endif;
endforeach;
// Append to totals
if ( sizeof( $team_form ) ) :
$totals[ $team_id ]['form'] = '<div class="sp-form-events">' . implode( ' ', $team_form ) . '</div>';
else :
$totals[ $team_id ]['form'] = null;
endif;
endforeach;
foreach ( $last5s as $team_id => $last5 ) :
// Add last 5 to totals
$totals[ $team_id ]['last5'] = $last5;
endforeach;
foreach ( $last10s as $team_id => $last10 ) :
// Add last 10 to totals
$totals[ $team_id ]['last10'] = $last10;
endforeach;
foreach ( $homerecords as $team_id => $homerecord ) :
// Add home record to totals
$totals[ $team_id ]['homerecord'] = $homerecord;
endforeach;
foreach ( $awayrecords as $team_id => $awayrecord ) :
// Add away record to totals
$totals[ $team_id ]['awayrecord'] = $awayrecord;
endforeach;
$args = array(
'post_type' => 'sp_column',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
);
$stats = get_posts( $args );
$columns = array();
$this->priorities = array();
foreach ( $stats as $stat ) :
// Get post meta
$meta = get_post_meta( $stat->ID );
// Add equation to object
$stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, null );
$stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 );
// Add column name to columns
$columns[ $stat->post_name ] = $stat->post_title;
// Add order to priorities if priority is set and does not exist in array already
$priority = sp_array_value( sp_array_value( $meta, 'sp_priority', array() ), 0, 0 );
if ( $priority && ! array_key_exists( $priority, $this->priorities ) ) :
$this->priorities[ $priority ] = array(
'column' => $stat->post_name,
'order' => sp_array_value( sp_array_value( $meta, 'sp_order', array() ), 0, 'DESC' ),
);
endif;
endforeach;
// Sort priorities in descending order
ksort( $this->priorities );
// Initialize games back column variable
$gb_column = null;
// Fill in empty placeholder values for each team
foreach ( $team_ids as $team_id ) :
if ( ! $team_id ) {
continue;
}
$placeholders[ $team_id ] = array();
foreach ( $stats as $stat ) :
if ( sp_array_value( sp_array_value( $placeholders, $team_id, array() ), $stat->post_name, '' ) == '' ) :
if ( $stat->equation == null ) :
$placeholder = sp_array_value( sp_array_value( $adjustments, $team_id, array() ), $stat->post_name, null );
if ( $placeholder == null ) :
$placeholder = '-';
endif;
else :
// Solve
$placeholder = sp_solve( $stat->equation, sp_array_value( $totals, $team_id, array() ), $stat->precision, 0, $team_id );
if ( '$gamesback' == $stat->equation ) {
$gb_column = $stat->post_name;
}
if ( ! in_array( $stat->equation, apply_filters( 'sportspress_equation_presets', array( '$gamesback', '$streak', '$form', '$last5', '$last10', '$homerecord', '$awayrecord' ) ) ) ) :
// Adjustments
$adjustment = sp_array_value( $adjustments, $team_id, array() );
if ( $adjustment != 0 ) :
$value = floatval( sp_array_value( $adjustment, $stat->post_name, 0 ) );
$placeholder += $value;
$placeholder = number_format( $placeholder, $stat->precision, '.', '' );
endif;
endif;
endif;
$placeholders[ $team_id ][ $stat->post_name ] = $placeholder;
endif;
endforeach;
endforeach;
// Find win and loss variables for games back
$w = $l = null;
if ( $gb_column ) {
$args = array(
'post_type' => 'sp_outcome',
'numberposts' => 1,
'posts_per_page' => 1,
'meta_query' => array(
array(
'key' => 'sp_condition',
'value' => '>',
),
),
);
$outcomes = get_posts( $args );
if ( $outcomes ) {
$outcome = reset( $outcomes );
if ( is_array( $stats ) ) {
foreach ( $stats as $stat ) {
if ( '$' . $outcome->post_name == $stat->equation ) {
$w = $stat->post_name;
}
}
}
}
// Calculate games back
$args = array(
'post_type' => 'sp_outcome',
'numberposts' => 1,
'posts_per_page' => 1,
'meta_query' => array(
array(
'key' => 'sp_condition',
'value' => '<',
),
),
);
$outcomes = get_posts( $args );
if ( $outcomes ) {
$outcome = reset( $outcomes );
if ( is_array( $stats ) ) {
foreach ( $stats as $stat ) {
if ( '$' . $outcome->post_name == $stat->equation ) {
$l = $stat->post_name;
}
}
}
}
}
// Merge the data and placeholders arrays
$merged = array();
foreach ( $placeholders as $team_id => $team_data ) :
// Add team name to row
$merged[ $team_id ] = array();
$team_data['name'] = sp_team_short_name( $team_id );
foreach ( $team_data as $key => $value ) :
// Use static data if key exists and value is not empty, else use placeholder
if ( array_key_exists( $team_id, $tempdata ) && array_key_exists( $key, $tempdata[ $team_id ] ) && $tempdata[ $team_id ][ $key ] != '' ) :
$value = $tempdata[ $team_id ][ $key ];
endif;
$merged[ $team_id ][ $key ] = $value;
endforeach;
endforeach;
uasort( $merged, array( $this, 'sort' ) );
// Calculate position of teams for ties
foreach ( $merged as $team_id => $team_columns ) {
$merged[ $team_id ]['pos'] = $this->calculate_pos( $team_columns, $team_id );
}
// Head to head table sorting
if ( $is_main_loop && 'h2h' == get_option( 'sportspress_table_tiebreaker', 'none' ) ) {
$order = array();
foreach ( $this->tiebreakers as $pos => $teams ) {
if ( sizeof( $teams ) === 1 ) {
$order[] = reset( $teams );
} else {
$standings = $this->data( false, $teams );
$teams = array_keys( $standings );
foreach ( $teams as $team ) {
$order[] = $team;
}
}
}
$head_to_head = array();
foreach ( $order as $team ) {
$head_to_head[ $team ] = sp_array_value( $merged, $team, array() );
}
$merged = $head_to_head;
// Recalculate position of teams after head to head
$this->pos = 0;
$this->counter = 0;
self::$last_pos = 0;
self::$last_compare = null;
foreach ( $merged as $team_id => $team_columns ) {
$merged[ $team_id ]['pos'] = $this->calculate_pos( $team_columns, $team_id, false );
}
}
// Rearrange the table if Default ordering is not selected
if ( $this->orderby != 'default' ) {
uasort( $merged, array( $this, 'simple_order' ) );
// Recalculate position of teams
$this->pos = 0;
$this->counter = 0;
self::$last_pos = 0;
self::$last_compare = null;
foreach ( $merged as $team_id => $team_columns ) {
$merged[ $team_id ]['pos'] = $this->calculate_pos( $team_columns, $team_id, false );
}
}
// Rearrange data array to reflect values
$data = array();
foreach ( $merged as $key => $value ) :
$data[ $key ] = $tempdata[ $key ];
endforeach;
if ( ! $is_main_loop ) :
return $merged;
elseif ( $admin ) :
$this->add_gb( $placeholders, $w, $l, $gb_column );
return array( $columns, $usecolumns, $data, $placeholders, $merged );
else :
$this->add_gb( $merged, $w, $l, $gb_column );
if ( ! is_array( $usecolumns ) ) {
$usecolumns = array();
}
$labels = array_merge(
array(
'pos' => esc_attr__( 'Pos', 'sportspress' ),
'name' => esc_attr__(
'Team',
'sportspress'
),
),
$columns
);
$merged[0] = $labels;
return $merged;
endif;
}
/**
* Sort the table by priorities.
*
* @param array $a
* @param array $b
* @return int
*/
public function sort( $a, $b ) {
// Loop through priorities
foreach ( $this->priorities as $priority ) :
// Proceed if columns are not equal
if ( sp_array_value( $a, $priority['column'], 0 ) != sp_array_value( $b, $priority['column'], 0 ) ) :
// Compare column values
$output = (float) sp_array_value( $a, $priority['column'], 0 ) - (float) sp_array_value( $b, $priority['column'], 0 );
// Flip value if descending order
if ( $priority['order'] == 'DESC' ) {
$output = 0 - $output;
}
return ( $output > 0 ? 1 : -1 );
endif;
endforeach;
// Default sort by alphabetical
return strcmp( sp_array_value( $a, 'name', '' ), sp_array_value( $b, 'name', '' ) );
}
/**
* Sort the table by ordering.
*
* @param array $a
* @param array $b
* @return int
*/
public function simple_order( $a, $b ) {
if ( $this->orderbyorder == 'DESC' ) {
if ( $this->orderby == 'name' ) {
return strcmp( sp_array_value( $b, 'name', '' ), sp_array_value( $a, 'name', '' ) );
} else {
return (float) $b[ $this->orderby ] - (float) $a[ $this->orderby ];
}
} else {
if ( $this->orderby == 'name' ) {
return strcmp( sp_array_value( $a, 'name', '' ), sp_array_value( $b, 'name', '' ) );
} else {
return (float) $a[ $this->orderby ] - (float) $b[ $this->orderby ];
}
}
}
/**
* Find accurate position of teams.
*
* @param array $columns
* @param int $id
* @return int
*/
public function calculate_pos( $columns, $id = 0, $add_tiebreakers = true ) {
$this->counter++;
$pos = $this->increment( $columns );
if ( $add_tiebreakers ) {
// Initialize tiebreaker position
if ( ! array_key_exists( $this->pos, $this->tiebreakers ) ) {
$this->tiebreakers[ $this->pos ] = array();
}
// Add to tiebreakers
if ( ! in_array( $id, $this->tiebreakers[ $this->pos ] ) ) {
$this->tiebreakers[ $this->pos ][] = $id;
}
}
return $pos;
}
/**
* Increment position as needed (dense ranking).
*
* @param array $columns
* @return int
*/
public function increment( $columns ) {
// First row
if ( self::$last_compare === null ) {
self::$last_pos = 1;
self::$last_compare = $columns;
$this->pos = self::$last_pos;
return $this->pos;
}
// Check if this row differs from the last based on priorities
$different = false;
foreach ( $this->priorities as $priority ) {
$col = $priority['column'];
$val = sp_array_value( $columns, $col, 0 );
$last_val = sp_array_value( self::$last_compare, $col, 0 );
if ( $val !== $last_val ) {
$different = true;
break;
}
}
// Only increment if different
if ( $different ) {
self::$last_pos++;
}
// Update last compared row
self::$last_compare = $columns;
// Assign position
$this->pos = self::$last_pos;
return $this->pos;
}
/**
* Calculate and add games back.
*
* @param array $a
* @param string $w
* @param string $l
* @param string $column
* @return null
*/
public function add_gb( &$a, $w = null, $l = null, $column = null ) {
if ( ! is_array( $a ) ) {
return;
}
if ( ! $w && ! $l ) {
return;
}
foreach ( $a as $team_id => $values ) {
if ( isset( $leader ) ) {
$gb = ( sp_array_value( $leader, $w, 0 ) - sp_array_value( $values, $w, 0 ) + sp_array_value( $values, $l, 0 ) - sp_array_value( $leader, $l, 0 ) ) / 2;
if ( 0 == sp_array_value( $values, $column ) && 0 !== $gb ) {
$a[ $team_id ][ $column ] = $gb;
}
} else {
$leader = $values;
}
}
}
}Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] Player Page EditsFor anyone with the same issue, i was able to edit the event-list.php to remove the unwanted columns and add the event name and event outcomes with only the relevant outcomes related to the player whos profile it is.
I cant work out how to add a column for the total points associated with the specific player in the specific event (associated with only the outcomes listed in the outcome column) however im still working on it.

<?php
/**
* Player Event List with Outcome
*
* Combines simplified Event List (Date + Event) with a per-player Outcome column
*
* @author Crazecollective
* @package SportsPress/Templates
* @version 1.1
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// Ensure $player is set (ID of the player whose profile we are on)
if ( ! isset( $player ) ) {
$player = get_the_ID();
}
// Defaults
$defaults = array(
'id' => null,
'title' => false,
'status' => 'default',
'format' => 'default',
'date' => 'default',
'date_from' => 'default',
'date_to' => 'default',
'date_past' => 'default',
'date_future' => 'default',
'date_relative' => 'default',
'day' => 'default',
'league' => null,
'season' => null,
'venue' => null,
'team' => null,
'teams_past' => null,
'date_before' => null,
'player' => $player,
'number' => -1,
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == '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,
'link_venues' => get_option( 'sportspress_link_venues', 'yes' ) == 'yes' ? true : false,
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'no' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false,
'paginated' => get_option( 'sportspress_event_list_paginated', 'no' ) == 'yes' ? true : false,
'rows' => get_option( 'sportspress_event_list_rows', 10 ),
'order' => 'default',
'columns' => null,
'show_all_events_link' => false,
'show_title' => get_option( 'sportspress_event_list_show_title', 'yes' ) == 'yes' ? true : false,
'title_format' => get_option( 'sportspress_event_list_title_format', 'title' ),
'time_format' => get_option( 'sportspress_event_list_time_format', 'combined' ),
);
extract( $defaults, EXTR_SKIP );
// Get the calendar object
$calendar = new SP_Calendar( $id );
if ( $status != 'default' ) $calendar->status = $status;
if ( $format != 'default' ) $calendar->event_format = $format;
if ( $date != 'default' ) $calendar->date = $date;
if ( $date_from != 'default' ) $calendar->from = $date_from;
if ( $date_to != 'default' ) $calendar->to = $date_to;
if ( $date_past != 'default' ) $calendar->past = $date_past;
if ( $date_future != 'default' ) $calendar->future = $date_future;
if ( $date_relative != 'default' ) $calendar->relative = $date_relative;
if ( $league ) $calendar->league = $league;
if ( $season ) $calendar->season = $season;
if ( $venue ) $calendar->venue = $venue;
if ( $team ) $calendar->team = $team;
if ( $teams_past ) $calendar->teams_past = $teams_past;
if ( $date_before ) $calendar->date_before = $date_before;
if ( $player ) $calendar->player = $player;
if ( $order != 'default' ) $calendar->order = $order;
if ( $day != 'default' ) $calendar->day = $day;
// Get event data
$data = $calendar->data();
$usecolumns = $calendar->columns;
// If columns explicitly set, use those
if ( isset( $columns ) ) :
if ( is_array( $columns ) ) {
$usecolumns = $columns;
} else {
$usecolumns = explode( ',', $columns );
}
endif;
// Add 'outcome' column
$usecolumns[] = 'outcome';
// Title
if ( $show_title && false === $title && $id ) :
$caption = $calendar->caption;
$title = $caption ? $caption : get_the_title( $id );
endif;
$identifier = uniqid( 'eventlist_' );
?>
<div class="sp-template sp-template-event-list">
<!-- ⭐ NEW STATIC WIDGET TITLE ⭐ -->
<h3 class="sp-widget-title" style="margin-bottom: 12px;">Events competed in:</h3>
<!-- End Title -->
<?php if ( $title ) : ?>
<h4 class="sp-table-caption"><?php echo wp_kses_post( $title ); ?></h4>
<?php endif; ?>
<div class="sp-table-wrapper">
<table class="sp-event-list sp-event-list-format-<?php echo esc_attr( $title_format ); ?> sp-data-table
<?php if ( $paginated ) echo ' sp-paginated-table'; ?>
<?php if ( $sortable ) echo ' sp-sortable-table'; ?>
<?php if ( $responsive ) echo ' sp-responsive-table ' . esc_attr( $identifier ); ?>
<?php if ( $scrollable ) echo ' sp-scrollable-table'; ?>" data-sp-rows="<?php echo esc_attr( $rows ); ?>">
<thead>
<tr>
<th class="data-date"><?php esc_html_e( 'Date', 'sportspress' ); ?></th>
<th class="data-event"><?php esc_html_e( 'Event', 'sportspress' ); ?></th>
<th class="data-outcome"><?php esc_html_e( 'Outcome', 'sportspress' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
if ( is_numeric( $number ) && $number > 0 ) $limit = $number;
foreach ( $data as $event ) :
if ( isset( $limit ) && $i >= $limit ) continue;
$event_obj = new SP_Event( $event->ID );
// Date
$date_html = get_post_time( get_option( 'date_format' ), false, $event, true );
if ( $link_events ) {
$date_html = '<a href="' . get_post_permalink( $event->ID ) . '">' . $date_html . '</a>';
}
// Event title
$teams = get_post_meta( $event->ID, 'sp_team' );
$team_logos = array();
if ( $teams && $show_team_logo ) {
foreach ( $teams as $t ) {
if ( has_post_thumbnail( $t ) ) {
$team_logos[] = '<span class="team-logo">' . sp_get_logo( $t, 'mini' ) . '</span>';
}
}
}
$title_html = implode( ' ', $team_logos ) . ' ' . $event->post_title;
if ( $link_events ) $title_html = '<a href="' . get_post_permalink( $event->ID ) . '">' . $title_html . '</a>';
// Outcome
$outcome = '—';
$event_results = $event_obj->results();
foreach ( $event_results as $competitor_id => $result ) {
if ( (int) $competitor_id === (int) $player ) {
$player_outcome = sp_array_value( $result, 'outcome' );
if ( is_array( $player_outcome ) ) {
$outcomes = array();
foreach ( $player_outcome as $oc ) {
$the_outcome = get_page_by_path( $oc, OBJECT, 'sp_outcome' );
if ( is_object( $the_outcome ) ) {
$outcomes[] = $the_outcome->post_title;
}
}
$outcome = implode( ', ', $outcomes );
}
break;
}
}
?>
<tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>">
<td class="data-date"><?php echo wp_kses_post( $date_html ); ?></td>
<td class="data-event"><?php echo wp_kses_post( $title_html ); ?></td>
<td class="data-outcome"><?php echo wp_kses_post( $outcome ); ?></td>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<?php if ( $id && $show_all_events_link ) : ?>
<div class="sp-calendar-link sp-view-all-link">
<a href="<?php echo esc_url( get_permalink( $id ) ); ?>"><?php esc_html_e( 'View all events', 'sportspress' ); ?></a>
</div>
<?php endif; ?>
</div>Heres the code with just the event names (with clickable link into the event) and no outcome column.
<?php
/**
* Player Event List (Date + Event only)
*
* Removed Outcome column completely
*
* @author Crazecollective
* @package SportsPress/Templates
* @version 1.2
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// Ensure $player is set (ID of the player whose profile we are on)
if ( ! isset( $player ) ) {
$player = get_the_ID();
}
// Defaults
$defaults = array(
'id' => null,
'title' => false,
'status' => 'default',
'format' => 'default',
'date' => 'default',
'date_from' => 'default',
'date_to' => 'default',
'date_past' => 'default',
'date_future' => 'default',
'date_relative' => 'default',
'day' => 'default',
'league' => null,
'season' => null,
'venue' => null,
'team' => null,
'teams_past' => null,
'date_before' => null,
'player' => $player,
'number' => -1,
'show_team_logo' => get_option( 'sportspress_event_list_show_logos', 'no' ) == '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,
'link_venues' => get_option( 'sportspress_link_venues', 'yes' ) == 'yes' ? true : false,
'responsive' => get_option( 'sportspress_enable_responsive_tables', 'no' ) == 'yes' ? true : false,
'sortable' => get_option( 'sportspress_enable_sortable_tables', 'yes' ) == 'yes' ? true : false,
'scrollable' => get_option( 'sportspress_enable_scrollable_tables', 'yes' ) == 'yes' ? true : false,
'paginated' => get_option( 'sportspress_event_list_paginated', 'no' ) == 'yes' ? true : false,
'rows' => get_option( 'sportspress_event_list_rows', 10 ),
'order' => 'default',
'columns' => null,
'show_all_events_link' => false,
'show_title' => get_option( 'sportspress_event_list_show_title', 'yes' ) == 'yes' ? true : false,
'title_format' => get_option( 'sportspress_event_list_title_format', 'title' ),
'time_format' => get_option( 'sportspress_event_list_time_format', 'combined' ),
);
extract( $defaults, EXTR_SKIP );
// Get the calendar object
$calendar = new SP_Calendar( $id );
if ( $status != 'default' ) $calendar->status = $status;
if ( $format != 'default' ) $calendar->event_format = $format;
if ( $date != 'default' ) $calendar->date = $date;
if ( $date_from != 'default' ) $calendar->from = $date_from;
if ( $date_to != 'default' ) $calendar->to = $date_to;
if ( $date_past != 'default' ) $calendar->past = $date_past;
if ( $date_future != 'default' ) $calendar->future = $date_future;
if ( $date_relative != 'default' ) $calendar->relative = $date_relative;
if ( $league ) $calendar->league = $league;
if ( $season ) $calendar->season = $season;
if ( $venue ) $calendar->venue = $venue;
if ( $team ) $calendar->team = $team;
if ( $teams_past ) $calendar->teams_past = $teams_past;
if ( $date_before ) $calendar->date_before = $date_before;
if ( $player ) $calendar->player = $player;
if ( $order != 'default' ) $calendar->order = $order;
if ( $day != 'default' ) $calendar->day = $day;
// Get event data
$data = $calendar->data();
$usecolumns = $calendar->columns;
// Explicit columns override
if ( isset( $columns ) ) :
if ( is_array( $columns ) ) {
$usecolumns = $columns;
} else {
$usecolumns = explode( ',', $columns );
}
endif;
// REMOVE outcome column completely
if ( ( $key = array_search( 'outcome', $usecolumns ) ) !== false ) {
unset( $usecolumns[ $key ] );
}
// Title
if ( $show_title && false === $title && $id ) :
$caption = $calendar->caption;
$title = $caption ? $caption : get_the_title( $id );
endif;
$identifier = uniqid( 'eventlist_' );
?>
<div class="sp-template sp-template-event-list">
<h3 class="sp-widget-title" style="margin-bottom: 15px;">Events competed in</h3>
<?php if ( $title ) : ?>
<h4 class="sp-table-caption"><?php echo wp_kses_post( $title ); ?></h4>
<?php endif; ?>
<div class="sp-table-wrapper">
<table class="sp-event-list sp-event-list-format-<?php echo esc_attr( $title_format ); ?> sp-data-table
<?php if ( $paginated ) echo ' sp-paginated-table'; ?>
<?php if ( $sortable ) echo ' sp-sortable-table'; ?>
<?php if ( $responsive ) echo ' sp-responsive-table ' . esc_attr( $identifier ); ?>
<?php if ( $scrollable ) echo ' sp-scrollable-table'; ?>" data-sp-rows="<?php echo esc_attr( $rows ); ?>">
<thead>
<tr>
<th class="data-date"><?php esc_html_e( 'Date', 'sportspress' ); ?></th>
<th class="data-event"><?php esc_html_e( 'Event', 'sportspress' ); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
if ( is_numeric( $number ) && $number > 0 ) $limit = $number;
foreach ( $data as $event ) :
if ( isset( $limit ) && $i >= $limit ) continue;
$event_obj = new SP_Event( $event->ID );
// Date
$date_html = get_post_time( get_option( 'date_format' ), false, $event, true );
if ( $link_events ) {
$date_html = '<a href="' . get_post_permalink( $event->ID ) . '">' . $date_html . '</a>';
}
// Event title with optional logos
$teams = get_post_meta( $event->ID, 'sp_team' );
$team_logos = array();
if ( $teams && $show_team_logo ) {
foreach ( $teams as $t ) {
if ( has_post_thumbnail( $t ) ) {
$team_logos[] = '<span class="team-logo">' . sp_get_logo( $t, 'mini' ) . '</span>';
}
}
}
$title_html = implode( ' ', $team_logos ) . ' ' . $event->post_title;
if ( $link_events ) $title_html = '<a href="' . get_post_permalink( $event->ID ) . '">' . $title_html . '</a>';
?>
<tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>">
<td class="data-date"><?php echo wp_kses_post( $date_html ); ?></td>
<td class="data-event"><?php echo wp_kses_post( $title_html ); ?></td>
</tr>
<?php
$i++;
endforeach;
?>
</tbody>
</table>
</div>
<?php if ( $id && $show_all_events_link ) : ?>
<div class="sp-calendar-link sp-view-all-link">
<a href="<?php echo esc_url( get_permalink( $id ) ); ?>"><?php esc_html_e( 'View all events', 'sportspress' ); ?></a>
</div>
<?php endif; ?>
</div>Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] Player Page Editsit seems that if i check the ‘total’ box, it does show the total points from all seasons added together but then it also shows the individual leagues, there doesnt seem to be a way to have the total shown but without the leagues showing. Plus the leagues still dont seem to show any information.
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] Event Result Page EditsI put the query monitor error and the whole php code into chat gpt and it told me to replace this portion of the code with the below code. Is this correct?
public function delimiter_setting() {
$selection = get_option( 'sportspress_event_teams_delimiter', 'vs' );
$limit = intval( get_option( 'sportspress_event_teams', 2 ) );
if ( $limit <= 0 ) {
$limit = 2;
}
if ( $limit <= 3 ) {
$example = str_repeat( esc_attr__( 'Team', 'sportspress' ) . ' %1$s ', $limit );
} else {
$example = str_repeat( esc_attr__( 'Team', 'sportspress' ) . ' %1$s ', 3 ) . '…';
}
$example = rtrim( $example, ' %1$s ' );
?>It seems to be working fine, the error has disappeared from the back end and i am able to edit and save the settings now, front end looks the same.
- This reply was modified 6 months, 1 week ago by Craze Collective.
- This reply was modified 6 months, 1 week ago by Craze Collective.
I want to implement teams in the future so its probably not a good idea to create every player as a team.
I was using player lists for the previous leaderboard, i have just noticed that i can reenter the equation so that it displays the same stats but via a league table which is where your settings suggestion helps.
Is there a way to change its current setup so instead of going 1 2 3,3,3, 6 it goes 1 2 3,3,3, 4?
- This reply was modified 6 months, 1 week ago by Craze Collective.
- This reply was modified 6 months, 1 week ago by Craze Collective.
Hi Savvas, thanks for your help!
I did not have pos – always increment checked however i have now checked it and it doesnt seem to make any difference whatsoever.
I have also changed tiebreaker from none to head to head and this doesnt seem to have any noticable difference on the front end either.
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] Event Result Page EditsThanks for your help! This is the message displayed by query monitor.
Forum: Plugins
In reply to: [SportsPress - Sports Club & League Manager] Player Page EditsUpdate: i was able to fix the issues in 1., I had to edit each players individual profile and check the boxes alongside the season in the career total section.
Is there a bulk way to do this when we move to the next season? Rather than needing to edit every player profile again.

I then unchecked total and left career total checked in settings > players. This removed the league breakdowns and kept the overall career total.

Is there a way to have a final row below career total that adds the points from each season together?
For example, the below page would show a total of 72 points.

- This reply was modified 6 months, 1 week ago by Craze Collective.