1. Customize
  2. Leaderboards
  3. Disable responsive leaderboards

Disable responsive leaderboards

In the update 1.1.5 of our Leaderboards add-on we introduced support for responsive leaderboards in small screens.

In case you wish to disable this mode for a specific leaderboard, here is a code snippet for that:

function my_prefix_remove_leaderboard_responsive_classes_to_leaderboard( $classes, $leaderboard_table_id ) {
    $leaderboard_id = 123; // ID of the leaderboard you want to disable the responsive mode
    if( $leaderboard_id !== $leaderboard_table_id ) {
        return $classes;
    }
    $new_classes = array();
    foreach( $classes as $class ) {
        if( $class === 'gamipress-leaderboard-table-responsive'
            || $class === 'gamipress-leaderboard-table-responsive-toggleable' ) {
            continue;
        }
        $new_classes[] = $class;
    }
    return $new_classes;
}
add_filter( 'gamipress_leaderboards_table_classes', 'my_prefix_remove_leaderboard_responsive_classes_to_leaderboard', 10, 2 );

Also, is possible to completely disable the responsive mode to all leaderboards with the following snippet:

function my_prefix_remove_leaderboard_responsive_classes( $classes ) {
    $new_classes = array();
    foreach( $classes as $class ) {
        if( $class === 'gamipress-leaderboard-table-responsive'
        || $class === 'gamipress-leaderboard-table-responsive-toggleable' ) {
            continue;
        }
        $new_classes[] = $class;
    }
    return $new_classes;
}
add_filter( 'gamipress_leaderboards_table_classes', 'my_prefix_remove_leaderboard_responsive_classes' );

How can we help?