Ice rink and skating trail: a municipality’s custom WordPress plugin

Illustration au trait : une patinoire vue de dessus, des sapins et un écran d’état avec deux pastilles

Before lacing up their skates, the residents of our client, a municipality in Québec, all ask the same question: is the ice open? We built the municipality a custom WordPress plugin: it shows the live status of the ice rink and the skating trail, closes and reopens them according to their schedules, and lets staff update everything in one click.

In short

  • A municipality in Québec, Canada, with a covered ice rink and a skating trail open to everyone free of charge.
  • The need: telling residents, right on the municipal website, whether each facility is open, closed, booked or under maintenance.
  • The answer: a “Facility conditions” block on the home page and on the rink page, which updates itself.
  • The key feature: each facility closes and reopens on its own according to its own time window, and staff stay in control from a simple page, with no WordPress account.
  • The deliverable: a WordPress plugin and two Elementor widgets, in use since the start of the skating season.

Our client is a municipality in Québec, Canada. In winter, two facilities draw skaters: a covered ice rink, used for public skating, hockey and private bookings, and a skating trail open to everyone free of charge.

During the season, they welcome the public every day, from the afternoon into the evening. But the posted schedule is only part of the story: it can change at any time, depending on the weather. A booking, ice maintenance or a mild spell is enough to close a facility for a few hours.

The problem: knowing whether the ice is open, right now

For residents, the schedule does not answer the real questions of the moment:

  • Is the rink open right now, or booked for a private session?
  • Is the trail skateable, or under maintenance?
  • Is the information I am reading up to date, or is it from yesterday?

Until then, rink news went through a dedicated Facebook page. Handy for posting, less so for finding out: you have to look for it, find the right post and guess whether it still applies. What was missing was an official source, on the municipality’s own website, always up to date, without adding to the staff’s workload.

Our answer: live facility status on the municipal website

We built a custom WordPress plugin, called Gestion des installations (facility management). For residents, a “Conditions des installations” (facility conditions) block appears on the home page and on the rink page. It shows:

  • a green, red or yellow dot for the rink (open, closed, booked) and for the trail (open, closed, maintenance);
  • a short message when more detail is needed, such as “Entretien en cours, réouverture à 14h” (maintenance under way, reopening at 2 pm);
  • a “Consultez l’horaire” (see the schedule) link to the rink’s detailed timetable;
  • the date and time of the last update, so residents know where they stand.
Bloc Conditions des installations en colonne : patinoire ouverte, sentier de patinage fermé, lien vers l’horaire et heure de mise à jour
The block as it appears on the municipal home page.

The block updates itself: a resident who keeps the page open sees the change within a minute, without reloading. The website becomes the go-to place to know whether you can skate, and the Facebook page is no longer essential.

Automatic closures, facility by facility

The rink and the trail do not necessarily keep the same hours. Each one therefore has its own closure window; the rink’s runs from 9 pm to noon. During that window, the facility switches to “Closed”; at the end, it reopens by itself. The window can run past midnight, just like a rink that closes in the evening and reopens the next day.

But the ice does not always follow the schedule. As soon as a staff member changes the status by hand (a weather closure, an unplanned booking), the plugin stops acting on that facility. A “Réactiver le mode automatique” (switch automatic mode back on) button hands control back to the schedule once things are back to normal. Automation does the repetitive work; staff have the final say.

A control page designed for staff

Rink staff have no account on the municipality’s website, and they do not need one. They use a dedicated, password-protected page, which works just as well on a computer as on a phone:

  • three buttons per facility: Open, Close, Book for the rink, Open, Close, Maintenance for the trail (labelled in French on the site);
  • an optional message of up to 150 characters, saved or cleared in one click;
  • the automatic closure windows of each facility;
  • a button to hide the whole block off season, and show it again when the ice is back.

Every click applies to the website immediately.

Page de contrôle des employés : boutons Ouvrir, Fermer, Réserver et Entretien, messages optionnels, horaires de fermeture automatique et visibilité du widget public
The staff control page: one card per facility, the automatic closure windows and public display.

In the WordPress dashboard, the “État actuel” (current status) tab brings everything together on one screen: the status, automatic closure window and public message of each facility, the block’s visibility and the schedule link. Sensitive settings, such as the address the “see the schedule” link points to, remain reserved for the site’s administrators there: the staff page gives no access to them.

Administration WordPress du plugin Gestion des installations, onglet État actuel : état, fermeture automatique et message public de la patinoire et du sentier, interrupteurs d’affichage public et de lien vers l’horaire
The dashboard’s “État actuel” (current status) tab: one card per facility, then public display and the link to the schedule file.

A block that adapts to each page

The public block is an Elementor widget. It can be placed anywhere and styled without touching code: list, card or horizontal banner layout, headings, colours, schedule link shown or hidden. On the home page, it fits in a narrow column next to the news; on the rink page, it spans the full width.

Bloc Conditions des installations en pleine largeur : une carte verte pour la patinoire ouverte, une carte rouge pour le sentier fermé
On the rink page, the same block at full width: one card per facility, the schedule link and the time of the last update.

What this project shows about the way we work

Showing “open” or “closed” sounds simple. Custom work is about the details on the ground: two facilities with different statuses (you book a rink, you maintain a trail), hours that run past midnight, staff without a WordPress account, a season that ends in spring. A generic opening hours module would have covered none of these cases.

And the plugin kept pace with the season: after the first few weeks of use, we improved it based on the municipality’s feedback, adding a time window specific to the trail, the link to the detailed schedule and a message editable from the dashboard. Since we also host the site, we control the whole chain end to end, caching included.

