🔄 Development Workflow
This guide outlines the development workflow for WP LLM contributors and advanced users. It covers best practices, development processes, and how to effectively contribute to the project.
🎯 Development Philosophy
Core Principles
- WordPress-First Approach - All generated code must follow WordPress standards
- Security by Design - Security considerations are built into every component
- Performance Optimization - Code should be efficient and scalable
- Accessibility - Generated interfaces must be accessible to all users
- Documentation - Comprehensive documentation for all features
Quality Standards
- WordPress Coding Standards - Follow PSR-12 and WordPress-specific guidelines
- Security Best Practices - Proper sanitization, validation, and nonce verification
- Performance Guidelines - Efficient queries, caching, and asset optimization
- Accessibility Standards - WCAG 2.1 AA compliance for frontend components
🛠️ Development Environment Setup
Required Tools
- Ollama - For running WP LLM locally
- WordPress Development Environment - LocalWP, XAMPP, or similar
- Code Editor - VS Code with WordPress extensions
- Git - Version control
- Node.js - For block development and build tools
Local Development Setup
# Clone the repository
git clone https://github.com/artificialpoets/wp-llm-docs.git
cd wp-llm
# Install dependencies
npm install
# Set up WordPress development environment
# (Follow your preferred local development setup)
# Start Ollama with WP LLM
ollama serve
ollama pull wp-llm
VS Code Configuration
Recommended Extensions:
- WordPress Snippets
- PHP Intelephense
- Ollama
- GitLens
- Prettier
Settings:
{
"php.validate.executablePath": "/usr/bin/php",
"php.suggest.basic": false,
"wordpress.suggest.basic": true,
"ollama.model": "wp-llm",
"ollama.host": "http://localhost:11434"
}
🔄 Development Process
1. Planning Phase
Define Requirements:
- Clear specification of what needs to be built
- User stories and acceptance criteria
- Technical constraints and considerations
Example Planning Template:
Feature: Custom Post Type Generator
- User Story: As a developer, I want to generate custom post types with meta fields
- Acceptance Criteria:
* Generates proper post type registration
* Includes meta boxes for custom fields
* Follows WordPress coding standards
* Includes proper sanitization
- Technical Considerations:
* REST API support
* Admin columns
* Custom taxonomies
2. Development Phase
Using WP LLM for Development:
-
Start with a Clear Prompt:
bashollama run wp-llm "Create a custom post type for 'Products' with the following requirements: - Must support: title, editor, thumbnail, excerpt, custom-fields - Include meta fields: price (number), sku (text), stock_status (select) - Add proper sanitization and validation - Follow WordPress coding standards - Include REST API support"
-
Review and Refine:
- Check generated code for accuracy
- Verify security measures
- Test functionality
- Optimize performance
-
Iterate and Improve:
bashollama run wp-llm "Improve this custom post type code by adding: - Admin columns for price and stock status - Better error handling - Additional meta field validation"
3. Testing Phase
Code Review Checklist:
- WordPress coding standards compliance
- Security measures implemented
- Performance considerations
- Accessibility features
- Error handling
- Documentation
Testing Procedures:
# Test in WordPress environment
# 1. Activate plugin/theme
# 2. Test functionality
# 3. Check for errors
# 4. Validate security
# 5. Performance testing
4. Documentation Phase
Documentation Requirements:
- Code comments and inline documentation
- README updates
- API documentation
- Usage examples
- Changelog entries
🎨 Block Development Workflow
Block Creation Process
-
Define Block Requirements:
json{ "name": "my-theme/hero-section", "title": "Hero Section", "category": "design", "attributes": { "title": { "type": "string" }, "backgroundImage": { "type": "object" }, "buttonText": { "type": "string" } } }
-
Generate Block Structure:
bashollama run wp-llm "Create a Gutenberg block for 'hero-section' with: - Background image support - Editable title and subtitle - Call-to-action button - Responsive design - Accessibility features"
-
Implement Block Files:
block.json
- Block configurationedit.js
- Editor componentsave.js
- Frontend renderstyle.css
- Stylingindex.js
- Block registration
-
Test and Refine:
- Test in block editor
- Verify frontend rendering
- Check responsive behavior
- Validate accessibility
Block Pattern Development
-
Define Pattern Structure:
phpregister_block_pattern( 'my-theme/hero-pattern', array( 'title' => __('Hero Section', 'my-theme'), 'description' => __('A hero section with background image and call-to-action', 'my-theme'), 'categories' => array('hero'), 'content' => '<!-- wp:my-theme/hero-section -->...', ) );
-
Generate Pattern Content:
bashollama run wp-llm "Create a block pattern for a hero section that includes: - Hero block with background image - Heading and subtitle - Call-to-action button - Proper spacing and layout"
🔌 Plugin Development Workflow
Plugin Structure
my-plugin/
├── my-plugin.php # Main plugin file
├── includes/ # PHP classes and functions
│ ├── class-plugin.php
│ ├── class-admin.php
│ └── class-api.php
├── admin/ # Admin interface
│ ├── css/
│ ├── js/
│ └── views/
├── public/ # Frontend assets
│ ├── css/
│ ├── js/
│ └── views/
├── languages/ # Translation files
├── assets/ # Build assets
└── tests/ # Unit tests
Development Steps
-
Generate Plugin Foundation:
bashollama run wp-llm "Create a WordPress plugin structure for 'Product Manager' with: - Custom post type for products - Meta boxes for product details - REST API endpoints - Admin interface - Proper file organization"
-
Implement Core Features:
- Custom post type registration
- Meta box implementation
- REST API endpoints
- Admin interface
-
Add Advanced Features:
- Custom taxonomies
- Admin columns
- Import/export functionality
- Settings page
-
Testing and Optimization:
- Unit tests
- Integration tests
- Performance optimization
- Security audit
🎯 Theme Development Workflow
Theme Structure
my-theme/
├── style.css # Theme information
├── index.php # Main template
├── functions.php # Theme functions
├── header.php # Header template
├── footer.php # Footer template
├── sidebar.php # Sidebar template
├── single.php # Single post template
├── page.php # Page template
├── archive.php # Archive template
├── search.php # Search template
├── 404.php # 404 error template
├── assets/ # Theme assets
│ ├── css/
│ ├── js/
│ └── images/
├── template-parts/ # Template parts
├── inc/ # Include files
└── languages/ # Translation files
Development Process
-
Generate Theme Foundation:
bashollama run wp-llm "Create a WordPress theme structure with: - Proper template hierarchy - Theme functions and hooks - Responsive design - SEO optimization - Accessibility features"
-
Implement Templates:
- Main template files
- Template parts
- Custom post type templates
- Archive templates
-
Add Functionality:
- Custom widgets
- Shortcodes
- Customizer options
- Theme hooks
-
Optimization:
- Performance optimization
- SEO improvements
- Accessibility enhancements
- Cross-browser testing
🔒 Security Development Workflow
Security Checklist
Input Validation:
- Sanitize all user inputs
- Validate data types and formats
- Check for malicious content
- Implement proper escaping
Authentication & Authorization:
- Verify user capabilities
- Implement nonce verification
- Check user permissions
- Secure admin interfaces
Database Security:
- Use prepared statements
- Validate SQL queries
- Implement proper escaping
- Check for SQL injection
File Security:
- Validate file uploads
- Check file types and sizes
- Secure file storage
- Implement access controls
Security Testing
# Test for common vulnerabilities
# 1. SQL injection testing
# 2. XSS vulnerability testing
# 3. CSRF protection testing
# 4. File upload security testing
# 5. Authentication bypass testing
📊 Performance Development Workflow
Performance Optimization
Database Optimization:
- Use efficient queries
- Implement proper indexing
- Optimize meta queries
- Use object caching
Asset Optimization:
- Minify CSS and JavaScript
- Optimize images
- Implement lazy loading
- Use CDN for assets
Caching Strategy:
- Object caching
- Page caching
- Fragment caching
- Transient API usage
Performance Testing
# Performance testing tools
# 1. Query Monitor (WordPress plugin)
# 2. GTmetrix
# 3. Google PageSpeed Insights
# 4. WebPageTest
🔄 Continuous Integration
CI/CD Pipeline
# .github/workflows/ci.yml
name: CI/CD Pipeline
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
- name: Install dependencies
run: composer install
- name: Run tests
run: vendor/bin/phpunit
- name: Code quality check
run: vendor/bin/phpcs
Automated Testing
Unit Tests:
class TestCustomPostType extends WP_UnitTestCase {
public function test_post_type_registration() {
// Test post type registration
$post_types = get_post_types();
$this->assertArrayHasKey('product', $post_types);
}
}
Integration Tests:
class TestRESTAPI extends WP_Test_REST_TestCase {
public function test_get_products_endpoint() {
// Test REST API endpoint
$request = new WP_REST_Request('GET', '/wp-json/product-manager/v1/products');
$response = rest_do_request($request);
$this->assertEquals(200, $response->get_status());
}
}
📝 Documentation Workflow
Documentation Standards
Code Documentation:
- PHPDoc comments for functions
- Inline comments for complex logic
- README files for projects
- API documentation
User Documentation:
- Installation guides
- Usage examples
- Troubleshooting guides
- FAQ sections
Documentation Process
- Write documentation alongside code
- Include usage examples
- Add troubleshooting sections
- Keep documentation updated
- Review and refine regularly
🚀 Deployment Workflow
Production Deployment
-
Code Review:
- Security audit
- Performance review
- Accessibility check
- Cross-browser testing
-
Testing:
- Staging environment testing
- User acceptance testing
- Performance testing
- Security testing
-
Deployment:
- Backup production environment
- Deploy to production
- Monitor for issues
- Rollback if necessary
Deployment Checklist
- Code review completed
- Tests passing
- Security audit passed
- Performance benchmarks met
- Documentation updated
- Backup created
- Deployment plan ready
- Rollback plan prepared
Ready to contribute? Follow this development workflow to ensure high-quality, secure, and performant WordPress code that follows best practices and standards.