You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -20,6 +21,7 @@ composer zip # Create distribution zip
20
21
```
21
22
22
23
### JavaScript/CSS
24
+
23
25
```bash
24
26
npm run build # Build JS/CSS assets with wp-scripts
25
27
npm run build:assets # Minify CSS/JS and generate RTL CSS (node build-assets.js)
@@ -33,30 +35,35 @@ npm run zip # Create plugin zip via wp-scripts
33
35
## Architecture
34
36
35
37
### Entry Point & Bootstrap
38
+
36
39
`freemkit.php` defines constants (`FREEMKIT_VERSION`, `FREEMKIT_PLUGIN_FILE`, `FREEMKIT_PLUGIN_DIR`, `FREEMKIT_PLUGIN_URL`), loads Kit shared library classes from `vendor/convertkit/convertkit-wordpress-libraries/`, registers the autoloader, and calls `\WebberZone\FreemKit\load()` on `plugins_loaded`.
37
40
38
41
**Autoloader convention:** Namespace segments become path segments under `includes/`; underscores → hyphens, lowercase, last segment prefixed with `class-`. e.g. `WebberZone\FreemKit\Admin\Settings` → `includes/admin/class-settings.php`.
39
42
40
43
### Core Components
44
+
41
45
-**`Main`** (`includes/class-main.php`) — Singleton. Instantiates `Runtime`, `Kit_Credential_Hooks`, and `Language_Handler`; registers hooks via `Hook_Registry`.
42
46
-**`Runtime`** (`includes/class-runtime.php`) — Initializes `Database`, `Kit_API`, and `Webhook_Handler` on `init`. Creates the `Admin` object when in admin context.
43
47
-**`Webhook_Handler`** (`includes/class-webhook-handler.php`) — Core logic. Registers a REST endpoint at `freemkit/v1/webhook` (or a query-var fallback). Validates HMAC-SHA256 signatures (`x-signature` header) and webhook freshness (15-minute window). Queues events as WP transients and processes them asynchronously via WP-Cron (`freemkit_process_webhook_event`). Includes deduplication via `freemkit_webhook_seen_*` transients, and exponential-backoff retry (max 3 attempts).
44
48
-**`Database`** (`includes/class-database.php`) — Manages the `{prefix}freemkit_subscribers` custom table, which persists subscriber records locally.
45
49
-**`Options_API`** (`includes/class-options-api.php`) — All settings stored as a single `freemkit_settings` array in `wp_options`. Access via `Options_API::get_option($key)` / `Options_API::get_settings()`. Sensitive keys (access/refresh tokens) are encrypted at rest using AES-256-CBC (OpenSSL) or libsodium.
46
50
47
51
### Kit Integration (`includes/kit/`)
52
+
48
53
-**`Kit_API`** — Wraps `ConvertKit_API_V4` to subscribe users to forms and apply tags.
49
54
-**`Kit_Settings`** — Manages OAuth tokens (`kit_access_token`, `kit_refresh_token`). Falls back to the official Kit WordPress plugin's stored credentials if available.
50
55
-**`Kit_Credential_Hooks`** — Listens for `freemkit_api_get_access_token` / `freemkit_api_refresh_token` / `convertkit_api_access_token_invalid` actions to keep tokens in sync.
51
56
-**`Kit_Audit_Log`** — Logs Kit API interactions.
52
57
53
58
### Admin (`includes/admin/`)
59
+
54
60
-**`Admin`** — Admin menu, settings page, subscriber list screen.
55
61
-**`Settings`** / **`Settings_Wizard`** — Settings pages; wizard is shown on first activation. Settings include: global Kit form/tag defaults, per-plugin overrides (free and paid form IDs, tag IDs, event types), custom field mappings, webhook endpoint type (REST vs query-var).
56
62
-**`Kit_OAuth`** — OAuth flow for connecting to Kit.
57
63
-**`Subscribers_List`** / **`Subscribers_List_Table`** — Admin screen displaying the local `freemkit_subscribers` table.
58
64
59
65
### Utilities (`includes/util/`)
66
+
60
67
-**`Hook_Registry`** — Static registry for all registered actions/filters; prevents duplicates (same pattern as CRP).
0 commit comments