$league ) { $leagues[ $key ]->sp_order = get_term_meta( $league->term_id, 'sp_order', true ); } if ( ! function_exists( 'sortByOrder' ) ) { function sortByOrder( $a, $b ) { return (int) $a->sp_order - (int) $b->sp_order; } } usort( $leagues, 'sortByOrder' ); $positions = $player->positions(); $player_sections = array(); if ( $positions ) { foreach ( $positions as $position ) { $player_sections = array_merge( $player_sections, sp_get_term_sections( $position->term_id ) ); } } // Determine order of sections if ( 1 == $sections ) { $section_order = array( 1 => esc_attr__( 'Defense', 'sportspress' ), 0 => esc_attr__( 'Offense', 'sportspress' ), ); } elseif ( 0 == $sections ) { $section_order = array( esc_attr__( 'Offense', 'sportspress' ), esc_attr__( 'Defense', 'sportspress' ) ); } else { $section_order = array( -1 => null ); } // Loop through statistics for each league if ( is_array( $leagues ) ) : foreach ( $section_order as $section_id => $section_label ) { if ( -1 !== $section_id && ! empty( $player_sections ) && ! in_array( $section_id, $player_sections ) ) { continue; } if ( sizeof( $leagues ) > 1 ) { printf( '