A modern, robust, and GPL-licensed code template for creating standards-compliant WordPress plugins with professional development practices.
# Create a modern WordPress plugin with all features in one command
curl -sSL https://raw.githubusercontent.com/kobkob/WordPress-Plugin-Template/refs/heads/master/install.sh | bash
Included: PHPUnit Tests β Docker Environment β GitHub Actions β Agile/XP Framework β REST API β AI Integration β
- Modern PHP 8.1+ Support with type declarations and latest features
- Plugin headers as required by WordPress & WordPress.org
- Singleton pattern main plugin class
- Object-oriented design with proper namespacing
- PSR-4 autoloading ready structure
- WordPress Coding Standards compliant
- PHPUnit test suite with unit and integration tests
- WordPress Coding Standards (PHPCS) configuration
- GitHub Actions CI/CD pipeline
- Composer dependency management
- PHPStan static analysis ready
- WordPress test environment setup scripts
- Agile/XP methodology with sprint management and TDD workflow
- WordPress Feature API integration for AI-powered functionality
- Automattic WP Feature API support (v0.1.8+)
- MCP-compatible feature registry for LLM agents
- Pre-built features for content management and plugin settings
- Extensible architecture for custom AI features
- Settings API wrapper for easy admin options
- Post Type API for one-line custom post type registration
- Taxonomy API for one-line taxonomy registration
- Admin API for meta boxes and custom fields
- REST API endpoints with full CRUD operations
- Asset management with proper enqueuing
- Grunt.js build system
- LESS preprocessing
- JavaScript minification
- CSS optimization
- Development and production builds
The fastest way to get started is with our one-liner installer:
# Interactive installation
curl -sSL https://raw.githubusercontent.com/kobkob/WordPress-Plugin-Template/refs/heads/master/install.sh | bash
For automated setups or CI/CD pipelines:
# Non-interactive installation with all features
curl -sSL https://raw.githubusercontent.com/kobkob/WordPress-Plugin-Template/refs/heads/master/install.sh | bash -s -- \
--name "My Awesome Plugin" \
--dir ./my-awesome-plugin \
--non-interactive
# Show help and options
curl -sSL https://raw.githubusercontent.com/kobkob/WordPress-Plugin-Template/refs/heads/master/install.sh | bash -s -- --help
Available Options:
--name NAME
- Plugin name (e.g., 'My Awesome Plugin')--dir DIRECTORY
- Destination directory--non-interactive
- Skip interactive prompts (requires --name and --dir)--help, -h
- Show help message
The installer automatically detects and installs missing dependencies on supported systems:
- Ubuntu/Debian: Uses
apt-get
package manager - RHEL/CentOS: Uses
yum
package manager - Fedora: Uses
dnf
package manager - Arch Linux: Uses
pacman
package manager - Alpine Linux: Uses
apk
package manager - macOS: Uses Homebrew (installs it first if missing)
- Windows: Provides manual installation instructions
Auto-installed dependencies:
- PHP 8.1+ with required extensions (curl, zip, xml, mbstring)
- Composer (latest stable version)
- Node.js LTS + npm
- Git version control
- curl for downloads
For unsupported systems, the installer provides clear manual installation instructions.
The one-liner installer automatically includes all modern features:
- β PHPUnit tests and WordPress Coding Standards
- β GitHub Actions CI/CD pipeline
- β Docker development environment
- β REST API endpoints and WordPress Feature API
- β Agile/XP methodology framework
- β Complete dependency setup
The one-liner installer automatically installs missing dependencies on supported systems. For manual setup or unsupported systems, ensure you have:
- PHP 8.1+ with required extensions (curl, zip, xml, mbstring)
- Composer for dependency management
- Node.js & NPM for asset building
- Git for version control
- curl for downloads
The enhanced create-plugin.sh
script automates the entire setup process:
# Clone this repository
git clone https://github.com/kobkob/WordPress-Plugin-Template.git
cd WordPress-Plugin-Template
# Run the creation script
./create-plugin.sh
The script will guide you through:
- Plugin Information: Name, description, author details
- Development Setup: PHPUnit tests, PHPCS, GitHub Actions
- API Integration: WordPress Feature API, REST API endpoints
- Docker Environment: Complete containerized development setup
- File Generation: All necessary config files and boilerplate
- Dependency Installation: Composer packages
- Git Initialization: Clean repository setup
For the quickest setup, use the included Docker environment:
# After running create-plugin.sh with Docker option
cd your-plugin-directory
# Start the development environment
docker-compose up -d
# Access your WordPress development site
open http://localhost:8000
See DOCKER.md for complete documentation.
The template includes a complete Agile/XP workflow framework for professional plugin development:
# After creating your plugin with Agile framework
cd your-plugin-directory
# Start your first sprint
./agile/scripts/start-sprint.sh
# Use AI assistance for development
./agile/scripts/ai-implement.sh
See AGILE-GUIDE.md for the complete methodology guide.
If you prefer manual setup:
- Copy the template files to your new plugin directory
- Rename
wordpress-plugin-template.php
to your plugin slug - Update all class names, function names, and text domains
- Run
composer install
for development dependencies - Configure your test environment
# Install WordPress test suite
./bin/install-wp-tests.sh wordpress_test root password localhost latest
# Run all tests
composer test
# Run specific test suites
vendor/bin/phpunit tests/unit
vendor/bin/phpunit tests/integration
tests/
βββ bootstrap.php # Test bootstrap
βββ unit/ # Unit tests
β βββ test-plugin.php # Main plugin tests
βββ integration/ # Integration tests
βββ test-integration.php
class Test_My_Plugin extends WP_UnitTestCase {
public function test_plugin_activation() {
$this->assertTrue(is_plugin_active('my-plugin/my-plugin.php'));
}
public function test_custom_functionality() {
// Your test code here
}
}
# Check coding standards
composer cs
# Fix coding standards automatically
composer cbf
The template includes a phpcs.xml
configuration file that enforces:
- WordPress-Extra coding standards
- WordPress documentation standards
- PHP 8.1+ compatibility
- Custom prefix validation
The template includes a comprehensive REST API system with full CRUD operations, authentication, and validation:
// Access the REST API through the main plugin instance
$plugin = My_Plugin();
if ( $plugin->rest_api ) {
// REST API is available at /wp-json/my-plugin/v1/
// See REST-API-GUIDE.md for complete documentation
}
- Plugin Info:
GET /info
- Get plugin information - Settings:
GET|POST /settings
- Manage plugin settings - Posts:
GET|POST|PUT|DELETE /posts
- Full CRUD for custom post types - Batch:
POST /batch
- Process multiple requests
// Create a new post via REST API
wp.apiFetch({
path: '/my-plugin/v1/posts',
method: 'POST',
data: {
title: 'API Created Post',
content: 'This post was created via the REST API',
meta: {
custom_field: 'custom_value'
}
}
}).then(post => {
console.log('Created post:', post);
});
// Update plugin settings
wp.apiFetch({
path: '/my-plugin/v1/settings',
method: 'POST',
data: {
text_field: 'Updated value',
checkbox_field: true
}
}).then(response => {
console.log('Settings updated:', response);
});
// Simple registration
My_Plugin()->register_post_type(
'product',
__('Products', 'my-plugin'),
__('Product', 'my-plugin')
);
// With custom options
My_Plugin()->register_post_type(
'product',
__('Products', 'my-plugin'),
__('Product', 'my-plugin'),
__('Custom product post type', 'my-plugin'),
[
'public' => true,
'supports' => ['title', 'editor', 'thumbnail'],
'has_archive' => true
]
);
// Simple registration
My_Plugin()->register_taxonomy(
'product_category',
__('Product Categories', 'my-plugin'),
__('Product Category', 'my-plugin'),
['product']
);
// Get plugin options
$value = get_option('my_plugin_option_name');
// The plugin automatically prefixes options
// Check the settings class for the prefix being used
The template includes built-in support for the Automattic WordPress Feature API, enabling your plugin to work seamlessly with AI systems and LLM agents.
// The Feature API is automatically loaded if available
// Access it through the main plugin instance
$plugin = My_Plugin();
if ( $plugin->feature_api && $plugin->feature_api->is_feature_api_available() ) {
// Feature API is available
$features = $plugin->feature_api->get_plugin_features();
}
The template includes several ready-to-use features:
- Create Posts: Allow AI agents to create content using your custom post types
- List Post Types: Provide information about available post types
- Plugin Settings: Enable AI access to plugin configuration
// Register custom features for your plugin
add_action('wordpress_plugin_template_register_features', function($feature_api) {
// Register a custom feature
wp_feature_api_register_feature([
'id' => 'my_plugin_custom_action',
'name' => __('Custom Action', 'my-plugin'),
'description' => __('Performs a custom action', 'my-plugin'),
'category' => 'custom',
'input_schema' => [
'type' => 'object',
'properties' => [
'action_type' => [
'type' => 'string',
'description' => __('Type of action to perform', 'my-plugin')
]
]
],
'callback' => 'my_custom_feature_callback',
'is_eligible' => 'current_user_can_edit_posts'
]);
});
Features registered through this template are compatible with the Model Context Protocol (MCP), making them discoverable and usable by:
- AI Assistants (Claude, ChatGPT, etc.)
- LLM Agents and automation tools
- WordPress AI plugins and extensions
- Custom MCP clients
# Install Node dependencies
npm install
# Development build (unminified)
grunt dev
# Production build (minified)
grunt build
# Watch for changes during development
grunt watch
assets/
βββ css/
β βββ admin.css # Admin styles
β βββ admin.less # Admin LESS source
β βββ frontend.css # Frontend styles
β βββ frontend.less # Frontend LESS source
βββ js/
βββ admin.js # Admin scripts
βββ admin.min.js # Minified admin scripts
βββ frontend.js # Frontend scripts
βββ frontend.min.js # Minified frontend scripts
The template includes a comprehensive GitHub Actions workflow that:
- Tests multiple PHP versions (8.1, 8.2, 8.3, 8.4)
- Tests multiple WordPress versions (latest, 6.0)
- Runs coding standards checks
- Executes PHPUnit tests
- Provides test coverage reports
- Caches dependencies for faster builds
The workflow is automatically created in .github/workflows/ci.yml
and triggers on:
- Push to
main
anddevelop
branches - Pull requests to
main
anddevelop
branches
my-plugin/
βββ .github/
β βββ workflows/
β βββ ci.yml # GitHub Actions workflow
βββ agile/ # Agile/XP methodology framework
β βββ scripts/ # Automation scripts
β βββ templates/ # User story & sprint templates
β βββ docs/ # Methodology documentation
β βββ ai/ # AI collaboration prompts
βββ assets/ # Frontend assets
βββ bin/
β βββ install-wp-tests.sh # WordPress test setup
βββ includes/
β βββ lib/ # Plugin libraries
β βββ class-plugin.php # Main plugin class
β βββ class-settings.php # Settings class
βββ lang/ # Translation files
βββ tests/
β βββ unit/ # Unit tests
β βββ integration/ # Integration tests
β βββ bootstrap.php # Test bootstrap
βββ vendor/ # Composer dependencies
βββ composer.json # Composer configuration
βββ phpcs.xml # Coding standards config
βββ phpunit.xml # PHPUnit configuration
βββ package.json # Node.js dependencies
βββ Gruntfile.js # Grunt build configuration
βββ AGILE-GUIDE.md # Agile methodology guide
βββ my-plugin.php # Main plugin file
βββ README.md # Plugin documentation
The template includes several security measures:
- ABSPATH checks in all PHP files
- Nonce verification in forms
- Capability checks for admin functions
- Data sanitization and validation
- SQL injection prevention
- XSS protection
The template is translation-ready:
- Text domains properly set
- POT file included for translators
- Load text domain function
- Proper string escaping
// Example usage
__('Hello World', 'my-plugin');
esc_html__('Safe Output', 'my-plugin');
sprintf(
/* translators: %s: plugin name */
__('Welcome to %s', 'my-plugin'),
'My Plugin'
);
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Follow WordPress coding standards
- Write tests for new features
- Submit a pull request
# Clone your fork
git clone https://github.com/kobkob/WordPress-Plugin-Template.git
cd WordPress-Plugin-Template
# Install dependencies
composer install
npm install
# Set up pre-commit hooks (optional)
composer require --dev dealerdirect/phpcodesniffer-composer-installer
This template is released under the GPL-3.0+ License. Feel free to use it for any project, commercial or personal.
- Documentation: Check this README and inline code comments
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- WordPress Forums: WordPress Plugin Development
- PHP 8.4 compatibility testing
- REST API endpoints template
- Docker development environment
- Agile/XP methodology with TDD and sprint management
- Block editor integration examples
- WP-CLI command examples
- Automated plugin submission tools
Happy Plugin Development! π
This template saves you hours of setup time and provides a solid foundation for professional WordPress plugin development.