Skip to content

Commit 7e80133

Browse files
committed
Update AGENTS.md and CLAUDE.md to reflect Pro plugin structure and Freemius integration
- Change plugin description from "free WordPress plugin" to "WordPress plugin" with freemium model - Remove "no includes/pro/ directory" note; add Pro features location and @fs_premium_only marker - Update build commands: add build:pro, clarify build:assets usage, document selective asset building flags - Add build-assets.js usage instructions with --css, --js, --rtl, --no-rtl flags and file/directory targeting
1 parent c50f9e2 commit 7e80133

2 files changed

Lines changed: 62 additions & 36 deletions

File tree

AGENTS.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ This file provides guidance to Codex (Codex.ai/code) when working with code in t
44

55
## Plugin Overview
66

7-
WebberZone Knowledge Base (v3.0.0) is a free WordPress plugin (namespace `WebberZone\Knowledge_Base`) that creates a multi-product knowledge base system. This is the standalone free version — there is no `includes/pro/` directory here. The companion premium plugin (knowledgebase-pro) is a separate repository that extends this codebase with pro features.
7+
WebberZone Knowledge Base Pro (v3.0.0) is a WordPress plugin (namespace `WebberZone\Knowledge_Base`) that creates a multi-product knowledge base system. It uses a freemium model via Freemius integration — free core features with premium features in `/includes/pro/`.
88

99
- **Plugin entry**: `knowledgebase.php` (defines constants, loads Freemius via `load-freemius.php`, registers autoloader, and directly requires `includes/options-api.php` and `includes/functions.php`)
1010
- **PHP**: 7.4+ | **WordPress**: 6.7+
1111
- **Custom post type**: `wz_knowledgebase` | **Taxonomies**: `wzkb_category`, `wzkb_product`, `wzkb_tag`
12-
- **Constants**: `WZKB_VERSION`, `WZKB_PLUGIN_DIR`, `WZKB_PLUGIN_URL`, `WZKB_PLUGIN_FILE`, `WZKB_DEFAULT_THUMBNAIL_URL`
1312

1413
## Build & Development Commands
1514

@@ -30,24 +29,35 @@ WP_MULTISITE=1 vendor/bin/phpunit # Run multisite unit tests
3029
### JavaScript / Blocks
3130

3231
```bash
33-
npm run build # Build all blocks (runs build:free + build:pro)
32+
npm run build # Build all blocks (free + pro)
3433
npm run build:free # Build all free blocks
35-
npm run build:assets # Minify CSS/JS and generate RTL
36-
npm run start # Watch mode for free blocks
34+
npm run build:pro # Build all pro blocks
35+
npm run build:assets # Minify CSS/JS and generate RTL (= node build-assets.js)
36+
npm run start # Watch mode for all blocks
3737
npm run lint:js # Lint JavaScript
3838
npm run lint:css # Lint CSS
3939
npm run format # Auto-format JS and CSS
4040
```
4141

42-
Individual block builds: `npm run build:[kb|articles|sections|products|search|breadcrumb|related|alerts]`
42+
Individual block builds: `npm run build:[kb|articles|sections|products|search|breadcrumb|related|alerts|rating]`
4343

44-
Note: `package.json` also contains `build:pro` and `build:rating` scripts that reference `includes/pro/` — these are irrelevant in this repository and will fail if run here.
44+
> **After editing any non-block JS or CSS** (files in `includes/admin/js/`, `includes/admin/css/`, `includes/admin/settings/js/`, `includes/frontend/css/`, `includes/pro/frontend/css/`, etc.) always run `node build-assets.js` to regenerate the `.min.js`, `.min.css`, and `-rtl` variants. Never hand-edit the minified or RTL files directly.
45+
>
46+
> **Selective asset building**: Pass flags to process only specific asset types:
47+
>
48+
> ```bash
49+
> node build-assets.js --css # Process CSS only
50+
> node build-assets.js --js # Process JS only
51+
> node build-assets.js --no-rtl # Skip RTL generation
52+
> node build-assets.js path/to/file.css # Process specific file
53+
> node build-assets.js includes/admin/css/ # Process directory
54+
> ```
4555
4656
### Distribution
4757
4858
```bash
4959
composer zip # Create PHP distribution zip
50-
npm run zip # Create full plugin zip (wp-scripts plugin-zip)
60+
npm run zip # Create full plugin zip
5161
```
5262
5363
## Architecture
@@ -56,31 +66,31 @@ npm run zip # Create full plugin zip (wp-scripts pl
5666

