|
| 1 | +# {{theme_name}} Block Theme Instructions |
| 2 | + |
| 3 | +You are an expert WordPress block theme developer working on {{theme_name}}, a modern WordPress block theme with Full Site Editing (FSE) support. |
| 4 | + |
| 5 | +## Theme Overview |
| 6 | + |
| 7 | +- **Theme Name**: {{theme_name}} |
| 8 | +- **Theme Slug**: {{theme_slug}} |
| 9 | +- **Version**: {{version}} |
| 10 | +- **Description**: {{description}} |
| 11 | +- **Architecture**: WordPress Block Theme with FSE support |
| 12 | +- **Build System**: Webpack with @wordpress/scripts |
| 13 | +- **Template System**: Mustache templates for configuration |
| 14 | + |
| 15 | +## Key Technologies |
| 16 | + |
| 17 | +- WordPress Block Editor (Gutenberg) |
| 18 | +- Full Site Editing (FSE) |
| 19 | +- theme.json for global styles |
| 20 | +- Block patterns and template parts |
| 21 | +- Modern JavaScript (ES6+) |
| 22 | +- SCSS for styling |
| 23 | +- Webpack for asset compilation |
| 24 | +- PHPUnit and Jest for testing |
| 25 | + |
| 26 | +## File Structure |
| 27 | + |
| 28 | +``` |
| 29 | +{{theme_slug}}/ |
| 30 | +├── .github/ # GitHub workflows and Copilot config |
| 31 | +├── assets/ # Static assets (images, fonts) |
| 32 | +├── inc/ # PHP includes and functionality |
| 33 | +├── parts/ # Template parts (header, footer, etc.) |
| 34 | +├── patterns/ # Block patterns |
| 35 | +├── src/ # Source files for build process |
| 36 | +│ ├── css/ # SCSS source files |
| 37 | +│ └── js/ # JavaScript source files |
| 38 | +├── styles/ # Style variations (dark mode, etc.) |
| 39 | +├── templates/ # Block templates (HTML) |
| 40 | +├── tests/ # Test files |
| 41 | +├── public/ # Built assets (auto-generated) |
| 42 | +├── functions.php # Theme functions |
| 43 | +├── style.css # Theme metadata |
| 44 | +├── theme.json # Theme configuration |
| 45 | +└── package.json # Build configuration |
| 46 | +``` |
| 47 | + |
| 48 | +## Coding Standards |
| 49 | + |
| 50 | +### PHP |
| 51 | +- Follow WordPress Coding Standards |
| 52 | +- Use {{theme_slug}}_ prefix for all functions |
| 53 | +- Escape all output with esc_html(), esc_attr(), etc. |
| 54 | +- Sanitize all input |
| 55 | +- Use WordPress hooks and filters appropriately |
| 56 | + |
| 57 | +### JavaScript |
| 58 | +- Use modern ES6+ syntax |
| 59 | +- Follow WordPress JavaScript standards |
| 60 | +- Use wp.domReady() for DOM manipulation |
| 61 | +- Utilize WordPress packages (@wordpress/*) |
| 62 | + |
| 63 | +### CSS/SCSS |
| 64 | +- Use BEM methodology for custom classes |
| 65 | +- Leverage CSS custom properties from theme.json |
| 66 | +- Follow WordPress CSS standards |
| 67 | +- Mobile-first responsive design |
| 68 | + |
| 69 | +### Block Templates |
| 70 | +- Use semantic HTML structure |
| 71 | +- Include proper block comments |
| 72 | +- Follow WordPress template hierarchy |
| 73 | +- Ensure accessibility compliance |
| 74 | + |
| 75 | +## Development Guidelines |
| 76 | + |
| 77 | +### When Working with Block Patterns |
| 78 | +- Register patterns in inc/block-patterns.php |
| 79 | +- Use mustache variables for customizable content |
| 80 | +- Include proper categories and keywords |
| 81 | +- Test patterns in the Site Editor |
| 82 | + |
| 83 | +### When Working with Templates |
| 84 | +- Use HTML files in templates/ directory |
| 85 | +- Include proper template parts |
| 86 | +- Follow WordPress template hierarchy |
| 87 | +- Test with different content types |
| 88 | + |
| 89 | +### When Working with Styles |
| 90 | +- Primary styles in theme.json |
| 91 | +- Additional styles in src/css/ |
| 92 | +- Use CSS custom properties |
| 93 | +- Ensure cross-browser compatibility |
| 94 | + |
| 95 | +### When Working with JavaScript |
| 96 | +- Frontend scripts in src/js/theme.js |
| 97 | +- Editor scripts in src/js/editor.js |
| 98 | +- Use WordPress dependencies |
| 99 | +- Ensure accessibility |
| 100 | + |
| 101 | +## Build Process |
| 102 | + |
| 103 | +- Development: `npm run start` |
| 104 | +- Production: `npm run build:production` |
| 105 | +- Linting: `npm run lint` |
| 106 | +- Testing: `npm test` |
| 107 | + |
| 108 | +## Testing Requirements |
| 109 | + |
| 110 | +- Write PHPUnit tests for PHP functions |
| 111 | +- Write Jest tests for JavaScript |
| 112 | +- Include E2E tests for critical features |
| 113 | +- Test accessibility compliance |
| 114 | +- Verify across different browsers |
| 115 | + |
| 116 | +## Best Practices |
| 117 | + |
| 118 | +1. **Performance**: Optimize images, minify assets, lazy load content |
| 119 | +2. **Accessibility**: Follow WCAG 2.1 AA guidelines |
| 120 | +3. **Security**: Validate input, escape output, use nonces |
| 121 | +4. **Compatibility**: Test with latest WordPress versions |
| 122 | +5. **Documentation**: Comment complex code, update README |
| 123 | + |
| 124 | +## Mustache Variables |
| 125 | + |
| 126 | +Use these variables in templates and configuration files: |
| 127 | + |
| 128 | +### Theme Meta |
| 129 | +- `{{theme_name}}` - Display name |
| 130 | +- `{{theme_slug}}` - URL-safe identifier |
| 131 | +- `{{description}}` - Theme description |
| 132 | +- `{{version}}` - Current version |
| 133 | +- `{{author}}` - Theme author |
| 134 | +- `{{license}}` - License type |
| 135 | + |
| 136 | +### Design Tokens |
| 137 | +- `{{primary_color}}` - Primary brand color |
| 138 | +- `{{secondary_color}}` - Secondary color |
| 139 | +- `{{background_color}}` - Background color |
| 140 | +- `{{text_color}}` - Text color |
| 141 | +- `{{font_family}}` - Body font |
| 142 | +- `{{heading_font}}` - Heading font |
| 143 | + |
| 144 | +### Content |
| 145 | +- `{{hero_title}}` - Hero section title |
| 146 | +- `{{cta_text}}` - Call-to-action text |
| 147 | +- `{{footer_text}}` - Footer copyright text |
| 148 | + |
| 149 | +## Common Tasks |
| 150 | + |
| 151 | +### Adding a New Block Pattern |
| 152 | +1. Create pattern in inc/block-patterns.php |
| 153 | +2. Register with appropriate category |
| 154 | +3. Use mustache variables for content |
| 155 | +4. Test in Site Editor |
| 156 | + |
| 157 | +### Adding a New Template |
| 158 | +1. Create HTML file in templates/ |
| 159 | +2. Follow block markup syntax |
| 160 | +3. Include proper template parts |
| 161 | +4. Test with different content |
| 162 | + |
| 163 | +### Adding Custom Styles |
| 164 | +1. Add settings to theme.json |
| 165 | +2. Create styles in src/css/ |
| 166 | +3. Register block styles if needed |
| 167 | +4. Test responsive behavior |
| 168 | + |
| 169 | +### Adding JavaScript Functionality |
| 170 | +1. Add to src/js/theme.js or src/js/editor.js |
| 171 | +2. Use WordPress APIs and hooks |
| 172 | +3. Ensure accessibility |
| 173 | +4. Write tests |
| 174 | + |
| 175 | +## Debugging |
| 176 | + |
| 177 | +- Use WordPress debug mode |
| 178 | +- Check browser console for errors |
| 179 | +- Use WordPress debugging tools |
| 180 | +- Test with default content |
| 181 | +- Verify plugin compatibility |
| 182 | + |
| 183 | +Remember to always test your changes thoroughly and follow WordPress best practices for theme development. |
0 commit comments