## Fail2Notify Monorepo Notes

（日本語は英語の下に併記しています）

```
fail2notify-core/                  Shared Composer library
wp-content/plugins/fail2notify/    Free (wp.org) plugin
wp-content/plugins/fail2notify-pro Pro plugin
```

### 1. Install dependencies during development

### 1. 開発時の依存関係インストール

From each plugin directory run Composer so the PSR-4 classes from `fail2notify-core` are autoloaded. If Composer is not on your `PATH`, you can rely on the local `composer.phar` that lives one level above WordPress (`php ../../../composer.phar …`).

各プラグイン直下で `composer install` を実行し、`fail2notify-core` の PSR-4 クラスを自動読み込みに登録します。環境に Composer が入っていない場合は、WordPress 直上にある `composer.phar` を使い `php ../../../composer.phar install` のように呼び出せます。

```bash
cd wp-content/plugins/fail2notify
composer install

cd ../fail2notify-pro
composer install
```

Both plugins now bootstrap the shared `F2N\Core\{Config,Plugin,Admin,Logger}` classes and expose the same filters:

| Hook | Purpose |
| ---- | ------- |
| `{$slug}/notifiers` | Add/remove notifier instances before a payload is dispatched. |
| `{$slug}/settings_fields` | Inject additional settings fields. |
| `{$slug}/sanitize_settings` | Sanitize extra fields. |
| `fail2notify_pro/channel_notifiers` | Pro-only helper for registering premium channels (Chatwork/LINE/Teams/Google Chat). |

The free edition uses a log limit of 20 (`Config::logLimit = 20`) while the Pro config passes `null` so logs are unlimited and ready for a CPT/DB backend later.

Free 版は `Config::logLimit = 20` で 20 件のログをキープ、Pro 版は `log_limit => null` を渡しており、将来的に CPT や専用 DB へ移行しても無制限で扱えるようにしています。

### 2. Building distributable zips

### 2. 配布用 ZIP のビルド

Each plugin ships with `composer build`, which calls `bin/build-release.php`.

各プラグインは `composer build` を持っており、内部で `bin/build-release.php` を呼び出します。

```bash
cd wp-content/plugins/fail2notify
COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev --optimize-autoloader
composer build          # produces dist/fail2notify.zip

cd ../fail2notify-pro
COMPOSER_MIRROR_PATH_REPOS=1 composer install --no-dev --optimize-autoloader
composer build          # produces dist/fail2notify-pro.zip
```

Pass `--skip-composer` to `bin/build-release.php` when you already ran the install step. The script copies the plugin directory (without dev folders such as `bin`/`dist`) and zips it so the WordPress.org submission contains the vendor tree with the shared core embedded.

すでに `composer install` 済みの場合は `bin/build-release.php --skip-composer` を指定できます。スクリプトはプラグインディレクトリから `bin` や `dist` などを除外した内容をコピーし、共有コアを含む `vendor/` 付きの ZIP を生成します。これを WordPress.org 提出物として利用してください。

### 3. Adding premium-only functionality

### 3. Pro 専用機能の追加方針

1. Register new settings fields via `add_filter( $config->hook( 'settings_fields' ), … )`.
2. Persist values through `add_filter( $config->hook( 'sanitize_settings' ), … )`.
3. Push notifier instances (implementing `F2N\Core\Notifiers\NotifierInterface`) into the `$notifiers` array in the `fail2notify_pro/channel_notifiers` filter.
4. For unlimited logging backends replace `F2N\Core\Logger` with your own implementation and inject it into the Pro bootstrap—`Plugin` only requires that the injected logger exposes `push()` and `all()` just like the default class.

1. 新しい設定フィールドは `add_filter( $config->hook( 'settings_fields' ), … )` で追加します。
2. 保存時のサニタイズは `add_filter( $config->hook( 'sanitize_settings' ), … )` で拡張します。
3. Pro 限定の通知チャンネルは `fail2notify_pro/channel_notifiers` で `F2N\Core\Notifiers\NotifierInterface` 実装を `$notifiers` 配列へ追加します。
4. 無制限ログや別ストレージに切り替える場合は、`F2N\Core\Logger` の代わりに独自クラスを作成し Pro ブートストラップへ注入します。`Plugin` が必要とするのは `push()` と `all()` メソッドのみです。

This keeps Free/Pro in sync while letting Pro bolt on premium features without touching the shared library.

これにより Free / Pro で同じコアを共有しつつ、Pro 側だけにプレミアム機能を積み重ねることができます。
