Gravity Forms Termageddon Add-On — Development Guide
====================================================

Version: 1.0.0-beta


REPOSITORY STRUCTURE
--------------------

  gravityformstermageddon.php       Plugin bootstrap
  includes/
    class-gf-termageddon-addon.php   GFAddOn — settings, hooks
    class-gf-termageddon-field.php   Custom GF_Field (termageddon_consent)
    class-gf-termageddon-api.php     Policy discovery + version hashes
    class-gf-termageddon-logger.php  Consent snapshot on submission
    class-gf-termageddon-notices.php Admin notices
    class-gf-termageddon-requirements.php
  assets/                            Field CSS/JS
  bin/
    setup-local-test.php             LocalWP smoke: pages, form, field
    test-submission.php              Entry + consent snapshot test
    swap-real-policy-keys.php        Utility for real Termageddon keys
  tests/                             PHPUnit + Playwright


REQUIREMENTS (DEV)
------------------

  - PHP 7.4+ (8.x recommended)
  - Composer
  - Node.js 24.x (see .nvmrc)
  - Gravity Forms — for integration tests
  - Termageddon WP plugin — for policy discovery tests
  - Published policy pages with embed codes — for end-to-end tests


LOCAL SETUP (LocalWP)
---------------------

1. Install and activate:
     - gravityforms
     - termageddon-usercentrics
     - gravityformstermageddon (this plugin)

2. Symlink or copy into wp-content/plugins/:

     ln -s /path/to/gravityformstermageddon \
       ~/Local\ Sites/yoursite/app/public/wp-content/plugins/gravityformstermageddon

3. Bootstrap test environment (creates/updates policy pages, test form):

     php bin/setup-local-test.php

4. Verify consent logging:

     php bin/test-submission.php

   Edit bin/lib/local-env.php if your Local site path differs.


CODE QUALITY
------------

  composer install
  composer phpcs
  composer phpstan
  composer phpunit

  PHPCS uses gravityforms/rgcodestandards (private GitHub repo; SSH required).


AUTOMATED TESTS (wp-env + Playwright)
--------------------------------------

  npm install
  npm run test:pw:start
  npm run test:pw:run

  Bundled GF copy for tests: tests/playwright/data/plugins/gravityforms/
  (Large — do not commit if cloning fresh; CI fetches GF via GitHub Actions.)


GITHUB ACTIONS
--------------

  .github/workflows/code-quality.yml
  .github/workflows/playwright.yml

  Requires BOT_DEPLOY_TOKEN secret for Gravity Forms test dependency.


BUILD RELEASE ZIP
-----------------

  From the parent GF Addons workspace:

    ./bin/build-release-zip.sh termageddon

  Output: dist/gravityformstermageddon-1.0.0-beta.zip

  Exclude: vendor/, node_modules/, tests/, tests/playwright/data/plugins/gravityforms/,
  .github/, bin/ (optional — bin/ is dev-only).


LABS AUTO-UPDATE
----------------

  _enable_rg_autoupgrade is true on GF_Termageddon_AddOn.


CODING STANDARDS
----------------

  - Tabs for PHP indentation
  - Text domain: gravityformstermageddon
  - Field type string: termageddon_consent
  - Extend GFAddOn; register field in pre_init / init
  - No runtime Composer dependencies