5767
1. `plugins_loaded` hook → `Main::get_instance()` (singleton)
5868
2. `Main::init()` instantiates all component handlers and registers their hooks
59-
3. Admin components only load on `is_admin()` (deferred to `init` action for translation readiness)
60-
4. `Main` has `$pro` and `$is_pro_enabled` properties defined but they are never set in this repository — those are only used by the pro plugin
69+
3. Admin components only load on `is_admin()`; Pro components only if Freemius detects a premium license
6170

6271
### Key Patterns
6372

6473
**Autoloader** (`includes/autoloader.php`): PSR-4 style. Converts `WebberZone\Knowledge_Base\Admin\Settings``includes/admin/class-settings.php`.
6574

6675
**Hook Registry** (`includes/util/class-hook-registry.php`): Custom wrapper around WordPress actions/filters with duplicate prevention and closure support. All components register hooks through this instead of calling `add_action()`/`add_filter()` directly.
6776

68-
**Settings**: Global `$wzkb_settings` populated at plugin load. Read via `wzkb_get_option( $key )` or `wzkb_get_settings()`. Settings page in `includes/admin/class-settings.php`. Stored as a single serialized array under option key `wzkb_settings`. All settings filters use the prefix `wzkb_` (e.g. `wzkb_get_option_{$key}`).
77+
**Settings**: Global `$wzkb_settings` populated at plugin load. Read via `wzkb_get_option( $key )` or `wzkb_get_settings()`. Settings page in `includes/admin/class-settings.php`.
6978

70-
**Caching** (`includes/util/class-cache.php`): Term meta-based caching (not transients) with expiry timestamps. AJAX endpoint for admin cache clearing.
79+
**Caching** (`includes/util/class-cache.php`): Term meta-based caching (not transients) with expiry timestamps. AJAX endpoint for admin cache clearing. Use atomic operations when modifying cached data.
7180

72-
**Free/Pro coexistence**: The plugin includes deactivation logic in `knowledgebase.php` — activating either the free or pro plugin automatically deactivates the other and shows an admin notice.
81+
**Free vs Pro**: Pro features conditionally instantiated in `Main::init()`. The `/includes/pro/` directory is marked `@fs_premium_only` in the plugin header. Do not add premium-only logic outside `/includes/pro/`.
7382

7483
### Component Map
7584

7685
| Directory | Responsibility |
77-
|---|---|
86+
| --- | --- |
7887
| `includes/admin/` | Settings UI, columns, wizard, notices, activation |
79-
| `includes/frontend/` | Templates, display, shortcodes, styles, search, breadcrumbs, related articles, feeds, patterns |
88+
| `includes/frontend/` | Templates, display, shortcodes, styles, search, breadcrumbs, related articles, feeds |
8089
| `includes/blocks/` | 8 free Gutenberg blocks (React in `src/`, compiled to `build/`) |
90+
| `includes/pro/` | Premium features: custom permalinks, rating system, help widget, KB homepage mode |
8191
| `includes/rest/` | REST API under `/wzkb/v1/` namespace |
82-
| `includes/widgets/` | 4 classic WordPress widgets (Articles, Sections, Breadcrumb, Products) |
83-
| `includes/util/` | Hook registry, caching utilities, helpers |
92+
| `includes/widgets/` | 4 classic WordPress widgets |
93+
| `includes/util/` | Hook registry, caching utilities |
8494

8595
### Block Development
8696

