diff --git a/admin/hooks/manage-posts-columns.php b/admin/hooks/manage-posts-columns.php
index 46e122e9..25830bca 100644
--- a/admin/hooks/manage-posts-columns.php
+++ b/admin/hooks/manage-posts-columns.php
@@ -29,12 +29,28 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
break;
elseif ( $post_type == 'sp_event' ):
$results = get_post_meta( $post_id, 'sp_results', true );
+ $options = get_option( 'sportspress' );
+ $main_result = sportspress_array_value( $options, 'main_result', null );
foreach( $teams as $team_id ):
if ( ! $team_id ) continue;
$team = get_post( $team_id );
- $outcome_slug = sportspress_array_value( sportspress_array_value( $results, $team_id, null ), 'outcome', null );
echo $team->post_title;
+
+ $team_results = sportspress_array_value( $results, $team_id, null );
+
+ if ( $main_result ):
+ $team_result = sportspress_array_value( $team_results, $main_result, null );
+ else:
+ end( $team_results );
+ $team_result = prev( $team_results );
+ endif;
+
+ if ( $team_result != null ):
+ echo ' — ' . $team_result;
+ endif;
+
+ $outcome_slug = sportspress_array_value( $team_results, 'outcome', null );
if ( $outcome_slug && $outcome_slug != '-1' ):
$args=array(
'name' => $outcome_slug,
@@ -46,9 +62,10 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
if ( sizeof( $outcomes ) ):
$outcome = reset( $outcomes );
- echo ' — ' . $outcome->post_title;
+ echo ' (' . $outcome->post_title . ')';
endif;
endif;
+
echo ' ';
endforeach;
elseif ( $post_type == 'sp_player' ):
diff --git a/admin/includes/notice-theme-support.php b/admin/includes/notice-theme-support.php
index 45662965..cbeb37e2 100644
--- a/admin/includes/notice-theme-support.php
+++ b/admin/includes/notice-theme-support.php
@@ -1,6 +1,7 @@
+
Your theme does not declare SportsPress support – if you encounter layout issues please read our integration guide or choose a SportsPress theme :)', 'sportspress' ); ?>
@@ -8,3 +9,4 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
+ '$l',
),
),
+ array(
+ 'post_title' => 'T',
+ 'post_name' => 't',
+ 'meta' => array(
+ 'sp_equation' => '$t',
+ ),
+ ),
array(
'post_title' => 'Pct',
'post_name' => 'pct',
@@ -31,26 +38,123 @@ $sportspress_sports['football'] = array(
'post_title' => 'PF',
'post_name' => 'pf',
'meta' => array(
- 'sp_equation' => '$ptsfor',
+ 'sp_equation' => '$pointsfor',
),
),
array(
'post_title' => 'PA',
'post_name' => 'pa',
'meta' => array(
- 'sp_equation' => '$ptsagainst',
+ 'sp_equation' => '$pointsagainst',
),
),
array(
- 'post_title' => 'Str',
+ 'post_title' => 'Net Pts',
+ 'post_name' => 'netpts',
+ 'meta' => array(
+ 'sp_equation' => '$pointsfor - $pointsagainst',
+ ),
+ ),
+ array(
+ 'post_title' => 'TD',
+ 'post_name' => 'td',
+ 'meta' => array(
+ 'sp_equation' => '$touchdown',
+ ),
+ ),
+ array(
+ 'post_title' => 'Strk',
'post_name' => 'strk',
'meta' => array(
'sp_equation' => '$streak',
),
),
+ array(
+ 'post_title' => 'Last 5',
+ 'post_name' => 'last5',
+ 'meta' => array(
+ 'sp_equation' => '$last5',
+ ),
+ ),
),
// Statistics
'sp_statistic' => array(
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp', // QB
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
+ array(
+ 'post_title' => 'Comp',
+ 'post_name' => 'comp',
+ ),
),
// Results
'sp_result' => array(
diff --git a/admin/settings/events.php b/admin/settings/events.php
index 199da2a2..7f956c80 100644
--- a/admin/settings/events.php
+++ b/admin/settings/events.php
@@ -1,4 +1,9 @@
+
'sp_result',
'numberposts' => -1,
diff --git a/admin/settings/general.php b/admin/settings/general.php
index 0e47f813..e45a3e8d 100644
--- a/admin/settings/general.php
+++ b/admin/settings/general.php
@@ -1,5 +1,5 @@
$sport ): ?>
- >
+ >
'sp_result',
+ 'name' => 'sportspress[main_result]',
+ 'show_option_all' => __( '(Auto)', 'sportspress' ),
+ 'selected' => $selected,
+ 'values' => 'slug',
+ );
+ sportspress_dropdown_pages( $args );
+}
+
function sportspress_team_stats_callback() {
sportspress_render_option_field( 'sportspress_stats', 'team', 'textarea' );
}
@@ -88,8 +104,7 @@ function sportspress_settings_init() {
// Event Settings
register_setting(
'sportspress_events',
- 'sportspress',
- 'sportspress_validate'
+ 'sportspress'
);
add_settings_section(
@@ -100,9 +115,9 @@ function sportspress_settings_init() {
);
add_settings_field(
- 'sport',
- __( 'Sport', 'sportspress' ),
- 'sportspress_sport_callback',
+ 'result',
+ __( 'Main Result', 'sportspress' ),
+ 'sportspress_result_callback',
'sportspress_events',
'events'
);
diff --git a/admin/templates/countdown.php b/admin/templates/countdown.php
index 45ff8e6f..26a3b60f 100644
--- a/admin/templates/countdown.php
+++ b/admin/templates/countdown.php
@@ -37,13 +37,13 @@ if ( !function_exists( 'sportspress_countdown' ) ) {
$now = new DateTime( current_time( 'mysql', 0 ) );
$date = new DateTime( $post->post_date );
- $interval = $date->diff( $now );
+ $interval = date_diff( $now, $date );
$output .= '' .
- '' . sprintf( '%02s', $interval->d ) . ' ' . __( 'days', 'sportspress' ) . ' ' .
- '' . sprintf( '%02s', $interval->h ) . ' ' . __( 'hours', 'sportspress' ) . ' ' .
- '' . sprintf( '%02s', $interval->i ) . ' ' . __( 'mins', 'sportspress' ) . ' ' .
- '' . sprintf( '%02s', $interval->s ) . ' ' . __( 'secs', 'sportspress' ) . ' ' .
+ '' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->d ) ) . ' ' . __( 'days', 'sportspress' ) . ' ' .
+ '' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' ' . __( 'hours', 'sportspress' ) . ' ' .
+ '' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' ' . __( 'mins', 'sportspress' ) . ' ' .
+ '' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' ' . __( 'secs', 'sportspress' ) . ' ' .
' ';
$output .= '';
diff --git a/admin/widgets/countdown.php b/admin/widgets/countdown.php
index 1ba01652..5faba94f 100644
--- a/admin/widgets/countdown.php
+++ b/admin/widgets/countdown.php
@@ -40,7 +40,7 @@ class SP_Widget_Countdown extends WP_Widget {
'name' => $this->get_field_name('id'),
'id' => $this->get_field_id('id'),
'selected' => $id,
- 'show_option_all' => '(' . __( 'Next Event', 'premier' ) . ')',
+ 'show_option_all' => __( '(Auto)', 'sportspress' ),
'values' => 'ID',
'class' => 'widefat',
'show_dates' => true,
diff --git a/functions.php b/functions.php
index 0c45fce4..95a8951f 100644
--- a/functions.php
+++ b/functions.php
@@ -491,6 +491,7 @@ if ( !function_exists( 'sportspress_equation_selector' ) ) {
case 'outcome':
$options[ __( 'Outcomes', 'sportspress' ) ] = sportspress_get_equation_optgroup_array( $postid, 'sp_outcome', array( 'max' => '↑', 'min' => '↓' ) );
$options[ __( 'Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
+ $options[ __( 'Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
$options[ __( 'Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
break;
case 'column':
@@ -1151,6 +1152,16 @@ if ( !function_exists( 'sportspress_solve' ) ) {
// Return direct value
return sportspress_array_value( $vars, 'streak', 0 );
+ elseif ( str_replace( ' ', '', $equation ) == '$last5' ):
+
+ // Return imploded string
+ $last5 = sportspress_array_value( $vars, 'last5', array( 0 ) );
+ if ( array_sum( $last5 ) > 0 ):
+ return implode( '-', $last5 );
+ else:
+ return '—';
+ endif;
+
elseif ( str_replace( ' ', '', $equation ) == '$last10' ):
// Return imploded string
@@ -1306,7 +1317,7 @@ if ( !function_exists( 'sportspress_get_team_columns_data' ) ) {
foreach ( $div_ids as $div_id ):
- $totals = array( 'eventsplayed' => 0, 'streak' => 0, 'last10' => null );
+ $totals = array( 'eventsplayed' => 0, 'streak' => 0, 'last5' => null, 'last10' => null );
foreach ( $result_labels as $key => $value ):
$totals[ $key . 'for' ] = 0;
@@ -1320,11 +1331,13 @@ if ( !function_exists( 'sportspress_get_team_columns_data' ) ) {
// Initialize streaks counter
$streak = array( 'name' => '', 'count' => 0, 'fire' => 1 );
- // Initialize last 10 counter
+ // Initialize last counters
+ $last5 = array();
$last10 = array();
- // Add outcome types to last 10 counter
+ // Add outcome types to last counters
foreach( $outcome_labels as $key => $value ):
+ $last5[ $key ] = 0;
$last10[ $key ] = 0;
endforeach;
@@ -1379,6 +1392,11 @@ if ( !function_exists( 'sportspress_get_team_columns_data' ) ) {
$streak['fire'] = 0;
endif;
+ // Add to last 5 counter if sum is less than 5
+ if ( array_key_exists( $value, $last5 ) && array_sum( $last5 ) < 5 ):
+ $last5[ $value ] ++;
+ endif;
+
// Add to last 10 counter if sum is less than 10
if ( array_key_exists( $value, $last10 ) && array_sum( $last10 ) < 10 ):
$last10[ $value ] ++;
@@ -1416,7 +1434,8 @@ if ( !function_exists( 'sportspress_get_team_columns_data' ) ) {
$totals['streak'] = $outcome->post_title . $streak['count'];
endif;
- // Add last 10 to totals
+ // Add last counters to totals
+ $totals['last5'] = $last5;
$totals['last10'] = $last10;
// Generate array of placeholder values for each league
@@ -1497,7 +1516,8 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
// Initialize streaks counter
$streaks = array();
- // Initialize last 10s counter
+ // Initialize last counters
+ $last5s = array();
$last10s = array();
foreach ( $team_ids as $team_id ):
@@ -1507,11 +1527,13 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
// Initialize team streaks counter
$streaks[ $team_id ] = array( 'name' => '', 'count' => 0, 'fire' => 1 );
- // Initialize team last 10 counter
+ // Initialize team last counters
+ $last5s[ $team_id ] = array();
$last10s[ $team_id ] = array();
- // Add outcome types to team last 10 counter
+ // Add outcome types to team last counters
foreach( $outcome_labels as $key => $value ):
+ $last5s[ $team_id ][ $key ] = 0;
$last10s[ $team_id ][ $key ] = 0;
endforeach;
@@ -1586,6 +1608,11 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
$streaks[ $team_id ]['fire'] = 0;
endif;
+ // Add to last 5 counter if sum is less than 5
+ if ( array_key_exists( $team_id, $last5s ) && array_key_exists( $value, $last5s[ $team_id ] ) && array_sum( $last5s[ $team_id ] ) < 5 ):
+ $last5s[ $team_id ][ $value ] ++;
+ endif;
+
// Add to last 10 counter if sum is less than 10
if ( array_key_exists( $team_id, $last10s ) && array_key_exists( $value, $last10s[ $team_id ] ) && array_sum( $last10s[ $team_id ] ) < 10 ):
$last10s[ $team_id ][ $value ] ++;
@@ -1632,6 +1659,11 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
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;
diff --git a/readme.txt b/readme.txt
index ee1d4f06..7f1458a4 100644
--- a/readme.txt
+++ b/readme.txt
@@ -74,9 +74,11 @@ SportsPress is currently in beta and is undergoing testing. We are still activel
= 0.2.2 =
* Feature - League Table widget added.
-* Feature - Events widget added.
+* Feature - Recent Events widget added.
+* Feature - Future Events widget added.
* Feature - Countdown widget added.
* Fix - Syntax error fixed for PHP version 5.2 and below.
+* Tweak - Editor section added to League Tables and Player Lists.
= 0.2.1 =
* Feature - Events Calendar widget added.