Use Order meta of League term to sort Leagues

When the 'sp_order' meta is defined for a League (sp_league) then it will be used to sort the Leagues inside a player's profile.
This commit is contained in:
savvasha
2018-04-18 17:02:07 +03:00
committed by GitHub
parent 5825cf1cfc
commit 526e4ef398

View File

@@ -20,6 +20,16 @@ $show_career_totals = 'yes' === get_option( 'sportspress_player_show_career_tota
$sections = get_option( 'sportspress_player_performance_sections', -1 );
$show_teams = apply_filters( 'sportspress_player_team_statistics', true );
$leagues = get_the_terms( $id, 'sp_league' );
// Sort Leagues by User Defined Order (PHP5.2 supported)
foreach ( $leagues as $key => $league ) {
$leagues[ $key ]->sp_order = get_term_meta ( $league->term_id , 'sp_order', true );
}
function sortByOrder($a, $b) {
return $a->sp_order - $b->sp_order;
}
usort($leagues, 'sortByOrder');
$positions = $player->positions();
$player_sections = array();
if ( $positions ) {
@@ -75,4 +85,4 @@ if ( is_array( $leagues ) ):
) );
}
}
endif;
endif;