For the more technical: how the plugin works

If you like to look under the bonnet of WordPress, here is what Gestion des installations does. Option names and code comments mix French and English, as in the plugin itself.

1. Automatic closure that does not rely on WP-Cron alone

By default, WP-Cron only runs when a page is visited, and a page served from the cache triggers nothing. The plugin therefore checks the windows at three points:

  • a scheduled task every 15 minutes (every_15_minutes interval added through the cron_schedules filter);
  • every uncached page load (wp hook);
  • every status read by the browser (patinoire_get_etat AJAX action).

The comparison uses the site’s time zone, through wp_timezone(), and handles windows that run past midnight:

function patinoire_is_in_fermeture_range( string $heure_debut, string $heure_fin ): bool {
	$now          = new DateTime( 'now', wp_timezone() );
	$current_time = $now->format( 'H:i' );

	// Range does not cross midnight.
	if ( $heure_debut < $heure_fin ) {
		return $current_time >= $heure_debut && $current_time < $heure_fin;
	}

	// Range crosses midnight (e.g. 22:00 → 12:00).
	return $current_time >= $heure_debut || $current_time < $heure_fin;
}

2. Manual status takes priority over the schedule

Every change made by a staff member saves a {installation}_manual option. The automatic check then skips that facility until someone clicks “switch automatic mode back on”. The two facilities are handled independently:

foreach ( [ 'patinoire', 'sentier' ] as $inst ) {
	// Employee has manually set this installation's state: never touch it automatically.
	if ( get_option( $inst . '_manual', 'false' ) === 'true' ) {
		continue;
	}

	// Each installation follows its own closure window.
	$horaire  = patinoire_get_horaire( $inst );
	$in_range = patinoire_is_in_fermeture_range( $horaire['debut'], $horaire['fin'] );
	$etat     = (string) get_option( $inst . '_etat', 'ferme' );

	if ( $in_range && $etat !== 'ferme' ) {
		update_option( $inst . '_etat', 'ferme' );
		update_option( $inst . '_last_update', $now );
	} elseif ( ! $in_range && $etat === 'ferme' ) {
		update_option( $inst . '_etat', 'ouvert' );
		update_option( $inst . '_last_update', $now );
	}
}

3. Accurate display despite LiteSpeed caching

The site runs LiteSpeed Cache. Every page showing the block gets the patinoire_status cache tag. As soon as a displayed option changes (status, message, visibility, link, colours), the plugin purges those pages, and only those, whoever made the change: staff, administrator or scheduled task. Without LiteSpeed Cache, these actions simply do nothing.

const PATINOIRE_CACHE_TAG = 'patinoire_status';

function patinoire_tag_page_cache(): void {
	do_action( 'litespeed_tag_add', PATINOIRE_CACHE_TAG );
}

function patinoire_purge_page_cache(): void {
	do_action( 'litespeed_purge', PATINOIRE_CACHE_TAG );
}

foreach ( $displayed_options as $option ) {
	add_action( "add_option_{$option}", 'patinoire_purge_page_cache' );
	add_action( "update_option_{$option}", 'patinoire_purge_page_cache' );
	add_action( "delete_option_{$option}", 'patinoire_purge_page_cache' );
}

On top of that, the public script polls admin-ajax.php every 60 seconds and updates dots, messages and date without reloading the page.

4. No account needed, but not unprotected

Write actions are open to logged-out visitors (wp_ajax_nopriv_), since staff have no account. They require a security token, patinoire_nonce, which is only served on the control page, itself password-protected and excluded from the cache. The public page gets no token at all: it only reads a public status.

Settings that could be used to send visitors elsewhere, such as the target of the schedule link, require an administrator account, a separate token and an http or https address:

function patinoire_ajax_save_horaire_link(): void {
    check_ajax_referer( 'patinoire_admin_nonce', 'nonce' );

    if ( ! current_user_can( 'manage_options' ) ) {
        wp_send_json_error( [ 'message' => 'Action non autorisée' ], 403 );
        return;
    }
    // ...
}
// Admin screen only: no wp_ajax_nopriv_ hook for this action.
add_action( 'wp_ajax_patinoire_save_horaire_link', 'patinoire_ajax_save_horaire_link' );

5. Two Elementor widgets, with shortcodes as a fallback

The plugin adds a “Patinoire” category to Elementor, with two widgets: État Patinoire (rink status: list, cards or horizontal banner) and Contrôle Patinoire (rink control). The same screens are available as shortcodes, [patinoire_etat] and [patinoire_controle]. Global colours are set in the dashboard and go through CSS custom properties, so a colour chosen in a widget keeps priority.

All in typed PHP, with no external dependency, plain WordPress options and a settings migration that runs only once per update.

What if we did the same for your organisation?

Here, a municipality’s website became a real live service for its residents, thanks to a plugin built for that precise need, and easy for staff to keep up to date.

Do you also run facilities or services whose status changes often: sports ground, swimming pool, hall for hire, trail, ski area? We can design the plugin that fits the way you work.

See our custom plugins or tell us about your needs

Contents
Read next

More articles that may help you

Illustration au trait : un casque audio, une onde sonore, un stockage de fichiers et le symbole d’un flux RSS

Self-hosted podcast: moving a podcast to WordPress and Cloudflare R2

Read the article →
WooCommerce e-invoicing: how to make your shop compliant

WooCommerce e-invoicing: how to bring your shop into compliance

Read the article →
Cookies and consent: why a simple banner is no longer enough

Cookies and consent: why a simple banner is no longer enough

Read the article →

A project, a question?

Free quote · Refundable deposit · Balance only if satisfied · No commitment