Skip to content
Merged

Dev #53

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 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
b0d9ee5
Fixed: wp-env integration environment failing to build on PHP 7.4 aft…
barrykooij Sep 18, 2026
9137b97
Fixed: PHPStan baseline drift check counting the commented example en…
barrykooij Sep 18, 2026
2f5cf19
Merge pull request #52 from Scanfully/feat/phpstan
barrykooij Sep 18, 2026
9dcc619
Fixed: probe header check firing rest_api_init too early and breaking…
barrykooij Sep 18, 2026
2834ea9
Security: post passwords are no longer sent in timeline events
barrykooij Sep 18, 2026
6fcb266
Security: connect flow accepting an empty state, which let a forged l…
barrykooij Sep 18, 2026
80b364e
Fixed: connect success handler continuing to render the page after re…
barrykooij Sep 18, 2026
38f4df9
Security: API requests now verify TLS certificates
barrykooij Sep 18, 2026
872c2e9
Security: WooCheckout probe secret is cleared on disconnect and only …
barrykooij Sep 18, 2026
cac1f31
Security: stricter site ID validation in the connect flow
barrykooij Sep 18, 2026
d0f6d19
Security: WooCheckout probe headers now expire two hours after the sc…
barrykooij Sep 18, 2026
dfb8eaa
Security: on-demand sync endpoint now requires the site access token
barrykooij Sep 18, 2026
3d51c6b
Fixed: token refresh locking sites out when refreshes overlap or the …
barrykooij Sep 18, 2026
03cb57a
Fixed: deactivation leaving queued event jobs behind and queueing new…
barrykooij Sep 18, 2026
b312bf2
Added: uninstall cleanup that removes all plugin options, scheduled j…
barrykooij Sep 18, 2026
5e91667
Security: edit shortcut no longer redirects visitors who can't edit, …
barrykooij Sep 18, 2026
9c2a551
Security: WooCheckout probe account is only used while it is a plain …
barrykooij Sep 18, 2026
c94dcb8
Fixed: WooCheckout probe orders holding stock; they are now cancelled…
barrykooij Sep 18, 2026
761130f
Added: WooCommerce integration tests for probe orders, run with both …
barrykooij Sep 18, 2026
1385565
Added: WooCommerce compatibility declaration for HPOS order storage a…
barrykooij Sep 18, 2026
1a90752
Security: email deliverability checks are only sent to Scanfully ping…
barrykooij Sep 18, 2026
949653e
Fixed: email deliverability check interval from the API is kept betwe…
barrykooij Sep 18, 2026
1ed31c3
Fixed: manual email deliverability check postponing the scheduled checks
barrykooij Sep 18, 2026
5e2809c
Changed: QA workflow also runs on pushes to the dev branch
barrykooij Sep 18, 2026
7efa118
Changed: integration tests run in a separate wp-env test environment
barrykooij Sep 19, 2026
f4ac110
Fixed: probe order cleanup query ignoring its probe filter on stores …
barrykooij Sep 19, 2026
6f61a89
Fixed: WooCommerce orders, imports and bulk edits flooding the timeli…
barrykooij Sep 19, 2026
f14a1a9
Fixed: update events reported for failed installs, for Scanfully itse…
barrykooij Sep 19, 2026
1c32645
Fixed: email deliverability checks treating API problems as mail fail…
barrykooij Sep 19, 2026
bc3f505
Fixed: directory sizes reported as 0 or stale; they are now measured …
barrykooij Sep 19, 2026
054e7ce
Fixed: Scanfully settings page and WooCommerce admin saves waiting on…
barrykooij Sep 19, 2026
a028e58
Fixed: Scanfully settings page breaking on an unreadable stored date
barrykooij Sep 19, 2026
1f6288f
Security: API tokens are no longer loaded on every request
barrykooij Sep 19, 2026
b7b60ea
Fixed: token refresh resetting the connection date and last-used date
barrykooij Sep 19, 2026
44ae491
Fixed: Scanfully admin notices showing to users who can't manage the …
barrykooij Sep 19, 2026
6315f06
Fixed: recurring job checks running on every front-end request and po…
barrykooij Sep 19, 2026
ab9d004
Fixed: dates shown in UTC on sites that use a manual UTC offset
barrykooij Sep 19, 2026
4845dd8
Fixed: site ID not encoded in API URLs, and the dashboard button igno…
barrykooij Sep 19, 2026
f6538dd
Fixed: connect notices showing HTML entities for translated text with…
barrykooij Sep 19, 2026
de7aeea
Fixed: site health data raising a warning when collected under WP-CLI…
barrykooij Sep 19, 2026
45dce80
Fixed: slow user count on large sites, and database size including ot…
barrykooij Sep 19, 2026
f82a4e9
Fixed: single-file plugins reported with the slug "." in site health …
barrykooij Sep 19, 2026
f85e592
Fixed: site health reporting the raised PHP memory limit instead of t…
barrykooij Sep 19, 2026
720bb76
Fixed: publish events dropped right after a draft save, and Quick Edi…
barrykooij Sep 19, 2026
694e5b9
Fixed: rewrite rule flushes creating repeated timeline events
barrykooij Sep 19, 2026
d865e0b
Fixed: oversized timeline events being dropped, and update events cra…
barrykooij Sep 19, 2026
fe25d5b
Fixed: timeline events silently lost when the API rejects them; tempo…
barrykooij Sep 19, 2026
763603e
Security: WooCheckout ping and product search only sign for the scan …
barrykooij Sep 19, 2026
3e1c714
Fixed: WooCheckout probe orders being sent to WooCommerce webhooks
barrykooij Sep 19, 2026
e1f92b9
Security: WooCheckout probe responses are never stored by page caches
barrykooij Sep 19, 2026
6c91656
Fixed: WooCheckout loading on unsupported WooCommerce versions, produ…
barrykooij Sep 19, 2026
3d42f03
Fixed: email deliverability checks with a guessable nonce, slow trans…
barrykooij Sep 19, 2026
caa23ac
Security: site API tokens are revoked on disconnect, reconnect and un…
barrykooij Sep 21, 2026
d8ef3c3
Fixed: email deliverability toggle button and last API error date mis…
barrykooij Sep 21, 2026
9b19aa6
changelog
barrykooij Sep 21, 2026
d29e1ee
version bump to 1.7.0
barrykooij Sep 21, 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:test:start` then `npm run test:integration`: PHPUnit integration suite under `tests/Integration`, run in a separate wp-env test environment (`.wp-env.test.json`, port 8889; latest WordPress and WooCommerce on PHP 7.4, needs Docker). `npm run env:start` starts the development site (`.wp-env.json`, port 8888), which the tests never touch. `npm run test:integration:all` runs it with both WooCommerce order storages (legacy posts and HPOS); CI does the same
- `composer qa`: lint, stan and unit tests in one go
- CI (`.github/workflows/qa.yml`) runs these on PHP 7.4 to 8.4
143 changes: 143 additions & 0 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: QA

on:
push:
branches: [main, dev]
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.
# Commented lines (such as the example in the file header) are skipped.
ADDED=$(git diff "$BASE"...HEAD -- phpstan-baseline.neon \
| grep -E '^\+[[:space:]]*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 (test environment)
run: npm run env:test:start

# WooCommerce stores orders either in posts (legacy) or in its own
# tables (HPOS); the WooCheckout code has separate paths for both.
- name: Run integration suite (legacy order storage)
run: npm run test:integration:legacy

- name: Run integration suite (HPOS order storage)
run: npm run test:integration:hpos
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
17 changes: 17 additions & 0 deletions .wp-env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"core": null,
"phpVersion": "7.4",
"plugins": [
".",
"https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip"
],
"themes": [],
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": false,
"SCRIPT_DEBUG": true
},
"mappings": {},
"testsEnvironment": false
}
18 changes: 18 additions & 0 deletions .wp-env.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"core": null,
"phpVersion": "7.4",
"plugins": [
".",
"https://downloads.wordpress.org/plugin/woocommerce.latest-stable.zip"
],
"themes": [],
"config": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": true,
"WP_DEBUG_DISPLAY": false,
"SCRIPT_DEBUG": true
},
"mappings": {},
"testsEnvironment": false,
"port": 8889
}
Loading
Loading