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' ); $output = ''; // Initialize and check $table_rows = ''; $i = 0; if ( empty( $results ) ) return false; foreach( $results as $team_id => $result ): if ( count( array_filter( $results ) ) ): 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 .= ''; $table_rows .= '' . get_the_title( $team_id ) . ''; foreach( $result_labels as $key => $label ): if ( $key == 'name' ) continue; if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ): $value = $result[ $key ]; else: $value = '—'; endif; $table_rows .= '' . $value . ''; endforeach; if ( $show_outcomes ): $table_rows .= '' . implode( ', ', $outcomes ) . ''; endif; $table_rows .= ''; $i++; endif; endforeach; if ( empty( $table_rows ) ): return false; else: $output .= '

' . SP()->text->string('Team Results') . '

'; $output .= '
' . '' . ''; foreach( $result_labels as $key => $label ): $output .= ''; endforeach; if ( $show_outcomes ): $output .= ''; endif; $output .= '' . '' . ''; $output .= $table_rows; $output .= '' . '
' . SP()->text->string('Team') . '' . $label . '' . SP()->text->string('Outcome') . '
' . '
'; endif; echo $output;