# Form Enhancer Pro

A WordPress plugin that extends **Fluent Forms** (and **Fluent SMTP**) with additional fields, integrations, and features — built with PHP 8.1+, PSR-4 autoloading, dependency injection, and scoped vendor dependencies.

> **Note:** The canonical, user-facing readme for the WordPress.org plugin directory is [`readme.txt`](readme.txt) — it holds the description, "Stable tag", and the official changelog, and the release pipeline parses it. This `README.md` is for developers working in the repo. End-user docs live at [formenhancer.com](https://formenhancer.com).

## Architecture

| Path | Purpose |
| --- | --- |
| `src/` | Free version classes (namespace `FormEnhancer\`) |
| `srcPro/` | Pro version classes (namespace `FormEnhancerPro\`) |
| `srcDepsPro/` | Composer dependencies for the Pro version (stripped at build) |
| `vendor/deps/` | Scoped dependencies for the free version |
| `vendor/depsPro/` | Scoped dependencies for the Pro version |
| `tests/unit/` | PHPUnit tests (WP_Mock) |

Pro features are conditionally loaded via Freemius `is__premium_only()` checks and the separate namespace/directory split. The DI container is created in `formenhancer_container()`.

See [`CLAUDE.md`](CLAUDE.md) for deeper architectural notes (conditional logic layers, integration conventions, Ecomail API specifics).

## Development

```bash
# Coding standards (WordPress + Eightshift)
composer standards:check
composer standards:fix

# Unit tests
composer test
composer test:report        # text coverage
composer test:report:html   # HTML coverage

# Pro scoped dependencies
composer install-deps       # install srcDepsPro into vendor/depsPro
composer update-deps        # regenerate HubSpot field list + update deps

# JavaScript
npm run build               # production build
npm run start               # watch / dev mode
```

Requirements: PHP 8.1+, Node/npm, Composer.

## Versioning

The version lives in **three** places that must stay in sync:

- `formenhancer.php` plugin header (`Version:`)
- `formenhancer.php` constant (`define('FORMENHANCER_VERSION', …)`)
- `readme.txt` (`Stable tag:`)

`make version-bump` updates all three at once (auto-suggests the next patch, accepts a custom value such as `1.4.0-alpha`). Pre-release versions with a `-suffix` intentionally leave `Stable tag` unchanged.

## Release workflow

The release is orchestrated through the `Makefile` and `scripts/`:

### 1. `make version-bump` — `scripts/version-bump.sh`
Bumps and synchronizes the version across the three sources above.

### 2. `make release` — `scripts/release.sh`
Builds the distributable zip at `build/formenhancer-<version>.zip`:
- runs `npm run build`
- copies the plugin to a temp dir, excluding dev-only files (`.git`, `scripts`, `vendor`, `node_modules`, `.claude`, `CLAUDE.md`, `docs`, `Makefile`, `.env`, …)
- runs `composer install --no-dev` and `composer run install-deps` (the scoped Pro-deps step)
- strips files disallowed by WordPress.org (vendor `bin/`, `tests/`, `examples/`) and removes `srcDepsPro`, `package.json`, `phpcs.xml`, `phpunit.xml`
- zips the result into `build/`

### 3. `make release-deploy` — `scripts/release-deploy.sh`
The full pipeline. Must run on `main` with a clean working tree.
1. Reconciles the three version sources (warns on mismatch).
2. Pushes `main`, then creates and pushes the git tag `v<version>`.
3. Builds the zip (`release.sh`).
4. Generates GitHub release notes by extracting the version's changelog block from `readme.txt` and formatting it via `claude -p`.
5. Creates the GitHub release (`gh release create`) with the zip attached.
6. Prompts for the **Freemius** release mode (beta / production / skip) and uploads via the Freemius PHP SDK, with secrets injected from **1Password** (`op run --env-file .env`).
7. On a **production** release, optionally deploys the free/stripped build to **WordPress.org SVN** (waits ~60s for Freemius to build the free version, then runs `wporg-deploy.sh`).

`scripts/release-deploy.sh --freemius-only` skips git/GitHub and re-uploads an existing zip (useful for testing the Freemius step).

### 4. `make wporg-deploy` — `scripts/wporg-deploy.sh`
Pushes the free version to the WordPress.org SVN repository.

### Prerequisites
- [1Password CLI](https://developer.1password.com/docs/cli/) (`op`) installed and signed in
- `.env` file with `op://` secret references (Freemius dev/public/secret keys, plugin ID)
- [GitHub CLI](https://cli.github.com/) (`gh`) authenticated
- `claude` CLI (for formatting release notes)
- `freemius/php-sdk` dev dependency (`composer require --dev freemius/php-sdk`)

## License

GPLv3 or later.
