A standalone real-time lookup tool for UK place, service and helpline data.
LifeLines imports a UK dataset (place / service / helpline records) that you upload as a CSV into its own table, and exposes a fast, public smart lookup: partial-match search across admin-configurable columns, with results rendered in real time as you type. It is self-contained — it has no plugin dependencies and registers entirely on core WordPress hooks.
Dependencies: none License: MIT (Modified — see License) Author: The Bleeding Deacons
- Requirements
- Installation
- Smart Lookup
- Architecture
- Kill Switch
- Extending LifeLines
- Building for Production
- License
- WordPress 6.1 or later
- PHP 8.6 or later
- No other plugins required
- Build the
lifelines.ziparchive (composer build) or clone this repository intowp-content/plugins/lifelines. - In WordPress, go to Plugins → Add New → Upload Plugin, or activate it from the Plugins screen if cloned.
- On activation LifeLines creates its (empty) table and adds a public Lookup page.
- Load your data: on LifeLines → Smart Lookup, upload a CSV whose first row is the column names (see Smart Lookup).
LifeLines provides a self-contained, real-time lookup over a UK dataset (place /
service / helpline data) that you import into its wp_life_lines table.
No data is bundled with the plugin — you upload a CSV (first row = column
names) from the admin screen, and can export the current data back to CSV. It is
fully self-contained — no plugin dependencies; it registers on core
WordPress hooks.
Public page. On activation the plugin creates a published Lookup page
containing the [lifelines_lookup] shortcode (you can also drop that shortcode on
any page). As you type, results are fetched from admin-ajax.php and rendered
live, matching partial values across the configured columns. The results list
is responsive — a table on wider screens, stacked cards on phones.
Remembered state. The search term is mirrored to the URL (?q=…) and to
sessionStorage, and the scroll position is stored too. If a visitor searches,
navigates away, and returns to the page, their term, results, and scroll position
are restored. A URL with ?q= pre-fills and runs that search (shareable links).
Admin settings (LifeLines menu → Smart Lookup):
- Searchable columns — which columns the typed text is partial-matched against.
- Displayed columns — which columns (and in what order) appear in the results.
- Maximum results and minimum characters before a search fires.
- Import / export data — upload a CSV (first row = column names; unknown
columns ignored, blank cells stored as NULL) to replace the current rows; the
uploaded file is then deleted. Export downloads all rows as CSV. A live row
count is shown. Embedded commas/quotes are handled via
fgetcsv/fputcsv.
Security. Column identifiers are never taken from user input: admin-chosen
columns are validated against a fixed whitelist (Lookup\Columns) before being
back-ticked, and the search term is bound via $wpdb->prepare(). The public
search endpoint is read-only and nonce-free by design, so it survives full-page
caching.
Key classes live under src/Lookup/: LookupBootstrap (wiring + activation),
TownSchema (table + import), TownRepository (search), LookupController
(shortcode + AJAX + assets), SettingsPage (admin), LookupSettings and
Columns (config + whitelist).
lifelines.php— plugin header, constants (LIFELINES_VERSION,LIFELINES_PLUGIN_DIR,LIFELINES_PLUGIN_URL), theLIFELINES_KILLkill switch, a PSR-4 autoloader for theLifeLines\namespace, and registration of the lookup subsystem on theplugins_loadedand activation hooks.LifeLines\Lookup\LookupBootstrap— wires the subsystem together and runs activation (install table, import data, create the public page).LifeLines\Lookup\TownSchema— the single source of truth for thewp_life_linestable: it creates the schema (viadbDelta), imports row data from an uploaded CSV (batched inserts; header matched againstColumns), and exports the table to CSV.LifeLines\Lookup\TownRepository— the partial-match search query.LifeLines\Lookup\LookupController— the[lifelines_lookup]shortcode, front-end assets, and the public AJAX search endpoint.LifeLines\Lookup\SettingsPage— the admin settings screen.LifeLines\Lookup\LookupSettings/Columns— configuration and the fixed column whitelist that keeps identifiers safe.
Stand the plugin down without deactivating it by adding this to wp-config.php:
define('LIFELINES_KILL', true);- Add a class under
src/(namespaceLifeLines\…). - Hook it up from
LookupBootstrap::register()(or add a new bootstrap wired in fromlifelines.php). - To broaden the dataset, extend the whitelist in
Lookup\Columnsand the table definition inLookup\TownSchema.
composer install
composer build # → build/lifelines.zip (production)
composer build:dev # includes tests
composer build:clean # clean the build directoryInstall the dev dependencies and run the suite from the plugin directory:
composer install| Command | Description |
|---|---|
composer test |
Run the Pest test suite |
composer phpstan |
Run PHPStan static analysis |
Line coverage is reported to Coveralls on every CI run — see the coverage badge at the top of this file.
MIT (Modified) — see LICENSE. The licensee may not sell the Software, alone or as part of an aggregate software distribution containing the Software.