Next Game widget
-
Hi. thank you for this awesome plugin
i like the look of next game widget.
is there any way to show all the next games ? not just one game in game widget?
or is there any way to make the games shortcode look similar to the widget?
can you give me some php or css code to do that please?
Viewing 1 replies (of 1 total)
-
Hi
If you know PHP a bit, you can override plugin template files.
Look into the file “widget-next-game.php” in the plugin “templates” folder.Below is the modified code.
<?php /** * The Template for displaying Next Game Widget. * * This template can be overridden by copying it to yourtheme/sports-leagues/widget-next-game.php. * * @var object $data - Object with widget data. * * @author Andrei Strekozov <anwp.pro> * @package Sports-Leagues/Templates * @since 0.5.6 * * @version 0.9.2 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } // Prevent errors with new params $args = (object) wp_parse_args( $data, [ 'team_id' => '', 'tournament_id' => '', 'stage_id' => '', 'season_id' => '', 'show_team_name' => '', 'game_link_text' => '', 'exclude_ids' => '', 'include_ids' => '', ] ); // Get tournament games $games = sports_leagues()->game->get_games_extended( [ 'tournament_id' => $args->tournament_id, 'stage_id' => $args->stage_id, 'season_id' => $args->season_id, 'finished' => 0, 'filter_by_team' => $args->team_id, 'limit' => 0, 'sort_by_date' => 'asc', 'exclude_ids' => $args->exclude_ids, 'include_ids' => $args->include_ids, ] ); if ( empty( $games ) || empty( $games[0]->game_id ) ) { return; } foreach ( $games as $game ) : $data = (object) sports_leagues()->game->prepare_tmpl_game_data( $game ); $show_name = Sports_Leagues::string_to_bool( $args->show_team_name ); ?> <div class="anwp-b-wrap"> <div class="game-card anwp-bg-light py-3"> <?php if ( intval( $data->venue_id ) ) : ?> <div class="game-card__venue anwp-text-center text-muted"> <svg class="anwp-icon"> <use xlink:href="#icon-location"></use> </svg> <?php echo esc_html( get_the_title( $data->venue_id ) ); $venue_city = get_post_meta( $data->venue_id, '_sl_city', true ); echo $venue_city ? esc_html( ', ' . $venue_city ) : ''; ?> </div> <?php endif; ?> <div class="game-card__tournament anwp-text-center font-weight-bold"> <?php echo esc_html( sports_leagues()->tournament->get_title( $data->tournament_id ) ); ?><br> <?php echo esc_html( sports_leagues()->tournament->get_title( $data->stage_id ) ); ?> </div> <div class="game-card__teams anwp-row anwp-no-gutters my-3"> <div class="anwp-col d-flex flex-column anwp-text-center anwp-min-width-0"> <?php if ( $show_name ) : ?> <div class="team-logo__cover team-logo__cover--xlarge d-block mx-auto" style="background-image: url('<?php echo esc_attr( $data->home_logo ); ?>')"></div> <div class="game__team mt-1 d-inline-block text-truncate"><?php echo esc_html( $data->home_title ); ?></div> <?php else : ?> <div class="team-logo__cover team-logo__cover--xlarge d-block mx-auto" style="background-image: url('<?php echo esc_attr( $data->home_logo ); ?>')" data-toggle="anwp-tooltip" data-tippy-content="<?php echo esc_attr( $data->home_title ); ?>"></div> <?php endif; ?> </div> <div class="anwp-col-auto align-self-center h3 text-muted">vs</div> <div class="anwp-col d-flex flex-column anwp-text-center anwp-min-width-0"> <?php if ( $show_name ) : ?> <div class="team-logo__cover team-logo__cover--xlarge d-block mx-auto" style="background-image: url('<?php echo esc_attr( $data->away_logo ); ?>')"></div> <div class="game__team mt-1 d-inline-block text-truncate"><?php echo esc_html( $data->away_title ); ?></div> <?php else : ?> <div class="team-logo__cover team-logo__cover--xlarge d-block mx-auto" style="background-image: url('<?php echo esc_attr( $data->away_logo ); ?>')" data-toggle="anwp-tooltip" data-tippy-content="<?php echo esc_attr( $data->away_title ); ?>"></div> <?php endif; ?> </div> </div> <div class="game-card__timer game-card__timer-static anwp-text-center mt-3"> <div class="d-inline-block py-1 px-2 anwp-bg-white text-dark text-uppercase h5"> <?php if ( $data->kickoff && '0000-00-00 00:00:00' !== $data->kickoff ) { $date_format = Sports_Leagues_Options::get_value( 'custom_game_date_format' ) ?: 'j M '; $time_format = Sports_Leagues_Options::get_value( 'custom_game_time_format' ) ?: get_option( 'time_format' ); echo esc_html( date_i18n( $date_format . ' ' . $time_format, get_date_from_gmt( $data->kickoff, 'U' ) ) ); } ?> </div> </div> <?php if ( $args->game_link_text ) : ?> <div class="anwp-text-center anwp-game-preview-link anwp-bg-light mt-1"> <a href="<?php echo esc_url( get_permalink( $data->game_id ) ); ?>" class="anwp-link-without-effects"> <span class="d-inline-block"><?php echo esc_html( $args->game_link_text ); ?></span> </a> </div> <?php endif; ?> </div> </div> <?php endforeach;
`
Viewing 1 replies (of 1 total)
- The topic ‘Next Game widget’ is closed to new replies.