Created
April 9, 2022 15:57
-
-
Save kadimi/5566c80f02f3598882624b5d6360ab1e to your computer and use it in GitHub Desktop.
SportsPress - Customize Player Details
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'sportspress_player_details', function( $data ) { | |
$labels_from_to = [ | |
'موضع' => 'المركز', | |
'الفريق الحالي' => 'النادي', | |
'المواسم' => 'الموسم الرياضي', | |
]; | |
$labels_order = [ | |
'#', | |
'الاسم', | |
'تاريخ الميلاد', | |
'العمر', | |
'المركز', | |
'النادي', | |
'الطول', | |
'الوزن', | |
'الدوري', | |
'الموسم الرياضي', | |
]; | |
foreach ( $labels_from_to as $from => $to ) { | |
if ( ! empty( $data[$from] ) ) { | |
$data[ $to ] = $data[ $from ]; | |
unset( $data[ $from ] ); | |
} | |
} | |
uksort( $data, function( $a, $b ) use ( $labels_order ) { | |
$position_a = array_search($a, $labels_order); | |
if ( FALSE === $position_a) { | |
$position_a = PHP_INT_MAX; | |
} | |
$position_b = array_search($b, $labels_order); | |
if ( FALSE === $position_b) { | |
$position_b = PHP_INT_MAX; | |
} | |
return ( $position_a === $position_b ) | |
? 0 | |
: ( $position_a < $position_b ? -1 : 1 ) | |
; | |
} ); | |
return $data; | |
}, PHP_INT_MAX ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment