06 / 06Custom WordPress Plugin

Offices Map

Custom plugin: Leaflet office map with opt-in geolocation.

01

Overview

I built a WordPress plugin that renders an interactive map of office locations managed in ACF. Visitors can pick an office or opt in to browser geolocation to find the nearest one. It uses no IP geolocation or external geo APIs, renders a server-side office list for SEO and accessibility, includes an admin diagnostics screen, and loads Leaflet locally with a cached REST endpoint.

WordPressACFPHPJavaScriptLeafletREST API
02

What was built

  • Data: Reads office locations from a custom ACF post type or an options page repeater, validating fields and coordinates.
  • Privacy: Uses no IP geolocation, external geo APIs or location cookies. Browser coordinates stay on the device and are never sent to the server, with an optional "Load map" click-to-load gate.
  • SEO & accessibility: The office list is server-rendered, works without JavaScript and outputs LocalBusiness JSON-LD structured data.
  • Performance: Leaflet is served locally and the public REST API endpoint uses caching.
  • Security: Map popups are assembled with DOM nodes and textContent, preventing stored XSS.
  • Administration: A diagnostics screen highlights invalid records, duplicate addresses, cache status and links to verify every pin.

Other projects