=== BranchHarbor Connector ===
Contributors: branchharbor
Tags: locations, class schedule, restaurant menu, multi-location, woocommerce
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.2.0
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Add BranchHarbor location finders, opening hours, class schedules, menus, booking buttons and enquiry forms that match your theme or brand.

== Description ==

BranchHarbor helps independent businesses, multi-location operators and franchise networks run their locations from one place. This connector lets you keep your existing WordPress site and theme while adding BranchHarbor content and connections.

**This plugin is a connector to the BranchHarbor service.** It needs a BranchHarbor account (or, for public content only, your organisation's public BranchHarbor address). See "External services" below for exactly what is sent and when.

= What you get =

* **Blocks and shortcodes** — Location finder, Opening hours, Class schedule, Book button, Menu, Pickup order button and an Enquiry / demo form. They work in the block editor and, through shortcodes, in Elementor, Divi, Beaver Builder and the classic editor.
* **Layouts for every block** — for example the location finder as a list, cards, map + list or a compact list; opening hours as a table, one line or a card; schedules as a list, table, cards or day tabs; menus as a list, cards, category tabs or a classic menu with dotted leaders; forms stacked, in two columns, minimal or boxed. Pick them in the block's Layout or Styles panel (with live previews) or with `layout="…"` in a shortcode.
* **Looks native, or on brand** — by default blocks use your theme's colours, fonts, spacing and buttons (theme.json presets in block themes, the editor palette and inherited styles in classic themes). Switch BranchHarbor → Design to "Use my brand colours" to choose primary, accent, text and card colours (or your BranchHarbor account's brand colours), button style and shape, card style, corner radius, density and fonts, with a live preview and WCAG AA contrast warnings. Each block can still override colours, typography, spacing and borders.
* **Guided connection** — consent, a local compatibility scan, least-privilege authorisation, location mapping, per-data-type direction choices and end-to-end connection tests.
* **Honest compatibility** — a published matrix with the labels Tested, Limited support, Requires setup, Planned and Unsupported. Nothing outside the matrix is claimed to work.
* **Multisite** — authorise the network once and map each site to a location explicitly, with clear mapping errors (for example a site in Pacific time mapped to a location in Eastern time).
* **WooCommerce (read-only)** — optionally share product and order totals with BranchHarbor for reporting, using WooCommerce APIs. Compatible with High-Performance Order Storage and cart/checkout blocks. Your checkout stays exactly as it is; no second checkout is added and customer personal details are not sent.
* **Status you can act on** — connected, initial sync, degraded, disconnected or authorisation expired, with the last successful sync, records waiting and a recovery action.

= What it never does =

* It does not contact BranchHarbor until an administrator connects and agrees to data processing.
* It does not disable, reconfigure or replace other plugins, and it does not overwrite your posts or pages.
* It does not copy your customer lists.
* It does not add ads, analytics or tracking to your site.
* It does not output SEO titles, canonical links or sitemaps — your SEO plugin stays in charge.
* The "Powered by BranchHarbor" credit is off unless you turn it on.
* It does not load fonts, maps or anything else from third-party services on its own. The optional map in the "Map + list" layout loads only after a visitor clicks "Show map".

= Performance =

Pages never wait for BranchHarbor. Content is cached on your site and refreshed in the background (WP-Cron, or Action Scheduler when WooCommerce provides it). BranchHarbor notifies your site when schedules or menus change so the cache stays current. Block styles and scripts load only on pages that use BranchHarbor blocks, and the CSS only styles BranchHarbor blocks.

== External services ==

This plugin connects to the **BranchHarbor API** (`https://api.branchharbor.com`) and, during the optional authorisation redirect, to the **BranchHarbor app** (`https://app.branchharbor.com`). Both are operated by BranchHarbor. No request is made before an administrator agrees to data processing on BranchHarbor → Connect.

What is sent, and when:

* **When you connect** (authorisation redirect or connection code): this site's address, REST API address, name, time zone, language, WordPress version, plugin version and whether it is a Multisite network, plus the one-time code. In return the site receives a site-scoped token stored in your database (encrypted with your site's salts).
* **When you save mapping, data directions or run a compatibility scan**: the chosen location mapping, data directions, SEO ownership choice and the list of detected plugin names, versions and compatibility status (not their settings).
* **When a visitor submits a BranchHarbor enquiry or demo form**: the fields the visitor filled in (for example name, email, phone, message, business name, number of locations, country, website and the marketing consent choice), the page address and the form's location. If BranchHarbor is unavailable, the submission is stored on your site for up to 7 days and retried, then deleted.
* **In the background, while connected**: requests for public content — your organisation's locations, class schedules, menus and pickup times. No visitor data is included in these requests.
* **If WooCommerce sync is turned on** (WordPress → BranchHarbor): product details (name, SKU, price, stock) and order details (number, status, totals, currency, line items, timestamps, whether the customer is registered). Customer names, emails, phone numbers and addresses are not sent.
* **When you run connection tests**: a reachability check and, with a full connection, a request for a signed test event.
* **When you disconnect**: a request to revoke this site's token.

BranchHarbor sends signed event notifications to `/wp-json/branchharbor/v1/webhook` on your site (for example "schedule updated"). They only clear cached content.

Booking and pickup buttons link visitors to pages hosted by BranchHarbor for the selected location.

**OpenStreetMap (optional, visitors only).** The location finder's "Map + list" layout shows a local sketch of your locations. Only when a visitor clicks "Show map" (or "Show on map") does their browser load an embedded map from `https://www.openstreetmap.org/export/embed.html`; the request contains the map area and marker position of your locations and, like any web request, the visitor's IP address. No other layout contacts OpenStreetMap. "Directions" links open Google Maps only when clicked.

