Add main result, last 5 counter, and fix countdown direction
This commit is contained in:
@@ -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 '<br>';
|
||||
endforeach;
|
||||
elseif ( $post_type == 'sp_player' ):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
?>
|
||||
<?php if ( false ): ?>
|
||||
<div id="message" class="error sportspress-message">
|
||||
<h4><?php _e( '<strong>Your theme does not declare SportsPress support</strong> – if you encounter layout issues please read our integration guide or choose a SportsPress theme :)', 'sportspress' ); ?></h4>
|
||||
<p class="submit">
|
||||
@@ -8,3 +9,4 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
<a class="button-secondary" href="<?php echo add_query_arg( 'hide_sportspress_theme_support_check', 'true' ); ?>"><?php _e( 'Hide this notice', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</div>
|
||||
<?php endif;
|
||||
|
||||
@@ -20,6 +20,13 @@ $sportspress_sports['football'] = array(
|
||||
'sp_equation' => '$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(
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<h3 class="title"><?php _e( 'Event Settings', 'sportspress' ); ?></h3>
|
||||
<?php
|
||||
settings_fields( 'sportspress_events' );
|
||||
do_settings_sections( 'sportspress_events' );
|
||||
submit_button();
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'sp_result',
|
||||
'numberposts' => -1,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<h3 class="title"><?php _e( 'General Settings', 'sportspress' ); ?></h3>
|
||||
<?php
|
||||
settings_fields( 'sportspress_general' );
|
||||
do_settings_sections( 'sportspress_general' );
|
||||
submit_button();
|
||||
settings_fields( 'sportspress_general' );
|
||||
do_settings_sections( 'sportspress_general' );
|
||||
submit_button();
|
||||
|
||||
@@ -38,15 +38,31 @@ function sportspress_settings() {
|
||||
function sportspress_sport_callback() {
|
||||
global $sportspress_sports;
|
||||
$options = get_option( 'sportspress' );
|
||||
|
||||
$selected = sportspress_array_value( $options, 'sport', null );
|
||||
?>
|
||||
<select id="sportspress_sport" name="sportspress[sport]">
|
||||
<?php foreach( $sportspress_sports as $slug => $sport ): ?>
|
||||
<option value="<?php echo $slug; ?>" <?php selected( $options['sport'], $slug ); ?>><?php echo $sport['name']; ?></option>
|
||||
<option value="<?php echo $slug; ?>" <?php selected( $selected, $slug ); ?>><?php echo $sport['name']; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
|
||||
function sportspress_result_callback() {
|
||||
$options = get_option( 'sportspress' );
|
||||
|
||||
$selected = sportspress_array_value( $options, 'main_result', null );
|
||||
$args = array(
|
||||
'post_type' => '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'
|
||||
);
|
||||
|
||||
@@ -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 .= '<h3 class="countdown sp-countdown"><time datetime="' . $post->post_date . '" data-countdown="' . str_replace( '-', '/', $post->post_date ) . '">' .
|
||||
'<span>' . sprintf( '%02s', $interval->d ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', $interval->h ) . ' <small>' . __( 'hours', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', $interval->i ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', $interval->s ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->d ) ) . ' <small>' . __( 'days', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->h ) ) . ' <small>' . __( 'hours', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->i ) ) . ' <small>' . __( 'mins', 'sportspress' ) . '</small></span> ' .
|
||||
'<span>' . sprintf( '%02s', ( $interval->invert ? 0 : $interval->s ) ) . ' <small>' . __( 'secs', 'sportspress' ) . '</small></span>' .
|
||||
'</time></h3>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user