diff --git a/event.php b/event.php index 4cde0689..6effb381 100644 --- a/event.php +++ b/event.php @@ -76,8 +76,6 @@ function sp_event_stats_meta( $post ) { $limit = get_option( 'sp_event_team_count' ); $teams = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_team', false ), 0, $limit ), $limit, 0 ); $stats = (array)get_post_meta( $post->ID, 'sp_stats', true ); - $result = (array)get_post_meta( $post->ID, 'sp_result', false ); - print_r( $result ); // Teams foreach ( $teams as $key => $value ): diff --git a/helpers.php b/helpers.php index d958c0ac..6d1c062b 100644 --- a/helpers.php +++ b/helpers.php @@ -239,13 +239,16 @@ if ( !function_exists( 'sp_get_stats_row' ) ) { function sp_get_stats_row( $args = array() ) { $args = array_merge( array( + 'meta_value' => 0, 'posts_per_page' => -1 ), (array)$args ); $posts = (array)get_posts( $args ); foreach( $posts as $post ): - $post->sp_stats = get_post_meta( $post->ID, 'sp_stats', true ); + $post->sp_team = get_post_meta( $post->ID, 'sp_team', false ); + $post->sp_team_index = array_search( $args['meta_value'], $post->sp_team ); + $post->sp_result = get_post_meta( $post->ID, 'sp_result', false ); endforeach; $row = array( sizeof( $posts ), @@ -253,10 +256,7 @@ if ( !function_exists( 'sp_get_stats_row' ) ) { array_filter( $posts, function( $var ) { - echo '
';
-				print_r( $var->sp_stats );
-				echo '
'; - return true; + return max( $var->sp_result ) == $var->sp_result[ $var->sp_team_index ]; } ) ),