Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
e75dba8
Added: WooCheckout monitoring feature with config API, controller, lo…
barrykooij May 20, 2026
67d9555
WooCommerce Blocks integration for probe gateway to support block-bas…
barrykooij May 27, 2026
dec8534
Fixed: email deliverability cadence stuck on 30-minute interval due t…
barrykooij Jul 9, 2026
588cffa
Merge branch 'dev' into feat/woocommerce-data
barrykooij Aug 21, 2026
4b28a5d
Fixed: probe secret mismatch by storing the API-issued secret after c…
barrykooij Aug 21, 2026
8080fca
clarify that woocheckout config sync also runs when WooCommerce is in…
barrykooij Aug 21, 2026
42add57
Fixed: exclude WooCommerce probe orders from admin order status view …
barrykooij Aug 23, 2026
4bae7ba
Added: variable product fallback to WooCommerce checkout probe produc…
barrykooij Aug 24, 2026
14eef23
Added: scheduled daily cleanup of old WooCommerce probe orders
barrykooij Aug 25, 2026
0d7f058
Added WooCheckout probe ping endpoint for pre-flight plugin verification
barrykooij Aug 26, 2026
67687f4
Added product search endpoint and API-driven billing/config for WooCo…
barrykooij Aug 26, 2026
b04175a
Added: WooCommerce flow hints
barrykooij Sep 3, 2026
194f2fb
Keep the probe gateway available on subscription checkouts
barrykooij Sep 4, 2026
9d3a2db
version bump
barrykooij Sep 6, 2026
3b071d6
Added: PHPCS, PHPStan, PHPUnit and wp-env tooling with composer scrip…
barrykooij Sep 18, 2026
52ac9b6
Fixed: PHPStan level 5 errors and false positives from untyped WordPr…
barrykooij Sep 18, 2026
bc79ba2
Fixed: PHPCS errors, unsanitized request input and debug logging that…
barrykooij Sep 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 39 additions & 14 deletions .distignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
# Files and folders NOT shipped to WordPress.org.

# VCS / CI / editor
/.git
/.github
/.gitignore
/.gitattributes
/.distignore
/.editorconfig
/.vscode
/.idea
/xdebug
/.wp-env.json

# Tooling and tests
/tests
/scripts
/docs
/xdebug
/phpcs.xml.dist
/phpstan.neon.dist
/phpstan-baseline.neon
/phpunit.xml.dist
/phpunit-integration.xml.dist
/composer.json
/composer.lock
/package.json
/package-lock.json
/node_modules

# Caches and reports
/.phpstan.cache
/.phpunit.cache
/.phpunit.result.cache
/.phpunit-integration.result.cache
/coverage
/coverage.xml
/clover.xml

# Local / Docker
DOCKER_ENV
Dockerfile-php-build
output.log

.distignore
.gitignore
.gitattributes
.editorconfig
CONTRIBUTING.md
docker-compose.yaml
composer.json
composer.lock
Dockerfile.wordpress
docker-compose.yaml
docker_tag
phpcs.xml
output.log
phpcs.txt
phpunit.xml
ruleset.xml
CONTRIBUTING.md

# OS
.DS_Store
Thumbs.db
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yml,yaml,json,md,neon}]
indent_style = space
indent_size = 2

[*.{js,jsx,ts,tsx,scss,css}]
indent_style = tab
indent_size = 4

[*.md]
trim_trailing_whitespace = false
27 changes: 25 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
# Auto detect text files and perform LF normalization
* text=auto
# Normalise line endings
* text=auto eol=lf

# Binary
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.zip binary

# Exclude from archive exports
/.github export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.distignore export-ignore
/.editorconfig export-ignore
/.wp-env.json export-ignore
/tests export-ignore
/scripts export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpunit.xml.dist export-ignore
/phpunit-integration.xml.dist export-ignore
/package.json export-ignore
54 changes: 54 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Scanfully Plugin — Copilot Instructions

## Project Overview

