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

    (@antoineh)

    calc_score was changed in the latest version. You should edit your extension Plugin and add the extra variable in the function call or callback.

    See calc_score function for the last parameter. I think it was the match_id. Don’t have the code at hand. So can’t check it now.

    Thread Starter lebo69

    (@lebo69)

    Thanks Antoine.

    When you have the code or updated extension please share so i can fix this.

    Thank you.

    Plugin Author AntoineH

    (@antoineh)

    It was the match ID. You will have to supply that value as the last parameter. See function declaration below:

    public function calc_score( $home, $away, $user_home, $user_away, $joker, $match_id ) {

    But since you are not doing anything with this value (I only added it to make it accessible in a hook), you might as well always send the same value (could be anything).

    Thread Starter lebo69

    (@lebo69)

    Thanks Antoine, but I am not a PHP programmer and do not understand exactly what to do. Could you please let me know what to insert or change on the plugin file?

    Thanks in advance.

    Plugin Author AntoineH

    (@antoineh)

    Not sure what the hide-zero-predictions.php file looks like, so can’t really help you if you don’t post the line that’s giving the error.

    Thread Starter lebo69

    (@lebo69)

    Hi Antoine,

    Here is the hide-zero-predictions.php file i have installed. I would appreciate your help when you can. Thanks.

    <?php
    /**
    * Plugin Name: Football Pool Match Predictions Extension
    * Description: Order match predictions by score and don’t show users without predictions.
    * Version: 1.0
    * Author: Antoine Hurkmans
    * Author URI: mailto:wordpressfootballpool@gmail.com
    * License: MIT
    */

    // Save this plugin in the wp-content/plugins folder and activate it //

    class FootballPoolExtensionMatchPredictions {
    public static function init_extension() {
    if ( ! is_admin() ) {
    add_filter( ‘footballpool_statistics_matchpredictions’, array( __CLASS__, ‘change_matchpredictions’ ), null, 2 );
    }
    }

    public static function change_matchpredictions( $predictions, $match_info ) {
    // add score
    array_walk( $predictions, array( __CLASS__, ‘add_score’ ), $match_info );
    // remove users without predictions
    $predictions = array_filter( $predictions, array( __CLASS__, ‘remove_inactive_users’ ) );
    // sort by score
    usort( $predictions, array( __CLASS__, ‘sort_table’ ) );

    return $predictions;
    }

    public static function add_score( &$prediction, $key, $match_info ) {
    $pool = new Football_Pool_Pool;
    $prediction[‘score’] = $pool->calc_score(
    $match_info[‘home_score’],
    $match_info[‘away_score’],
    $prediction[‘home_score’],
    $prediction[‘away_score’],
    $prediction[‘has_joker’]
    );
    }

    public static function remove_inactive_users( $prediction ) {
    return ! is_null( $prediction[‘home_score’] ) && ! is_null( $prediction[‘away_score’] );
    }

    public static function sort_table( $a, $b ) {
    if ( $a[‘score’] == $b[‘score’] ) return 0;
    return ( $a[‘score’] < $b[‘score’] ) ? 1 : -1;
    }
    }

    add_filter( ‘plugins_loaded’, array( ‘FootballPoolExtensionMatchPredictions’, ‘init_extension’ ) );

    Plugin Author AntoineH

    (@antoineh)

    I didn’t test it, but I think this should be it.

    Thread Starter lebo69

    (@lebo69)

    Worked great. Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Error on Statistics Page’ is closed to new replies.