• Hi Mark,

    I found your plugin after getting a public PlayHQ API and looking at doing my own custom plugin to display some data on a club website.

    Have you considered adding the following optional features:

    1. Club filter for the returned list of teams specific to a club within the parent league (i.e. by friendly name or club id)?
    2. Including the Season/League information on the fixture title (e.g. League 2026)
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author markrblackburn

    (@markrblackburn)

    Hi Stobipole,

    My original implementation was for a very small league so the number of teams per club was manageable, but when I did some debugging for a larger league, I did notice that the teams list was pretty unwieldy. Are you thinking of a filter on the setup page to make it easier to find the appropriate teams? I guess it could also be useful on the display page if you are using the drop down to select teams rather than configuring it in the page. I can certainly look at adding those options as well as the league & season information. I was also planning to give an option to show scores for completed games if that is of interest to you

    Mark

    Thread Starter stobipole

    (@stobipole)

    Hi Mark,

    Yeah, optional filter in the settings page so that way you could have a single ‘club fixtures’ page and have the drop down only populate teams from your own club, not the entire league.

    I can see scores being a good addition.

    Other one I forgot to mention was the option to limit the number of returned rounds from the fixtures in the shortcode, for example:

    [playhq_fixtures team=”<TEAM NAME>” limit=”<VALUE>”]

    If set, then it would take the current date and get the next round(s) (based on the limit set) so you can have an ‘upcoming games’ section rather than the full table.

    Thread Starter stobipole

    (@stobipole)

    Here’s a temp addition I’ve done to filter the returned list of teams

    $club_name = '<VALUE>';
    $teams_list = array_filter($teams_list, function($item) use ($club_name) {
    return str_contains($item['name'], $club_name);
    });
    Thread Starter stobipole

    (@stobipole)

    Another temp addition – only show upcoming when limit is set:

    	$game_count = 0;
    foreach ($data['data'] as $game) {
    // Defensive: skip if competitors is missing or not an array
    if (!isset($game['competitors']) || !is_array($game['competitors'])) {
    continue;
    }
    $date = $game['schedule']['date'] ?? '-';
    $time = $game['schedule']['time'] ?? 'TBA';
    $round_full = $game['round']['name'] ?? '-';
    $round = preg_replace('/[^\d]/', '', $round_full);

    $game_datetime = DateTime::createFromFormat('Y-m-d H:i:s', $date . ' ' . $time, new DateTimeZone("Australia/Melbourne"));
    if ($game_datetime === false) {
    $game_datetime = null;
    }
    if (!empty($atts['limit'])) {
    $filter = 'upcoming';
    $game_limit = $atts['limit'];
    }
    if ($filter === 'upcoming' && $game_datetime && $game_datetime < $now) continue;
    if ($filter === 'past' && $game_datetime && $game_datetime > $now) continue;

    $home = $away = '-';
    $home_id = $away_id = '';
    foreach ($game['competitors'] as $team) {
    if (!isset($team['name'])) continue;
    $team_name = $team['name'];
    if ($clean_team_names) {
    $team_name = preg_replace([
    '/\s*Over\s*\d{1,2}s?/i',
    '/\s*O\d{1,2}s?/i',
    '/\s*Under\s*\d{1,2}s?/i',
    '/\s*U\d{1,2}s?/i',
    '/\s*Reserves?/i',
    '/\s*Div(?:ision)?\s*\d+/i',
    '/\s*Grade\s*\w+/i',
    '/\s*Men\'?s?/i',
    '/\s*Women\'?s?/i',
    '/\s*Mixed/i',
    ], '', $team_name);
    $team_name = trim($team_name);
    }
    if (!empty($team['isHomeTeam'])) {
    $home = $team_name;
    $home_id = $team['id'] ?? '';
    } else {
    $away = $team_name;
    $away_id = $team['id'] ?? '';
    }
    }

    // Only color and bold the selected team (home or away)
    $is_home_selected = ($home_id === $selected_team_id);
    $is_away_selected = ($away_id === $selected_team_id);

    if ($is_home_selected) {
    $home = '<span class="playhq-selected-team">' . esc_html($home) . '</span>';
    }
    if ($is_away_selected) {
    $away = '<span class="playhq-selected-team">' . esc_html($away) . '</span>';
    }

    $venue = $game['venue']['name'] ?? '-';

    $date_formatted = $game_datetime ? $game_datetime->format($date_format) : $date;
    $time_formatted = $game_datetime ? $game_datetime->format($time_format) : $time;
    $datetime_combined = trim($date_formatted . ' ' . $time_formatted);

    // Determine opponent for mobile
    $opponent = '-';
    if ($is_home_selected) {
    $opponent = $away_id ? $away : $away;
    } elseif ($is_away_selected) {
    $opponent = $home_id ? $home : $home;
    }

    $output .= "<tr>
    <td class='phq-col-datetime' data-label='" . esc_attr__('Date/Time', 'fixture-viewer-for-playhq') . "' style='display:none;'>$datetime_combined</td>
    <td class='phq-col-opponent' data-label='" . esc_attr__('Opponent', 'fixture-viewer-for-playhq') . "' style='display:none;'>$opponent</td>
    <td class='phq-col-round' data-label='" . esc_attr__('Round', 'fixture-viewer-for-playhq') . "'>$round</td>
    <td class='phq-col-date' data-label='" . esc_attr__('Date', 'fixture-viewer-for-playhq') . "'>$date_formatted</td>
    <td class='phq-col-time' data-label='" . esc_attr__('Time', 'fixture-viewer-for-playhq') . "'>$time_formatted</td>
    <td class='phq-col-home' data-label='" . esc_attr__('Home', 'fixture-viewer-for-playhq') . "'>$home</td>
    <td class='phq-col-away' data-label='" . esc_attr__('Away', 'fixture-viewer-for-playhq') . "'>$away</td>
    <td class='phq-col-venue' data-label='" . esc_attr__('Venue', 'fixture-viewer-for-playhq') . "'>$venue</td>
    </tr>";
    $game_count++;
    if ($game_count == $game_limit){
    break;
    }
    }

    $output .= '</tbody></table>';
    return '<div class="playhq-fixture-wrapper">' . $selector . $output . '</div>';
    }

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

You must be logged in to reply to this topic.