- WordPress plugin (PHP 7.4+, WordPress 6.0+) that connects sites to the Scanfully platform
- PSR-4 autoloading: namespace `Scanfully\` maps to `src/`
- Entry point: `scanfully.php` (loads Action Scheduler, defines the `Scanfully()` helper, hooks `plugins_loaded` at priority 20)
- Bootstrap: `src/Main.php` is a singleton (`Main::get()`); `setup()` wires the module controllers (Events, Cron, Connect, PageEdit, WooCheckout when WooCommerce is active)

## Project Structure (src/)

- `API/` — request classes to the Scanfully API; abstract `Request` base with concrete subclasses (EventRequest, SiteDataRequest, ...)
- `Connect/` — OAuth connection flow, dashboard admin page, notices, connection state
- `Cron/` — Action Scheduler job scheduling (`Cron\Controller`)
- `EmailHealth/` — email deliverability monitoring
- `Events/` — timeline event tracking; each event extends the base `Event` class with a hook name constant
- `Health/` — site health data collection and syncing
- `Options/` — plugin options (connection state, tokens, site ID)
- `PageEdit/` — post/page edit integration hooks
- `Sync/` — on-demand sync endpoint handler
- `Util/` — utilities
- `WooCheckout/` — WooCommerce probe checkout gateway (probe requests use the `X-Scanfully-Probe` header, probe orders use `_scanfully_probe_order` post meta)

## Conventions

- All hooks and filters are prefixed `scanfully_` (e.g., `scanfully_api_url`, `scanfully_auth_headers`, `scanfully_health_data`)
- Options in `wp_options` are prefixed `scanfully_connect_`
- Action Scheduler action names are class constants on `Cron\Controller` (e.g., `ACTION_SYNC_SITE_HEALTH`); all jobs use the `'scanfully'` group
- Background/scheduled work uses Action Scheduler (`woocommerce/action-scheduler` from `vendor/`), never raw WP-Cron
- API calls go through `src/API/Request.php` subclasses using `wp_remote_post()`/`wp_remote_get()` with a Bearer token from options; base URL is `Main::API_URL` (filterable)
- Text domain: `scanfully`, domain path `/languages/` (`languages/scanfully.pot`). All user-facing strings must be translatable (`__()`, `esc_html__()`, etc.)
- Keep code compatible with PHP 7.4 (no PHP 8-only syntax)
- Never use a real client's domain in examples; use `scanfully.com`

## Coding Standards & Security

- WordPress Coding Standards (WPCS 3.x) via `phpcs.xml.dist`: short array syntax `[]` is allowed, Yoda conditions are not required, and the `WordPress.Files.FileName` rule is disabled
- Classes, folders and file names are PascalCase and follow PSR-4 (class `AddressCodec` lives in `src/EmailHealth/AddressCodec.php`); functions, methods and variables are `lower_snake_case`
- Escape all output (`esc_html`, `esc_attr`, `esc_url`), sanitize all input, use nonces and capability checks for admin actions, use `$wpdb->prepare()` for queries

## Releases & Tooling

- `scripts/bump-version.sh <version>` updates the version in `readme.txt`, the `scanfully.php` header, and the `SCANFULLY_VERSION` constant
- Releasing is done via the GitHub release workflow (`.github/workflows/release.yml`), which deploys to WordPress.org SVN
- `vendor/` is not committed; run `composer install` after cloning (the release workflow runs a no-dev install)

## Quality gates

- `composer lint` / `composer lint:fix` / `composer lint:strict`: PHPCS (errors only / auto-fix / including warnings)
- `composer stan`: PHPStan (config in `phpstan.neon.dist`, WordPress, WooCommerce and Action Scheduler symbols resolved). New baseline entries need a `# BASELINE:` justification
- `composer test`: PHPUnit unit suite under `tests/Unit` (Brain Monkey via `yoast/wp-test-utils`, no WordPress runtime). Test files are PascalCase and end in `Test.php`, e.g. `tests/Unit/EmailHealth/AddressCodecTest.php`
- `npm run env:start` then `npm run test:integration`: PHPUnit integration suite under `tests/Integration`, run inside wp-env (PHP 7.4, needs Docker)
- `composer qa`: lint, stan and unit tests in one go
- CI (`.github/workflows/qa.yml`) runs these on PHP 7.4 to 8.4
137 changes: 137 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: QA

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

concurrency:
group: qa-${{ github.ref }}
cancel-in-progress: true

