Add time setting to event logos
This commit is contained in:
@@ -213,7 +213,7 @@ class SP_Settings_Events extends SP_Settings_Page {
|
|||||||
apply_filters( 'sportspress_event_logo_options', array(
|
apply_filters( 'sportspress_event_logo_options', array(
|
||||||
array(
|
array(
|
||||||
'title' => __( 'Display', 'sportspress' ),
|
'title' => __( 'Display', 'sportspress' ),
|
||||||
'desc' => __( 'Display team names', 'sportspress' ),
|
'desc' => __( 'Name', 'sportspress' ),
|
||||||
'id' => 'sportspress_event_logos_show_team_names',
|
'id' => 'sportspress_event_logos_show_team_names',
|
||||||
'default' => 'no',
|
'default' => 'no',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
@@ -221,7 +221,15 @@ class SP_Settings_Events extends SP_Settings_Page {
|
|||||||
),
|
),
|
||||||
|
|
||||||
array(
|
array(
|
||||||
'desc' => __( 'Display results', 'sportspress' ),
|
'desc' => __( 'Time', 'sportspress' ),
|
||||||
|
'id' => 'sportspress_event_logos_show_time',
|
||||||
|
'default' => 'no',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'checkboxgroup' => '',
|
||||||
|
),
|
||||||
|
|
||||||
|
array(
|
||||||
|
'desc' => __( 'Results', 'sportspress' ),
|
||||||
'id' => 'sportspress_event_logos_show_results',
|
'id' => 'sportspress_event_logos_show_results',
|
||||||
'default' => 'no',
|
'default' => 'no',
|
||||||
'type' => 'checkbox',
|
'type' => 'checkbox',
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|||||||
if ( get_option( 'sportspress_event_show_logos', 'yes' ) === 'no' ) return;
|
if ( get_option( 'sportspress_event_show_logos', 'yes' ) === 'no' ) return;
|
||||||
|
|
||||||
$show_team_names = get_option( 'sportspress_event_logos_show_team_names', 'no' ) === 'yes' ? true : false;
|
$show_team_names = get_option( 'sportspress_event_logos_show_team_names', 'no' ) === 'yes' ? true : false;
|
||||||
|
$show_time = get_option( 'sportspress_event_logos_show_time', 'no' ) === 'yes' ? true : false;
|
||||||
$show_results = get_option( 'sportspress_event_logos_show_results', 'no' ) === 'yes' ? true : false;
|
$show_results = get_option( 'sportspress_event_logos_show_results', 'no' ) === 'yes' ? true : false;
|
||||||
|
|
||||||
if ( ! isset( $id ) )
|
if ( ! isset( $id ) )
|
||||||
@@ -20,6 +21,8 @@ if ( $show_results ) {
|
|||||||
$results = sp_get_main_results( $id );
|
$results = sp_get_main_results( $id );
|
||||||
if ( empty( $results ) ) {
|
if ( empty( $results ) ) {
|
||||||
$show_results = false;
|
$show_results = false;
|
||||||
|
} else {
|
||||||
|
$show_time = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +53,7 @@ if ( $teams ):
|
|||||||
if ( get_option( 'sportspress_link_teams', 'no' ) == 'yes' ) $logo = '<a href="' . get_post_permalink( $team ) . '">' . $logo . '</a>';
|
if ( get_option( 'sportspress_link_teams', 'no' ) == 'yes' ) $logo = '<a href="' . get_post_permalink( $team ) . '">' . $logo . '</a>';
|
||||||
|
|
||||||
// Add result
|
// Add result
|
||||||
if ( $show_results ) {
|
if ( $show_results && ! empty( $results ) ) {
|
||||||
$team_result = array_shift( $results );
|
$team_result = array_shift( $results );
|
||||||
$team_result = apply_filters( 'sportspress_event_logos_team_result', $team_result, $id, $team );
|
$team_result = apply_filters( 'sportspress_event_logos_team_result', $team_result, $id, $team );
|
||||||
if ( $alt ) {
|
if ( $alt ) {
|
||||||
@@ -60,13 +63,23 @@ if ( $teams ):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$team_logos[] = '<span class="sp-team-logo">' . $logo . '</span>';
|
// Add logo to array
|
||||||
$i++;
|
if ( '' !== $logo ) {
|
||||||
|
$team_logos[] = '<span class="sp-team-logo">' . $logo . '</span>';
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
endforeach;
|
endforeach;
|
||||||
$team_logos = array_filter( $team_logos );
|
$team_logos = array_filter( $team_logos );
|
||||||
if ( ! empty( $team_logos ) ):
|
if ( ! empty( $team_logos ) ):
|
||||||
echo '<div class="sp-template sp-template-event-logos"><div class="sp-event-logos sp-event-logos-' . sizeof( $teams ) . '">';
|
echo '<div class="sp-template sp-template-event-logos"><div class="sp-event-logos sp-event-logos-' . sizeof( $teams ) . '">';
|
||||||
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
|
|
||||||
|
// Assign delimiter
|
||||||
|
if ( $show_time && sizeof( $teams ) <= 2 ) {
|
||||||
|
$delimiter = '<strong class="sp-event-logos-time sp-team-result">' . get_the_time( get_option('time_format'), $id ) . '</strong>';
|
||||||
|
} else {
|
||||||
|
$delimiter = get_option( 'sportspress_event_teams_delimiter', 'vs' );
|
||||||
|
}
|
||||||
|
|
||||||
echo implode( ' ' . $delimiter . ' ', $team_logos );
|
echo implode( ' ' . $delimiter . ' ', $team_logos );
|
||||||
echo '</div></div>';
|
echo '</div></div>';
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
Reference in New Issue
Block a user