Skip to content

Releases: lukehsuhao/power-agreement

v0.4.1 — larger modal consent label + checkbox

Choose a tag to compare

@lukehsuhao lukehsuhao released this 05 May 12:09

Bump the in-modal consent line to font-size 1.1em and the checkbox to 1.3em so the primary gesture in the dialog stands out. CSS-only; outer in-page consent stays at theme size.

v0.4.0 — Button colour setting + 'Read agreement' label

Choose a tag to compare

@lukehsuhao lukehsuhao released this 05 May 09:44

Two merchant-driven changes:\n\n1. Renamed the expand button from "Expand to view" / 全部展開 → "Read agreement" / 閱讀合約.\n2. New admin setting: Button colour (color picker). Applies to the "Read agreement" CTA and the modal's "Confirm" button. Default unchanged (#1f2937 dark grey). Hover automatically darkens via CSS filter: brightness(0.88) so any picked colour gets a sensible hover state.\n\nSee CHANGELOG.md for full details.

v0.3.3 — anchor-based triggers survive over-aggressive sanitisers

Choose a tag to compare

@lukehsuhao lukehsuhao released this 05 May 09:27

Some checkout-customising plugins (Flexible Checkout Fields, Conditional Payments, certain caching layers) strip non-submit <button> elements from the order-review HTML, making the modal unreachable. Switched the Expand / Close / Confirm controls to <a role="button"> — anchors survive that filtering. See CHANGELOG.md for the full diagnosis.

v0.3.2 — fix relocate on cart-on-checkout pages

Choose a tag to compare

@lukehsuhao lukehsuhao released this 05 May 09:16

Hardens the relocate helper introduced in 0.3.1: anchors strictly to [name="woocommerce_checkout_place_order"] (so coupon / update-cart buttons never grab the slot) and dedupes duplicate wrappers when WC's order-review hook fires twice. See CHANGELOG.md for full details.

v0.3.1 — Custom-layout compatibility (Elementor / FunnelKit / etc.)

Choose a tag to compare

@lukehsuhao lukehsuhao released this 05 May 09:11

What's new in 0.3.1

A compatibility patch for custom checkout layouts.

The problem

A merchant testing 0.3.0 reported that on their production site (Elementor Pro Checkout widget + Flexible Checkout Fields) the agreement appeared in the order-summary area at the top of the page — about 1000 px above the actual "確認送出" / Place order button.

The root cause: woocommerce_review_order_before_submit is the canonical WooCommerce hook for "directly before the place-order button" on stock Classic Checkout (it's the same hook the built-in Terms and conditions feature uses). But it bakes in the assumption that the standard .form-row.place-order slot is where the button lives. Custom layouts move the button hundreds of pixels away, so the hook fires in what's now the wrong place.

The fix

A small client-side helper (relocate.js) that runs after the page loads and after every updated_checkout ajax fragment refresh. It:

  1. Finds the form's actual submit button — preferring [name="woocommerce_checkout_place_order"] / #place_order, falling back to the last <button|input type="submit"> in the form (excluding controls inside our own modal so we never anchor to the agreement dialog's "Confirm" button).
  2. Reinserts the agreement wrapper as the immediate previous sibling of that button's row.

Re-runs on:

  • DOMContentLoaded
  • window.load (catches plugins that inject late)
  • jQuery updated_checkout (the official WC channel)
  • native updated_checkout (some themes re-emit it on document)
  • a debounced MutationObserver on <body> as a safety net for heavily-customized checkouts that disable WC's standard ajax flow entirely

What stays the same

  • PHP rendering hook is unchanged. Stock Classic Checkout sees no behavioural change because the wrapper is already adjacent to the submit button on first render — the relocate helper short-circuits when there's nothing to move.
  • Server-side gate is untouched. ConsentValidator and the Store API extension still hold the line. This is purely a client-side cosmetic fix.

Compatibility

  • WordPress 6.5 → 6.9
  • WooCommerce 8.3+
  • PHP 8.1+
  • Verified against: Elementor Pro Checkout widget, Flexible Checkout Fields. Should also handle FunnelKit Funnel Builder, Cartflows, theme template overrides, and similar layouts.

Tests

  • 13 unit + 49 integration green; no test changes needed because PHP render is unchanged.

Full diff: v0.3.0...v0.3.1

v0.3.0 — Self-hosted updater + compact 'Expand to view' card

Choose a tag to compare

@lukehsuhao lukehsuhao released this 05 May 08:41

What's new in 0.3.0

Two user-driven changes after live testing on a real WooCommerce store.

1. Self-hosted update mechanism

The plugin no longer needs a wp.org listing to receive updates. From this release onward, every installed copy polls this repo's Releases feed via yahnis-elsts/plugin-update-checker. When a new tag with a power-agreement-X.Y.Z.zip asset is published:

  • The merchant sees an update prompt in the standard Plugins → Update screen.
  • One click installs the new version through WordPress's normal update flow (download asset → unpack → activate).

