diff --git a/includes/admin/settings/class-sp-settings-events.php b/includes/admin/settings/class-sp-settings-events.php index d6b977b1..4caf09fe 100644 --- a/includes/admin/settings/class-sp-settings-events.php +++ b/includes/admin/settings/class-sp-settings-events.php @@ -60,6 +60,14 @@ class SP_Settings_Events extends SP_Settings_Page { 'checkboxgroup' => 'end', ), + array( + 'title' => __( 'Results', 'sportspress' ), + 'desc' => __( 'Display outcomes', 'sportspress' ), + 'id' => 'sportspress_event_show_outcomes', + 'default' => 'no', + 'type' => 'checkbox', + ), + array( 'title' => __( 'Player Performance', 'sportspress' ), 'desc' => __( 'Link players', 'sportspress' ), diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 08cec2c0..416c3573 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -3216,6 +3216,7 @@ function sp_get_text_options() { 'event' => __( 'Event', 'sportspress' ), 'league' => __( 'League', 'sportspress' ), 'nationality' => __( 'Nationality', 'sportspress' ), + 'outcome' => __( 'Outcome', 'sportspress' ), 'past_teams' => __( 'Past Teams', 'sportspress' ), 'played' => __( 'Played', 'sportspress' ), 'player' => __( 'Player', 'sportspress' ), diff --git a/templates/event-results.php b/templates/event-results.php index ac29810c..90163f20 100644 --- a/templates/event-results.php +++ b/templates/event-results.php @@ -12,6 +12,12 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! isset( $id ) ) $id = get_the_ID(); +$defaults = array( + 'show_outcomes' => get_option( 'sportspress_event_show_outcomes', 'yes' ) == 'yes' ? true : false, +); + +extract( $defaults, EXTR_SKIP ); + $teams = (array)get_post_meta( $id, 'sp_team', false ); $results = array_filter( sp_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ), 'array_filter' ); $result_labels = sp_get_var_labels( 'sp_result' ); @@ -29,6 +35,20 @@ if ( empty( $results ) ) foreach( $results as $team_id => $result ): if ( sp_array_value( $result, 'outcome', '-1' ) != '-1' ): + if ( $show_outcomes ): + $outcomes = array(); + $result_outcome = $result['outcome']; + if ( ! is_array( $result_outcome ) ): + $result_outcome = (array) $result_outcome; + endif; + foreach( $result_outcome as $outcome ): + $the_outcome = get_page_by_path( $outcome, OBJECT, 'sp_outcome' ); + if ( is_object( $the_outcome ) ): + $outcomes[] = $the_outcome->post_title; + endif; + endforeach; + endif; + unset( $result['outcome'] ); $table_rows .= '