diff --git a/helpers.php b/helpers.php index f63a9ffc..fbab2c13 100644 --- a/helpers.php +++ b/helpers.php @@ -337,83 +337,6 @@ if ( !function_exists( 'sp_get_stats_row' ) ) { } } -if ( !function_exists( 'sp_get_stats' ) ) { - function sp_get_stats( $post_id, $set_id = 0, $subset_id = 0, $slug = 'sp_stats' ) { - if ( isset( $post_id ) && $post_id ): - $stats = (array)get_post_meta( $post_id, $slug, true ); - $set = sp_array_value( $stats, $set_id, array() ); - $subset = sp_array_value( $set, $subset_id, array() ); - - // If empty columns exist in subset - if ( empty( $subset ) || in_array( '', $subset ) ): - - // If subset is total row - if ( $subset_id == 0 ): - - // Get fallback if empty columns exist in row - foreach ( $set as $index => $row ): - if ( !$index ) continue; - if ( in_array( '', $row ) ): - echo 'shit!'; - endif; - endforeach; - - // Add values from each row where missing in total - foreach( $subset as $key => $value ): - if ( $value != '' ) continue; - foreach ( $set as $row ): - $value += $row[ $key ]; - endforeach; - $subset[ $key ] = $value; - endforeach; - - else: - - // Get current post type - $post_type = get_post_type( $post_id ); - - // Get fallback values - switch ( $post_type ): - - // Team: all events attended in the league - case 'sp_team': - $args = array( - 'post_type' => 'sp_event', - 'meta_key' => 'sp_team', - 'meta_value' => $post_id, - 'taxonomy' => 'sp_league', - 'terms' => $subset_id - ); - $fallback = sp_get_stats_row( $args ); - break; - - // Player: all events attended in the league - case 'sp_player': - $args = array( - 'post_type' => 'sp_event', - 'meta_key' => 'sp_player', - 'meta_value' => $post_id, - 'taxonomy' => 'sp_league', - 'terms' => $subset_id - ); - $fallback = sp_get_stats_row( $args ); - break; - - endswitch; - - // Merge fallback values with current subset - $subset = array_merge( $fallback, $subset ); - - endif; - - endif; - return $subset; - else: - return array(); - endif; - } -} - if ( !function_exists( 'sp_stats_table' ) ) { function sp_stats_table( $stats = array(), $placeholders = array(), $index = 0, $columns = array( 'Name' ), $total = true, $rowtype = 'post', $slug = 'sp_stats' ) { global $pagenow;