function generate_complete_match_report_with_all_data($match_id) {
$api_url = "https://rest.entitysport.com/v4/matches/{$match_id}/advance?token=" . GENERATE_DRAFT_TOKEN;
$response = wp_remote_get($api_url);
if (is_wp_error($response)) {
return '
Error: Unable to fetch data from the API.
';
}
$data = json_decode(wp_remote_retrieve_body($response), true);
if (empty($data['response'])) {
return 'Error: No data available for the given match.
';
}
$response_data = $data['response'];
$html = "";
// Info Section
if (!empty($response_data['info'])) {
$info = $response_data['info'];
$html .= "
Match Info
Match | {$info['short_title']} |
Title | {$info['title']} |
Subtitle | {$info['subtitle']} |
Venue | {$info['venue']['name']} ({$info['venue']['location']}) |
Toss | {$info['toss']['text']} |
Status | {$info['status_str']} - {$info['status_note']} |
";
}
// Player Batting Stats on Venue
if (!empty($response_data['player_batting_stats_on_venue']['team1'])) {
$html .= "
Player Batting Stats on Venue
Batsman |
Innings |
Runs |
Average |
Strike Rate |
";
foreach ($response_data['player_batting_stats_on_venue']['team1'] as $batsman) {
$html .= "
{$batsman['batsman_title']} |
{$batsman['innings']} |
{$batsman['runs']} |
{$batsman['average']} |
{$batsman['strike']} |
";
}
$html .= "
";
}
// Player Bowling Stats on Venue
if (!empty($response_data['player_bowling_stats_on_venue']['team1'])) {
$html .= "
Player Bowling Stats on Venue
Bowler |
Innings |
Wickets |
Economy |
Average |
Strike Rate |
";
foreach ($response_data['player_bowling_stats_on_venue']['team1'] as $bowler) {
$html .= "
{$bowler['bowler_title']} |
{$bowler['innings']} |
{$bowler['wickets']} |
{$bowler['econ']} |
{$bowler['average']} |
{$bowler['strike']} |
";
}
$html .= "
";
}
// Team A Last 10 Matches
if (!empty($response_data['teama_last10_match'])) {
$html .= "
Team A Last 10 Matches
Match |
Score |
Result |
Date |
";
foreach ($response_data['teama_last10_match'] as $match) {
$html .= "
{$match['short_title']} |
{$match['teama']['scores_full']} vs {$match['teamb']['scores_full']} |
{$match['result']} |
{$match['date_start']} |
";
}
$html .= "
";
}
// Team B Last 10 Matches
if (!empty($response_data['teamb_last10_match'])) {
$html .= "
Team B Last 10 Matches
Match |
Score |
Result |
Date |
";
foreach ($response_data['teamb_last10_match'] as $match) {
$html .= "
{$match['short_title']} |
{$match['teama']['scores_full']} vs {$match['teamb']['scores_full']} |
{$match['result']} |
{$match['date_start']} |
";
}
$html .= "
";
}
// Venue Stats
if (!empty($response_data['venue_stats']['average_score_for_venue'])) {
$html .= "
Venue Stats
Inning |
Average Runs |
Average Wickets |
Average Strike Rate |
";
foreach ($response_data['venue_stats']['average_score_for_venue'] as $stat) {
$html .= "
Inning {$stat['inningnumber']} |
{$stat['avgruns']} |
{$stat['avgwickets']} |
{$stat['avgstrike']} |
";
}
$html .= "
";
}
// Add additional sections (teama_vs_teamb_last10_match, player_vs_player, etc.) similarly
$html .= "
";
return $html;
}
// Shortcode for Full Match Report
add_shortcode('full_match_report', function ($atts) {
$atts = shortcode_atts(['match_id' => ''], $atts, 'full_match_report');
if (empty($atts['match_id'])) {
return 'Error: Match ID is required.
';
}
return generate_complete_match_report_with_all_data($atts['match_id']);
});
Italy vs France, Live Cricket Commentary