* OpenStreetMap terms: https://wiki.osmfoundation.org/wiki/Terms_of_Use
* OpenStreetMap privacy policy: https://osmfoundation.org/wiki/Privacy_Policy
* Google Maps terms: https://policies.google.com/terms

* BranchHarbor terms of service: https://branchharbor.com/legal/terms
* BranchHarbor privacy policy: https://branchharbor.com/legal/privacy
* Data processing agreement: https://branchharbor.com/legal/dpa

== Installation ==

1. Install and activate the plugin from Plugins → Add New, or upload the `branchharbor` folder to `/wp-content/plugins/`.
2. Open BranchHarbor in the WordPress menu and choose Connect.
3. Read what is shared and agree to data processing.
4. Scan the site, then connect with BranchHarbor (or paste a connection code, or choose "Public content only").
5. Map this site to a BranchHarbor location, choose data directions and run the tests.
6. Add BranchHarbor blocks to your pages.

On Multisite, network-activate the plugin and use Network Admin → BranchHarbor to authorise the network and map each site.

= Cache and security plugins =

Exclude `/wp-json/branchharbor/` from page caching and minification, and allow POST requests to `/wp-json/branchharbor/v1/webhook`. Pages that contain BranchHarbor blocks can stay cached. The connection test tells you if something is intercepting the route.

= Optional: Application Password =

To let BranchHarbor read WooCommerce data from your site on demand, create a user with the "BranchHarbor Connector" role (it can only read BranchHarbor endpoints) and create an Application Password for that user from the link on the Connect tab. Never use an administrator account for this.

== Frequently Asked Questions ==

= Does the plugin work without a BranchHarbor account? =

The plugin connects your site to the BranchHarbor service. Without an account you can use "Public content only" for a business that already publishes on BranchHarbor. Location enquiries, WooCommerce sync and instant updates need a full connection.

= Will it change my WooCommerce checkout? =

No. Orders are read through WooCommerce APIs and sent for reporting only. Nothing is written back and no checkout is added.

= What happens if BranchHarbor is unreachable? =

Blocks keep showing the last copy that loaded. Enquiries are queued on your site and retried. The Overview tab shows the status, the last successful sync and a recovery action.

= What happens when I disconnect or delete the plugin? =

Disconnecting revokes the site token. BranchHarbor blocks show a short "temporarily unavailable" message; your pages are untouched. Deleting the plugin always removes credentials, queued enquiries and cached content; settings are kept only if you chose to keep them.

= Can the blocks match my brand or my theme? =

Yes. Out of the box they follow your theme. Under BranchHarbor → Design you can switch to your brand colours, choose button, card, spacing and font options and see a live preview, with a warning if a colour combination is hard to read. In the editor each block has several layouts and supports the usual colour, typography, spacing and border controls.

= Which languages are supported? =

The plugin is translation-ready (text domain `branchharbor`). Blocks currently show in the site's default language; WPML and Polylang mapping is planned.

== Screenshots ==

1. Guided connection (consent, detect, authorise, map sites, data, test, done), shown at the connection-test step.
2. Compatibility matrix with status labels.
3. Class schedule block in the editor.
4. Overview with connection status and recent activity.

== Changelog ==

= 1.2.0 =
* New: BranchHarbor has its own admin menu (old Settings links are redirected), a new look in BranchHarbor colours with a welcome screen, block previews, one-click shortcode copy and three short walkthrough videos included in the plugin (nothing is loaded from other sites).
* New: BranchHarbor → Design — keep blocks matching your theme, or use your brand colours (one click to use your BranchHarbor account's brand colours), with button style and shape, card style, corner radius, density and font options, a live preview using your theme's styles and WCAG AA contrast warnings.
* New: layouts for every block, registered as block styles with previews: location finder (list, cards, map + list, compact), class schedule (list, table, cards, day tabs), menu (list, cards, category tabs, classic menu), enquiry form (stacked, two columns, minimal, boxed), buttons (filled, outline, soft, text link). Shortcodes accept `layout="…"`.
* New: Opening hours block and `[branchharbor_opening_hours]` (table, inline, card) with an "Open now" status in the location's time zone; the location finder shows today's hours and directions.
* New: blocks support colour, typography, spacing, border and shadow controls, plus per-block brand colours, card style and density.
* New: try blocks before you connect — people who can edit the site see sample content with a prompt to connect (it opens in a new tab, as signing in cannot complete inside the editor). Visitors see nothing until the site is connected.
* New: shortcodes are drawn live inside the Elementor editor, with your layouts and design settings.
* Changed: blocks now follow your theme's palette, fonts, spacing scale and button styles by default instead of the plugin's own teal; choose "Use my brand colours" under BranchHarbor → Design for a fixed brand look.
* Improved: CSS loads in the page head only where blocks are used; layouts respond to the width of the column they are in; right-to-left support; bundled files carry a version that changes with every update, so caches never show an old design.

= 1.0.0 =
* First release: guided connection, compatibility scan, Multisite mapping, six blocks with shortcodes, signed webhooks, queued enquiries, read-only WooCommerce export.

== Upgrade Notice ==

= 1.2.0 =
New BranchHarbor menu, block layouts, a Design page and an Opening hours block. Block buttons and accents now follow your theme's colours; for a fixed brand look choose "Use my brand colours" under BranchHarbor → Design.

= 1.0.0 =
First release.
