Prerequisites
Before you begin, ensure you have the following installed on your system:Required Software
- PHP >= 7.2 - Required for WordPress compatibility
- Node.js >= 18.0 - For building JavaScript and CSS assets
- Composer >= 2.0 - For PHP dependency management
- Docker - For running the WordPress test environment
- Git - For version control
Verify Installation
Check your versions:Installation
1. Clone the Repository
2. Install Dependencies
Install both npm and Composer dependencies:npm install command will:
- Install all npm packages
- Set up Husky git hooks
- Automatically run
composer install
3. Configure Git Hooks
Git hooks are automatically configured via Husky duringnpm install. These hooks run:
Pre-commit:
- PHP CodeSniffer (WPCS)
- ESLint (JavaScript)
- Stylelint (SCSS)
- Additional lint checks
- Ensure code quality before pushing
Development Commands
Build Commands
Start Development Mode
Run webpack in watch mode with hot module replacement:- Watches for file changes
- Automatically rebuilds assets
- Enables hot module replacement
- Shows detailed progress
- Generates source maps for debugging
Build for Development
Create a one-time development build:build/ directory.
Build for Production
- Generates translation files (
.potand.json) - Builds minified production assets
- Creates a plugin zip file
- Should only be run for releases
build:prod during regular development.
Code Quality
Linting
Check code quality without making changes:Auto-Fixing
Automatically fix linting issues:Testing
WordPress Test Environment
Visual Portfolio useswp-env (WordPress’s official testing environment powered by Docker):
- WordPress site: http://localhost:8888
- Admin: http://localhost:8888/wp-admin
- Username: admin
- Password: password
Running Tests
wp-env is running before executing tests:
Development Workflow
Typical Development Session
-
Start development build:
-
Start WordPress environment (in another terminal):
- Make your changes to PHP, JavaScript, or SCSS files
- Test your changes in the browser at http://localhost:8888
-
Run linters before committing:
-
Commit your changes (hooks will run automatically):
Working with PHP
When modifying PHP files:- Edit the file in
classes/or main plugin file - Always run PHP linter after changes:
- Fix any issues reported by WPCS:
- Refresh the WordPress site to see changes
Working with JavaScript
When modifying JavaScript files inassets/js/ or gutenberg/:
- Edit the file with ES6+ syntax
- Webpack auto-rebuilds (if
npm run devis running) - Check browser console for errors
- Run linter:
- Auto-fix issues:
Working with SCSS
When modifying styles inassets/css/, gutenberg/, or templates/:
- Edit the
.scssfile - Webpack auto-rebuilds CSS (if
npm run devis running) - Check browser for style changes
- Run linter:
- Auto-fix issues:
Working with Gutenberg Blocks
For React components ingutenberg/:
- Edit React component files
- Webpack auto-rebuilds (if
npm run devis running) - Refresh the block editor to see changes
- Check browser console for React errors
- Test in block editor at http://localhost:8888/wp-admin/post-new.php
Build Output
Webpack compiles source files into thebuild/ directory:
build/ directly - they will be overwritten. Always edit source files in:
assets/for CSS and JavaScriptgutenberg/for React componentsclasses/for PHP
Debugging
Enable WordPress Debug Mode
Editwp-config.php in your wp-env environment:
Source Maps
Development builds include source maps for debugging:- JavaScript:
build/*.js.map - CSS:
build/*.css.map
PHP Debugging
Add debug output:Troubleshooting
Port Already in Use
If port 8888 is already in use:Node Modules Issues
If you encounter dependency issues:Composer Issues
If PHP dependencies are problematic:wp-env Issues
Reset the WordPress environment:Build Issues
Clear webpack cache:IDE Configuration
VS Code
The project includes VS Code settings in.vscode/:
- ESLint integration
- Stylelint integration
- PHP formatting
- Recommended extensions
PHP IntelliSense
For better PHP autocomplete, install WordPress stubs:Next Steps
- Architecture Deep Dive - Learn about the plugin’s class structure
- Contributing Guidelines - Learn how to contribute