Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author AntoineH

    (@antoineh)

    The function that shows this info (show_predictions_for_match in the Football_Pool_Statistics class) has a filter to change the predictions array. You could write your own function to alter the order of the array.

    To calculate the score (which is not part of the array) use the calc_score() function in the Football_Pool_Pool class. Example of usage is in the show_predictions_for_match function.

    Thread Starter latinosamorir

    (@latinosamorir)

    Thanks Antoine.

    I can try to use the filter but you don’t pass the variable $match_info.

    I believe I need this to use calc_score(), yes?

    Please advice.

    Thank you.

    Thread Starter latinosamorir

    (@latinosamorir)

    Ok — I’ve succeeded if I add $match_info to the filter — would you mind adding that to avoid losing this when I update next:

    I changed line 363 in class-football-pool-statistics.php to:

    $rows = apply_filters( 'footballpool_statistics_matchpredictions', $predictions, $match_info );

    and added the following to my functions.php:

    // Change sort of statisctics page
    add_filter('footballpool_statistics_matchpredictions','gd_chgorder',10,2);
    function gd_chgorder ($rows, $match_info){
    
    	global $wpdb;
    	$prefix = FOOTBALLPOOL_DB_PREFIX;
    
    	$pool = new Football_Pool_Pool;
    
    	$i=0;
    	foreach ( $rows as $row ) {
    		$rows[$i]["score"] = $pool->calc_score(
    										$match_info['home_score'],
    										$match_info['away_score'],
    										$row['home_score'],
    										$row['away_score'],
    										$row['has_joker']
    									);
    
    		$i++;
    	}
    	$rows = sort_by_key($rows, 'score');
    	return $rows;
    }
    Plugin Author AntoineH

    (@antoineh)

    I’ve added the $match_info in my dev version.

    Thread Starter latinosamorir

    (@latinosamorir)

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sort Statistics Match page’ is closed to new replies.