Add full time minutes to events
This commit is contained in:
@@ -31,34 +31,31 @@ class SP_Meta_Box_Equation {
|
||||
foreach ( $groups as $group ):
|
||||
switch ( $group ):
|
||||
case 'player_event':
|
||||
$options['Events'] = array( '$eventsattended' => __( 'Attended', 'sportspress' ), '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventsstarted' => __( 'Started', 'sportspress' ), '$eventssubbed' => __( 'Substituted', 'sportspress' ) );
|
||||
$options[ __( 'Events', 'sportspress' ) ] = array( '$eventsattended' => __( 'Attended', 'sportspress' ), '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventsstarted' => __( 'Started', 'sportspress' ), '$eventssubbed' => __( 'Substituted', 'sportspress' ), '$eventminutes' => __( 'Minutes', 'sportspress' ) );
|
||||
break;
|
||||
case 'team_event':
|
||||
$options['Events'] = array( '$eventsplayed' => __( 'Played', 'sportspress' ) );
|
||||
$options[ __( 'Events', 'sportspress' ) ] = array( '$eventsplayed' => __( 'Played', 'sportspress' ), '$eventminutes' => __( 'Minutes', 'sportspress' ) );
|
||||
break;
|
||||
case 'result':
|
||||
$options['Results'] = self::optgroup( 'sp_result', array( 'for' => '(' . __( 'for', 'sportspress' ) . ')', 'against' => '(' . __( 'against', 'sportspress' ) . ')' ), null, false );
|
||||
$options[ __( 'Results', 'sportspress' ) ] = self::optgroup( 'sp_result', array( 'for' => '(' . __( 'for', 'sportspress' ) . ')', 'against' => '(' . __( 'against', 'sportspress' ) . ')' ), null, false );
|
||||
break;
|
||||
case 'outcome':
|
||||
$options['Outcomes'] = self::optgroup( 'sp_outcome' );
|
||||
$options['Outcomes']['$streak'] = __( 'Streak', 'sportspress' );
|
||||
$options['Outcomes']['$last5'] = __( 'Last 5', 'sportspress' );
|
||||
$options['Outcomes']['$last10'] = __( 'Last 10', 'sportspress' );
|
||||
$options[ __( 'Outcomes', 'sportspress' ) ] = self::optgroup( 'sp_outcome' );
|
||||
$options[ __( 'Outcomes', 'sportspress' ) ]['$streak'] = __( 'Streak', 'sportspress' );
|
||||
$options[ __( 'Outcomes', 'sportspress' ) ]['$last5'] = __( 'Last 5', 'sportspress' );
|
||||
$options[ __( 'Outcomes', 'sportspress' ) ]['$last10'] = __( 'Last 10', 'sportspress' );
|
||||
break;
|
||||
case 'performance':
|
||||
$options['Performance'] = self::optgroup( 'sp_performance' );
|
||||
$options[ __( 'Performance', 'sportspress' ) ] = self::optgroup( 'sp_performance' );
|
||||
break;
|
||||
case 'metric':
|
||||
$options['Metric'] = self::optgroup( 'sp_metric' );
|
||||
$options[ __( 'Metric', 'sportspress' ) ] = self::optgroup( 'sp_metric' );
|
||||
break;
|
||||
endswitch;
|
||||
endforeach;
|
||||
|
||||
// Create array of operators
|
||||
$operators = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
|
||||
|
||||
// Add operators to options
|
||||
$options['Operators'] = $operators;
|
||||
$options[ __( 'Operators', 'sportspress' ) ] = array( '+' => '+', '-' => '−', '*' => '×', '/' => '÷', '(' => '(', ')' => ')' );
|
||||
|
||||
// Create array of constants
|
||||
$max = 10;
|
||||
@@ -71,7 +68,9 @@ class SP_Meta_Box_Equation {
|
||||
$constants[100] = 100;
|
||||
|
||||
// Add constants to options
|
||||
$options['Constants'] = (array) $constants;
|
||||
$options[ __( 'Constants', 'sportspress' ) ] = (array) $constants;
|
||||
|
||||
$options = apply_filters( 'sportspress_equation_options', $options );
|
||||
?>
|
||||
<div class="sp-equation-builder">
|
||||
<div class="sp-data-table-container sp-equation-parts">
|
||||
|
||||
@@ -19,10 +19,18 @@ class SP_Meta_Box_Event_Details {
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$minutes = get_post_meta( $post->ID, 'sp_minutes', true );
|
||||
$league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||
$season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$venue_id = sp_get_the_term_id( $post->ID, 'sp_venue', 0 );
|
||||
?>
|
||||
<div class="sp-event-minutes-field">
|
||||
<p><strong><?php _e( 'Full Time', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<input name="sp_minutes" type="number" step="1" min="0" class="small-text" placeholder="<?php echo get_option( 'sportspress_event_minutes', 90 ); ?>" value="<?php echo $minutes; ?>">
|
||||
<?php _e( 'mins', 'sportspress' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="sp-event-league-field">
|
||||
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
@@ -83,6 +91,7 @@ class SP_Meta_Box_Event_Details {
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_minutes', sp_array_value( $_POST, 'sp_minutes', get_option( 'sportspress_event_minutes', 90 ) ) );
|
||||
$format = get_post_meta( $post_id, 'sp_format', true );
|
||||
if ( $format == 'friendly' )
|
||||
wp_set_post_terms( $post_id, -1, 'sp_league' );
|
||||
|
||||
@@ -126,6 +126,19 @@ class SP_Settings_Events extends SP_Settings_Page {
|
||||
'type' => 'checkbox',
|
||||
'checkboxgroup' => 'start',
|
||||
),
|
||||
|
||||
array(
|
||||
'title' => __( 'Full Time', 'sportspress' ),
|
||||
'id' => 'sportspress_event_minutes',
|
||||
'class' => 'small-text',
|
||||
'default' => '90',
|
||||
'desc' => __( 'mins', 'sportspress' ),
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array(
|
||||
'min' => 0,
|
||||
'step' => 1
|
||||
),
|
||||
),
|
||||
|
||||
array( 'type' => 'sectionend', 'id' => 'event_options' ),
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class SP_League_Table extends SP_Custom_Post{
|
||||
endforeach;
|
||||
|
||||
// Initialize team totals
|
||||
$totals[ $team_id ] = array( 'eventsplayed' => 0, 'streak' => 0 );
|
||||
$totals[ $team_id ] = array( 'eventsplayed' => 0, 'eventminutes' => 0, 'streak' => 0 );
|
||||
|
||||
foreach ( $result_labels as $key => $value ):
|
||||
$totals[ $team_id ][ $key . 'for' ] = 0;
|
||||
@@ -120,6 +120,8 @@ class SP_League_Table extends SP_Custom_Post{
|
||||
foreach ( $events as $event ):
|
||||
|
||||
$results = (array)get_post_meta( $event->ID, 'sp_results', true );
|
||||
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
|
||||
if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 );
|
||||
|
||||
foreach ( $results as $team_id => $team_result ):
|
||||
|
||||
@@ -138,8 +140,9 @@ class SP_League_Table extends SP_Custom_Post{
|
||||
|
||||
// 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 ][ $outcome ]++;
|
||||
$totals[ $team_id ]['eventsplayed'] ++;
|
||||
$totals[ $team_id ]['eventminutes'] += $minutes;
|
||||
$totals[ $team_id ][ $outcome ] ++;
|
||||
endif;
|
||||
|
||||
if ( $outcome && $outcome != '-1' ):
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* The SportsPress player list class handles individual player list data.
|
||||
*
|
||||
* @class SP_Player_List
|
||||
* @version 1.2.6
|
||||
* @version 1.3
|
||||
* @package SportsPress/Classes
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
@@ -84,7 +84,7 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
endforeach;
|
||||
|
||||
// Initialize player totals
|
||||
$totals[ $player_id ] = array( 'eventsattended' => 0, 'eventsplayed' => 0, 'eventsstarted' => 0, 'eventssubbed' => 0, 'streak' => 0 );
|
||||
$totals[ $player_id ] = array( 'eventsattended' => 0, 'eventsplayed' => 0, 'eventsstarted' => 0, 'eventssubbed' => 0, 'eventminutes' => 0, 'streak' => 0 );
|
||||
|
||||
foreach ( $performance_labels as $key => $value ):
|
||||
$totals[ $player_id ][ $key ] = 0;
|
||||
@@ -143,6 +143,8 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
foreach ( $events as $event ):
|
||||
$results = (array)get_post_meta( $event->ID, 'sp_results', true );
|
||||
$team_performance = get_post_meta( $event->ID, 'sp_players', true );
|
||||
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
|
||||
if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 );
|
||||
|
||||
// Add all team performance
|
||||
if ( is_array( $team_performance ) ): foreach ( $team_performance as $team_id => $players ):
|
||||
@@ -163,16 +165,17 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
if ( array_key_exists( 'outcome', $team_results ) ):
|
||||
|
||||
// Increment events attended
|
||||
$totals[ $player_id ]['eventsattended']++;
|
||||
$totals[ $player_id ]['eventsattended'] ++;
|
||||
|
||||
// Continue with incrementing values if active in event
|
||||
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals[ $player_id ]['eventsplayed']++;
|
||||
$totals[ $player_id ]['eventsplayed'] ++;
|
||||
$totals[ $player_id ]['eventminutes'] += $minutes;
|
||||
|
||||
if ( sp_array_value( $player_performance, 'status' ) == 'lineup' ):
|
||||
$totals[ $player_id ]['eventsstarted']++;
|
||||
$totals[ $player_id ]['eventsstarted'] ++;
|
||||
elseif ( sp_array_value( $player_performance, 'status' ) == 'sub' && sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals[ $player_id ]['eventssubbed']++;
|
||||
$totals[ $player_id ]['eventssubbed'] ++;
|
||||
endif;
|
||||
|
||||
$value = $team_results['outcome'];
|
||||
@@ -188,7 +191,7 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
|
||||
// Increment events attended and outcome count
|
||||
if ( array_key_exists( $outcome, $totals[ $player_id ] ) ):
|
||||
$totals[ $player_id ][ $outcome ]++;
|
||||
$totals[ $player_id ][ $outcome ] ++;
|
||||
endif;
|
||||
|
||||
// Add to streak counter
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* The SportsPress player class handles individual player data.
|
||||
*
|
||||
* @class SP_Player
|
||||
* @version 0.8.1
|
||||
* @version 1.3
|
||||
* @package SportsPress/Classes
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
@@ -99,7 +99,7 @@ class SP_Player extends SP_Custom_Post {
|
||||
|
||||
foreach ( $div_ids as $div_id ):
|
||||
|
||||
$totals = array( 'eventsattended' => 0, 'eventsplayed' => 0, 'eventsstarted' => 0, 'eventssubbed' => 0, 'streak' => 0, 'last5' => null, 'last10' => null );
|
||||
$totals = array( 'eventsattended' => 0, 'eventsplayed' => 0, 'eventsstarted' => 0, 'eventssubbed' => 0, 'eventminutes' => 0, 'streak' => 0, 'last5' => null, 'last10' => null );
|
||||
|
||||
foreach ( $performance_labels as $key => $value ):
|
||||
$totals[ $key ] = 0;
|
||||
@@ -166,6 +166,8 @@ class SP_Player extends SP_Custom_Post {
|
||||
foreach( $events as $event ):
|
||||
$results = (array)get_post_meta( $event->ID, 'sp_results', true );
|
||||
$team_performance = (array)get_post_meta( $event->ID, 'sp_players', true );
|
||||
$minutes = get_post_meta( $event->ID, 'sp_minutes', true );
|
||||
if ( $minutes === '' ) $minutes = get_option( 'sportspress_event_minutes', 90 );
|
||||
|
||||
// Add all team performance
|
||||
foreach ( $team_performance as $team_id => $players ):
|
||||
@@ -185,16 +187,17 @@ class SP_Player extends SP_Custom_Post {
|
||||
if ( array_key_exists( 'outcome', $team_results ) ):
|
||||
|
||||
// Increment events attended
|
||||
$totals['eventsattended']++;
|
||||
$totals['eventsattended'] ++;
|
||||
|
||||
// Continue with incrementing values if active in event
|
||||
if ( sp_array_value( $player_performance, 'status' ) != 'sub' || sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals['eventsplayed']++;
|
||||
$totals['eventsplayed'] ++;
|
||||
$totals['eventminutes'] += $minutes;
|
||||
|
||||
if ( sp_array_value( $player_performance, 'status' ) == 'lineup' ):
|
||||
$totals['eventsstarted']++;
|
||||
$totals['eventsstarted'] ++;
|
||||
elseif ( sp_array_value( $player_performance, 'status' ) == 'sub' && sp_array_value( $player_performance, 'sub', 0 ) ):
|
||||
$totals['eventssubbed']++;
|
||||
$totals['eventssubbed'] ++;
|
||||
endif;
|
||||
|
||||
$value = $team_results['outcome'];
|
||||
@@ -209,7 +212,7 @@ class SP_Player extends SP_Custom_Post {
|
||||
|
||||
// Increment outcome count
|
||||
if ( array_key_exists( $outcome, $totals ) ):
|
||||
$totals[ $outcome ]++;
|
||||
$totals[ $outcome ] ++;
|
||||
endif;
|
||||
|
||||
// Add to streak counter
|
||||
|
||||
Reference in New Issue
Block a user