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' ),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user