jobs:
baseline-drift:
name: PHPStan baseline drift
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check phpstan-baseline.neon additions are justified
shell: bash
run: |
set -euo pipefail
BASE="origin/${{ github.base_ref }}"
git fetch origin "${{ github.base_ref }}" --depth=1

# Count lines added to the baseline that look like a new ignore entry.
ADDED=$(git diff "$BASE"...HEAD -- phpstan-baseline.neon \
| grep -E '^\+[^+].*message:' \
| wc -l \
| tr -d ' ')

if [ "$ADDED" = "0" ]; then
echo "No new baseline entries. OK."
exit 0
fi

echo "Detected $ADDED new baseline entries; checking for matching BASELINE: blocks..."

JUSTIFIED=$(git diff "$BASE"...HEAD -- phpstan-baseline.neon \
| grep -E '^\+\s*#\s*BASELINE:' \
| wc -l \
| tr -d ' ')

if [ "$JUSTIFIED" -lt "$ADDED" ]; then
echo "::error::phpstan-baseline.neon grew by $ADDED entries but only $JUSTIFIED BASELINE: justifications were added."
echo "Add a '# BASELINE: <reason>' comment block per new entry, optionally followed by '# Upstream: <link>'."
exit 1
fi

echo "Baseline additions are justified. OK."

php:
name: PHP ${{ matrix.php }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
steps:
- uses: actions/checkout@v4

- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer:v2

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ matrix.php }}-

- name: Install composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- name: PHPCS (errors only)
run: composer lint

- name: PHPCS (warnings) - informational
continue-on-error: true
run: composer lint:strict

- name: PHPStan
run: composer stan

- name: PHPUnit - Unit
run: composer test

- name: Upload coverage
if: matrix.php == '8.3'
uses: actions/upload-artifact@v4
with:
name: coverage
path: |
coverage/
coverage.xml
if-no-files-found: ignore

integration:
name: PHPUnit - Integration (wp-env)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer:v2

- name: Install composer dependencies
run: composer install --prefer-dist --no-progress --no-interaction

- uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install npm dependencies
run: npm install --no-audit --no-fund

- name: Start wp-env
run: npm run env:start

- name: Run integration suite
run: npm run test:integration
27 changes: 26 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Dependencies (installed by Composer; the release workflow runs a no-dev install)
/vendor/
/node_modules/

# PHPUnit
/.phpunit.cache/
/.phpunit.result.cache
/.phpunit-integration.result.cache
/coverage/
/coverage.xml
/clover.xml

# PHPStan
/.phpstan.cache/

# Local
/tmp/
/dev/
/.idea/
phpcs.txt

# OS / Editor
.DS_Store
Thumbs.db
.idea/
.vscode/
*.swp
*~

# Logs
*.log
13 changes: 13 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"core": "WordPress/WordPress#6.8",
"phpVersion": "7.4",
"plugins": [ "." ],
"themes": [],
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": false,
"SCRIPT_DEBUG": true
},
"mappings": {}
}
36 changes: 36 additions & 0 deletions assets/js/probe-blocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Scanfully Probe — WooCommerce Blocks payment method.
*
* Registers a minimal payment method block so the probe gateway is
* selectable in block-based Cart/Checkout. The block must render an input
* whose name+value matches the underlying WC_Payment_Gateway id; Blocks
* handles that automatically via registerPaymentMethod, so the only
* requirement here is that the method be registered with the same id.
*/
( function () {
if ( typeof window.wc === 'undefined' || ! window.wc.wcBlocksRegistry ) {
return;
}
const { registerPaymentMethod } = window.wc.wcBlocksRegistry;
const { createElement } = window.wp.element;
const settings = ( window.wc.wcSettings && window.wc.wcSettings.getSetting )
? window.wc.wcSettings.getSetting( 'scanfully_probe_data', {} )
: {};

const label = settings.title || 'Scanfully Probe (test order)';
const description = settings.description || '';

const Content = () => createElement( 'div', { 'data-scanfully-probe-block': '1' }, description );

registerPaymentMethod( {
name: 'scanfully_probe',
label: createElement( 'span', null, label ),
ariaLabel: label,
canMakePayment: () => true,
content: createElement( Content, null ),
edit: createElement( Content, null ),
supports: {
features: ( settings.supports && settings.supports.length ) ? settings.supports : [ 'products' ],
},
} );
} )();
Loading
Loading