@@ -89,18 +99,21 @@ Blocks are in `includes/blocks/src/[block-name]/`. Each block has its own `block
8999
### Public Helper Functions
90100

91101
`includes/functions.php` exposes the plugin's public API. Key functions:
102+
92103
- `wzkb_knowledge()` — render the full KB output
93104
- `wzkb_get_option( $key )` / `wzkb_get_settings()` — read settings (prefer over `get_option()` directly)
94105
- `wzkb_get_breadcrumb()`, `wzkb_get_search_form()`, `wzkb_get_alert()`, `wzkb_related_articles()` — frontend rendering helpers
95106
- `wzkb_get_the_post_thumbnail()` — thumbnail retrieval (supports ACF image fields)
96107
- `wzkb_get_kb_url()`, `wzkb_get_product_sections_list()`, `wzkb_get_term_hierarchy_path()` — URL and taxonomy helpers
97108

109+
Settings are stored as a single serialized array under option key `wzkb_settings`. All settings filters use the prefix `wzkb_` (e.g. `wzkb_get_option_{$key}`).
110+
98111
### REST API
99112

100113
Endpoints under `/wzkb/v1/`: `/sections` (product sections), `/knowledgebase` (list), `/knowledgebase/{id}` (single). Responses are object-cached under group `wzkb_rest` (300 s TTL); cache is invalidated on post save/delete and term changes.
101114

102115
## Code Quality Configuration
103116

104117
- **PHPCS**: `phpcs.xml.dist` — WordPress coding standards
105-
- **PHPStan**: `phpstan.neon.dist` — Level 5 strict analysis; baseline in `phpstan-baseline.neon`
118+
- **PHPStan**: `phpstan.neon.dist` — Level 5 strict analysis; baseline in `phpstan-baseline.neon`; ACF Pro stubs included
106119
- **PHPUnit**: `phpunit.xml.dist` — test configuration, tests in `phpunit/tests/`

CLAUDE.md

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Plugin Overview
66

7-
WebberZone Knowledge Base (v3.0.0) is a free WordPress plugin (namespace `WebberZone\Knowledge_Base`) that creates a multi-product knowledge base system. This is the standalone free version — there is no `includes/pro/` directory here. The companion premium plugin (knowledgebase-pro) is a separate repository that extends this codebase with pro features.
7+
WebberZone Knowledge Base Pro (v3.0.0) is a WordPress plugin (namespace `WebberZone\Knowledge_Base`) that creates a multi-product knowledge base system. It uses a freemium model via Freemius integration — free core features with premium features in `/includes/pro/`.
88

99
- **Plugin entry**: `knowledgebase.php` (defines constants, loads Freemius via `load-freemius.php`, registers autoloader, and directly requires `includes/options-api.php` and `includes/functions.php`)
1010
- **PHP**: 7.4+ | **WordPress**: 6.7+
1111
- **Custom post type**: `wz_knowledgebase` | **Taxonomies**: `wzkb_category`, `wzkb_product`, `wzkb_tag`
12-
- **Constants**: `WZKB_VERSION`, `WZKB_PLUGIN_DIR`, `WZKB_PLUGIN_URL`, `WZKB_PLUGIN_FILE`, `WZKB_DEFAULT_THUMBNAIL_URL`
1312

1413
## Build & Development Commands
1514

@@ -30,24 +29,35 @@ WP_MULTISITE=1 vendor/bin/phpunit # Run multisite unit tests
3029
### JavaScript / Blocks
3130

3231
```bash
33-
npm run build # Build all blocks (runs build:free + build:pro)
32+
npm run build # Build all blocks (free + pro)
3433
npm run build:free # Build all free blocks
35-
npm run build:assets # Minify CSS/JS and generate RTL
36-
npm run start # Watch mode for free blocks
34+
npm run build:pro # Build all pro blocks
35+
npm run build:assets # Minify CSS/JS and generate RTL (= node build-assets.js)
36+
npm run start # Watch mode for all blocks
3737
npm run lint:js # Lint JavaScript
3838
npm run lint:css # Lint CSS
3939
npm run format # Auto-format JS and CSS
4040
```
4141

42-
Individual block builds: `npm run build:[kb|articles|sections|products|search|breadcrumb|related|alerts]`
42+
Individual block builds: `npm run build:[kb|articles|sections|products|search|breadcrumb|related|alerts|rating]`
4343

44-
Note: `package.json` also contains `build:pro` and `build:rating` scripts that reference `includes/pro/` — these are irrelevant in this repository and will fail if run here.
44+
> **After editing any non-block JS or CSS** (files in `includes/admin/js/`, `includes/admin/css/`, `includes/admin/settings/js/`, `includes/frontend/css/`, `includes/pro/frontend/css/`, etc.) always run `node build-assets.js` to regenerate the `.min.js`, `.min.css`, and `-rtl` variants. Never hand-edit the minified or RTL files directly.
45+
>
46+
> **Selective asset building**: Pass flags to process only specific asset types:
47+
>
48+
> ```bash
49+
> node build-assets.js --css # Process CSS only
50+
> node build-assets.js --js # Process JS only
51+
> node build-assets.js --no-rtl # Skip RTL generation
52+
> node build-assets.js path/to/file.css # Process specific file
53+
> node build-assets.js includes/admin/css/ # Process directory
54+
> ```
4555
4656
### Distribution
4757
4858
```bash
4959
composer zip # Create PHP distribution zip
50-
npm run zip # Create full plugin zip (wp-scripts plugin-zip)
60+
npm run zip # Create full plugin zip
5161
```
5262
5363
## Architecture
@@ -56,31 +66,31 @@ npm run zip # Create full plugin zip (wp-scripts pl
5666

5767
1. `plugins_loaded` hook → `Main::get_instance()` (singleton)
5868
2. `Main::init()` instantiates all component handlers and registers their hooks
59-
3. Admin components only load on `is_admin()` (deferred to `init` action for translation readiness)
60-
4. `Main` has `$pro` and `$is_pro_enabled` properties defined but they are never set in this repository — those are only used by the pro plugin
69+
3. Admin components only load on `is_admin()`; Pro components only if Freemius detects a premium license
6170

6271
### Key Patterns
6372

6473
**Autoloader** (`includes/autoloader.php`): PSR-4 style. Converts `WebberZone\Knowledge_Base\Admin\Settings``includes/admin/class-settings.php`.
6574

6675
**Hook Registry** (`includes/util/class-hook-registry.php`): Custom wrapper around WordPress actions/filters with duplicate prevention and closure support. All components register hooks through this instead of calling `add_action()`/`add_filter()` directly.
6776

68-
**Settings**: Global `$wzkb_settings` populated at plugin load. Read via `wzkb_get_option( $key )` or `wzkb_get_settings()`. Settings page in `includes/admin/class-settings.php`. Stored as a single serialized array under option key `wzkb_settings`. All settings filters use the prefix `wzkb_` (e.g. `wzkb_get_option_{$key}`).
77+
**Settings**: Global `$wzkb_settings` populated at plugin load. Read via `wzkb_get_option( $key )` or `wzkb_get_settings()`. Settings page in `includes/admin/class-settings.php`.
6978

70-
**Caching** (`includes/util/class-cache.php`): Term meta-based caching (not transients) with expiry timestamps. AJAX endpoint for admin cache clearing.
79+
**Caching** (`includes/util/class-cache.php`): Term meta-based caching (not transients) with expiry timestamps. AJAX endpoint for admin cache clearing. Use atomic operations when modifying cached data.
7180

72-
**Free/Pro coexistence**: The plugin includes deactivation logic in `knowledgebase.php` — activating either the free or pro plugin automatically deactivates the other and shows an admin notice.
81+
**Free vs Pro**: Pro features conditionally instantiated in `Main::init()`. The `/includes/pro/` directory is marked `@fs_premium_only` in the plugin header. Do not add premium-only logic outside `/includes/pro/`.
7382

7483
### Component Map
7584

7685
| Directory | Responsibility |
77-
|---|---|
86+
| --- | --- |
7887
| `includes/admin/` | Settings UI, columns, wizard, notices, activation |
79-
| `includes/frontend/` | Templates, display, shortcodes, styles, search, breadcrumbs, related articles, feeds, patterns |
88+
| `includes/frontend/` | Templates, display, shortcodes, styles, search, breadcrumbs, related articles, feeds |
8089
| `includes/blocks/` | 8 free Gutenberg blocks (React in `src/`, compiled to `build/`) |
90+
| `includes/pro/` | Premium features: custom permalinks, rating system, help widget, KB homepage mode |
8191
| `includes/rest/` | REST API under `/wzkb/v1/` namespace |
82-
| `includes/widgets/` | 4 classic WordPress widgets (Articles, Sections, Breadcrumb, Products) |
83-
| `includes/util/` | Hook registry, caching utilities, helpers |
92+
| `includes/widgets/` | 4 classic WordPress widgets |
93+
| `includes/util/` | Hook registry, caching utilities |
8494

8595
### Block Development
8696

@@ -89,18 +99,21 @@ Blocks are in `includes/blocks/src/[block-name]/`. Each block has its own `block
8999
### Public Helper Functions
90100

