|
| 1 | +# Agent Workflow |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Otter Blocks is a WordPress Gutenberg blocks page builder plugin. It's a monorepo containing: |
| 6 | +- **Otter Blocks** (main free plugin) — `otter-blocks.php` |
| 7 | +- **Otter Pro** (premium extension) — `plugins/otter-pro/` |
| 8 | +- **Blocks Animation** — `plugins/blocks-animation/` |
| 9 | +- **Blocks CSS** — `plugins/blocks-css/` |
| 10 | +- **Blocks Export/Import** — `plugins/blocks-export-import/` |
| 11 | + |
| 12 | +Namespace: `ThemeIsle\GutenbergBlocks`. Requires WordPress 6.2+, PHP 7.4+ (platform target). |
| 13 | + |
| 14 | +## Build & Development Commands |
| 15 | + |
| 16 | +```bash |
| 17 | +# Setup |
| 18 | +npm ci && composer install |
| 19 | + |
| 20 | +# Development (watch mode) |
| 21 | +npm run start # All configs with watch |
| 22 | +npm run dev:lite # Watch lite blocks only |
| 23 | +npm run dev:pro # Watch pro blocks only |
| 24 | + |
| 25 | +# Production build |
| 26 | +npm run build # Full production build (all configs in parallel) |
| 27 | +npm run prod:lite # Lite blocks only |
| 28 | +npm run prod:pro # Pro blocks only |
| 29 | +npm run prod:grunt # SASS compilation via Grunt |
| 30 | + |
| 31 | +# Sister plugins build |
| 32 | +npm run plugins # Build blocks-animation, blocks-css, blocks-export-import |
| 33 | +``` |
| 34 | + |
| 35 | +## Testing |
| 36 | + |
| 37 | +```bash |
| 38 | +# JavaScript unit tests (Jest) |
| 39 | +npm run test:unit |
| 40 | +npm run test:unit:watch |
| 41 | + |
| 42 | +# PHP unit tests (requires wp-env) |
| 43 | +npm run test:unit:php # Starts wp-env + runs PHPUnit |
| 44 | +npm run test:unit:php:base # PHPUnit only (if wp-env already running) |
| 45 | +npm run test:unit:php:multisite # Multisite PHPUnit tests |
| 46 | + |
| 47 | +# E2E tests (Playwright) |
| 48 | +npm run test:e2e:playwright |
| 49 | +npm run test:e2e:playwright-ui # With UI |
| 50 | + |
| 51 | +# Performance tests |
| 52 | +npm run test:performance |
| 53 | +``` |
| 54 | + |
| 55 | +PHPUnit config: `phpunit.xml` (single-site), `phpunit/multisite.xml`. |
| 56 | +Playwright config: `src/blocks/test/e2e/playwright.config.js`. |
| 57 | + |
| 58 | +## Linting & Formatting |
| 59 | + |
| 60 | +```bash |
| 61 | +# JavaScript |
| 62 | +npm run lint # ESLint check |
| 63 | +npm run format # ESLint autofix |
| 64 | + |
| 65 | +# PHP |
| 66 | +composer run lint # PHPCS |
| 67 | +composer run format # PHPCBF |
| 68 | +composer run phpstan # PHPStan static analysis (uses phpstan.neon + baseline) |
| 69 | +``` |
| 70 | + |
| 71 | +ESLint: WordPress preset with TypeScript (`.eslintrc`). PHPCS: WordPress-Core/Docs/Extra + VIP-Go (`phpcs.xml`). |
| 72 | + |
| 73 | +## Architecture |
| 74 | + |
| 75 | +### Webpack Build Pipeline |
| 76 | + |
| 77 | +Three webpack configs, all extending `@wordpress/scripts`: |
| 78 | +- `webpack.config.js` — Lite: dashboard, onboarding, animation frontend, and all free blocks |
| 79 | +- `webpack.config.pro.js` — Pro blocks and features |
| 80 | +- `webpack.config.plugins.js` — Sister plugins (animation, CSS, export-import) |
| 81 | + |
| 82 | +Grunt handles SASS compilation and version bumping (`Gruntfile.js`). |
| 83 | + |
| 84 | +### Block Metadata Registry |
| 85 | + |
| 86 | +`blocks.json` is the central manifest mapping every block to its `block.json` path and SCSS asset paths. Both webpack and Grunt read this file. Pro blocks are marked with `isPro: true`. |
| 87 | + |
| 88 | +### PHP Structure (`inc/`) |
| 89 | + |
| 90 | +- `class-main.php` — Singleton bootstrap, hooks, autoloading, SVG/MIME handling |
| 91 | +- `class-registration.php` — Block registration (WordPress native), asset enqueue, block categories (`themeisle-blocks`, `themeisle-woocommerce-blocks`), lazy-load dependencies |
| 92 | +- `class-pro.php` — Pro plugin loader |
| 93 | +- `class-patterns.php` — Pattern library |
| 94 | +- `css/` — CSS generation classes (`Block_Frontend`, `CSS_Handler`) |
| 95 | +- `plugins/` — Feature modules: Block_Conditions, Dynamic_Content, Dashboard, Stripe_API, Template_Cloud |
| 96 | +- `render/` — Dynamic block server-side renderers |
| 97 | +- `server/` — REST API endpoints |
| 98 | +- `integrations/` — Form provider integrations (email services) |
| 99 | + |
| 100 | +### JavaScript Structure (`src/`) |
| 101 | + |
| 102 | +- `src/blocks/blocks/` — Individual block implementations (edit.js, index.js, inspector.js, block.json) |
| 103 | +- `src/blocks/components/` — Shared React components |
| 104 | +- `src/blocks/frontend/` — Block frontend scripts (loaded on visitor-facing pages) |
| 105 | +- `src/blocks/plugins/` — Editor plugins (conditions, CSS, animations, copy-paste styles) |
| 106 | +- `src/blocks/helpers/` — Utility functions |
| 107 | +- `src/pro/` — Pro block implementations |
| 108 | +- `src/dashboard/` — Otter settings dashboard |
| 109 | +- `src/onboarding/` — Onboarding wizard |
| 110 | +- `src/animation/`, `src/css/`, `src/export-import/` — Sister plugin sources |
| 111 | + |
| 112 | +### Development Environment |
| 113 | + |
| 114 | +Uses `@wordpress/env` (wp-env). Config: `.wp-env.override.json`. Start with `npm run test:unit:php:setup` or `npx wp-env start`. |
| 115 | + |
| 116 | +## Key Conventions |
| 117 | + |
| 118 | +- Text domains: `otter-blocks`, `otter-pro`, `blocks-animation`, `blocks-css`, `blocks-export-import` |
| 119 | +- Tab indentation (JS and PHP), single quotes, semicolons required (JS) |
| 120 | +- Block namespace: `themeisle-blocks/<block-name>` (e.g., `themeisle-blocks/accordion`) |
| 121 | +- PHP autoloading follows class file naming: `class-<name>.php` |
| 122 | +- Distribution via `npm run dist` (runs `bin/dist.sh`, creates ZIP artifacts filtered by `.distignore`) |
0 commit comments