diff --git a/actions.php b/actions.php index 93b3da5f..35e4b33d 100644 --- a/actions.php +++ b/actions.php @@ -103,10 +103,14 @@ function sp_save_post( $post_id ) { foreach ( $sportspress as $key => $value ): delete_post_meta( $post_id, $key ); if ( is_array( $value ) ): - $values = new RecursiveIteratorIterator( new RecursiveArrayIterator( $value ) ); - foreach ( $values as $value ): + if ( sp_array_depth( $value ) >= 3 ): add_post_meta( $post_id, $key, $value, false ); - endforeach; + else: + $values = new RecursiveIteratorIterator( new RecursiveArrayIterator( $value ) ); + foreach ( $values as $value ): + add_post_meta( $post_id, $key, $value, false ); + endforeach; + endif; else: update_post_meta( $post_id, $key, $value ); endif; diff --git a/event.php b/event.php index a2449cb9..78b24f5e 100644 --- a/event.php +++ b/event.php @@ -35,7 +35,7 @@ function sp_event_meta_init() { function sp_event_team_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); + $teams = array_pad( array_slice( (array)get_post_meta( $post->ID, 'sp_team', false ), 0, $limit ), $limit, 0 ); $players = (array)get_post_meta( $post->ID, 'sp_player', false ); for ( $i = 0; $i < $limit; $i++ ): ?> @@ -74,18 +74,31 @@ function sp_event_article_meta( $post ) { 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); - $players = (array)get_post_meta( $post->ID, 'sp_player', false ); - for ( $i = 0; $i < $limit; $i++ ): + $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 ); + foreach ( $teams as $key => $value ): ?>
- +
- ID, 'sp_player', 'block', 'sp_team', $i ); ?> + ID, 'sp_player', false ), 0, $key ); + $size = sizeof( $ids ); + if ( array_key_exists( $value, $stats ) ) + $team_stats = (array)$stats[ $value ]; + $data = array(); + foreach ( $ids as $id ): + if ( array_key_exists( $id, $team_stats ) ) + $data[ $id ] = $team_stats[ $id ]; + else + $data[ $id ] = array(); + endforeach; + sp_data_table( $data, $value ); + ?>| - | - | - | - | + | + + | + |
| Total | -- | - | - | + | + + | + |