That's it — no FTP, no manual replacement, no per-site magic.

2. Inline-scroll mode redesigned as a compact card

The 240 px scrollable preview is gone. The agreement now shows as a single-line card with the title on the left and a clear "Expand to view" (繁中:全部展開) button on the right. Clicking the button opens the same full-size modal we already had — with the synced inner consent checkbox and Confirm action.

Why: in live testing the previous scrollable preview "looked already-fully-expanded" because customers could scroll inside it; the explicit button makes the affordance unambiguous and renders cleanly inside any host-theme payment box.

The accordion mode is unchanged. The display_mode setting still accepts both values; existing data needs no migration.

What got removed

  • The power-agreement__preview-* markup and CSS (header / body / role="button" scaffolding).
  • The document-level keydown handler in inline-scroll.js — the new real <button> element handles Enter/Space natively.

Hook position (re-confirming)

Rendering still happens via woocommerce_review_order_before_submit, which is WooCommerce's canonical hook for "directly before the place-order button" on Classic Checkout — the same hook WooCommerce's built-in Terms and conditions feature uses.

Compatibility

  • WordPress 6.5 → 6.9
  • WooCommerce 8.3+ (HPOS declared compatible)
  • PHP 8.1+

Tests

  • 13 unit + 49 integration (HPOS on/off matrix) ✅
  • PHPCS + PHPStan level 8: 0 errors ✅
  • Live verification: see docs/screenshots/17-frontend-compact-card.png and docs/screenshots/18-frontend-compact-modal.png in this commit.

Full diff: v0.2.0...v0.3.0

v0.2.0 — Inline scrolling preview + modal redesign + zh_TW i18n

Choose a tag to compare

@lukehsuhao lukehsuhao released this 05 May 07:04

What's new in 0.2.0

A major UX revamp driven by user feedback during live testing on a real WooCommerce store.

Inline scrolling preview (new default display mode)

Previously every checkout displayed the agreement as a collapsed accordion that the customer had to click to see anything. Some stores wanted the agreement to be visible from the start — just preview-sized, without dominating the checkout column.

This release adds a second display mode, Inline scrolling preview, set as the default for new installs:

  • A 240 px scrollable box shows the start of the agreement immediately. The customer can scroll to read the full text in place.
  • Clicking the box opens a native <dialog> modal with the full agreement at a comfortable reading width — focus trap, ESC to close, and a proper backdrop come for free from the browser.
  • Heading typography inside the preview is intentionally flattened (h1h6 rendered at 1em with 600 weight) so the excerpt reads as a single flat flow. The full-size modal keeps the original heading sizes — that's the "real reading view".

The classic accordion mode is still available as a one-click choice in WooCommerce → Power Agreement → Display mode.

Two-way synced consent checkbox

The modal now contains a mirrored consent checkbox alongside the Confirm button. Customers can tick from either the outer (page-level) checkbox or the inner (modal) one, and the two stay in sync in real time. The form-submitted state is the outer checkbox; the inner one is a UI mirror without a name attribute so we never double-submit. Behaviour is identical between Classic and Block Checkout.

Modal redesign

Replaced the default-styled "Close" button (which inherited Storefront's full-width .button class and broke on themes with strong button styling) with a plugin-owned .power-agreement__confirm-btn: fixed dark background, white label, focus ring, hover/active states. Host themes can no longer override the modal's controls.

Full Traditional Chinese coverage

Both PHP and React strings are now translated for zh_TW. JavaScript translations ship as a JSON file produced via wp i18n make-json, so wp_set_script_translations() picks them up automatically when the WordPress site locale is set to Traditional Chinese.

Hardening

  • defined( 'ABSPATH' ) || exit; guards on every class file (was missing on five files in src/).
  • Explicit sanitize_text_field on the consent $_POST field — already safe by virtue of the '1' comparison, but Plugin Check now passes cleanly.
  • Bumped Tested up to to WordPress 6.9.
  • New .distignore excludes dev tooling from the production zip.

CI fixes (under the hood)

  • The integration matrix and E2E jobs now retry wp-env start up to 3 times to ride out the wp.org HTTP 429 rate-limiting that was failing CI on busy runner days.
  • The i18n .pot drift check now builds the production JS bundle first so it sees the same input set as the local generator.

Compatibility

  • WordPress 6.5 → 6.9
  • WooCommerce 8.3+ (HPOS declared compatible, tested on both HPOS-on and HPOS-off matrices)
  • PHP 8.1+

Tests

  • 13 unit + 49 integration (HPOS on/off matrix), 0 PHPStan level 8 / PHPCS errors.

Full diff: v0.1.0...v0.2.0