There is not a shortcode yet, but the code to display the matches for a venue is fairly simple.
$pool = new Football_Pool_Pool;
$stadiums = new Football_Pool_Stadiums;
$stadium = $stadiums->get_stadium_by_id( 1 );
$fixtures = $stadium->get_plays();
echo $pool->matches->print_matches( $fixtures, 'page stadium-page' );
So, I went ahead and asked chatgpt to create a shortcode for me with this code ??
This was the conversation:
https://app.screencast.com/7qUY1Q5Q6kPfN
and here’s the result:
<?php
/*
Plugin Name: Stadium Matches Shortcode
Description: This plugin adds a shortcode to display matches for a certain stadium.
*/
// Main plugin class
class Stadium_Matches_Shortcode {
public function __construct() {
// Hook to plugins_loaded to ensure dependencies are loaded
add_action('plugins_loaded', array($this, 'init'));
}
// Initialize the plugin
public function init() {
// Add shortcode
add_shortcode('stadium_matches', array($this, 'display_stadium_matches'));
}
// Shortcode function
public function display_stadium_matches($atts) {
// Instantiate Football Pool classes
$pool = new Football_Pool_Pool;
$stadiums = new Football_Pool_Stadiums;
// Get stadium ID from shortcode attribute
$stadium_id = isset($atts['stadium_id']) ? intval($atts['stadium_id']) : 1;
// Get stadium details
$stadium = $stadiums->get_stadium_by_id($stadium_id);
// Get matches for the stadium
$fixtures = $stadium->get_plays();
// Return the matches using Football Pool's print_matches method
return $pool->matches->print_matches($fixtures, 'page stadium-page');
}
}
// Instantiate the plugin class
new Stadium_Matches_Shortcode();
Works pretty well ??