91101
`includes/functions.php` exposes the plugin's public API. Key functions:
102+
92103
- `wzkb_knowledge()` — render the full KB output
93104
- `wzkb_get_option( $key )` / `wzkb_get_settings()` — read settings (prefer over `get_option()` directly)
94105
- `wzkb_get_breadcrumb()`, `wzkb_get_search_form()`, `wzkb_get_alert()`, `wzkb_related_articles()` — frontend rendering helpers
95106
- `wzkb_get_the_post_thumbnail()` — thumbnail retrieval (supports ACF image fields)
96107
- `wzkb_get_kb_url()`, `wzkb_get_product_sections_list()`, `wzkb_get_term_hierarchy_path()` — URL and taxonomy helpers
97108

109+
Settings are stored as a single serialized array under option key `wzkb_settings`. All settings filters use the prefix `wzkb_` (e.g. `wzkb_get_option_{$key}`).
110+
98111
### REST API
99112

100113
Endpoints under `/wzkb/v1/`: `/sections` (product sections), `/knowledgebase` (list), `/knowledgebase/{id}` (single). Responses are object-cached under group `wzkb_rest` (300 s TTL); cache is invalidated on post save/delete and term changes.
101114

102115
## Code Quality Configuration
103116

104117
- **PHPCS**: `phpcs.xml.dist` — WordPress coding standards
105-
- **PHPStan**: `phpstan.neon.dist` — Level 5 strict analysis; baseline in `phpstan-baseline.neon`
118+
- **PHPStan**: `phpstan.neon.dist` — Level 5 strict analysis; baseline in `phpstan-baseline.neon`; ACF Pro stubs included
106119
- **PHPUnit**: `phpunit.xml.dist` — test configuration, tests in `phpunit/tests/`

0 commit comments

Comments
 (0)