wp scaffold plugin
Overview
Generate a complete plugin boilerplate in seconds — plugin header, main class, activation/deactivation hooks, readme.txt, and optionally a PHPUnit test suite. The fastest way to start a new plugin that follows WordPress coding standards.
What It Does
wp scaffold plugin creates a new directory in wp-content/plugins/ with a full plugin structure including the main PHP file, activation/deactivation stubs, class loading, and optional unit test scaffolding.
Syntax
wp scaffold plugin <slug> [OPTIONS]
Options
| Flag | Description |
|---|---|
SLUG | Plugin directory and file name |
--plugin_name=NAME | Human-readable plugin name |
--plugin_description=DESC | Plugin description |
--plugin_author=NAME | Author name |
--plugin_author_uri=URL | Author URL |
--plugin_uri=URL | Plugin URL |
--skip-tests | Don't generate PHPUnit test files |
--activate | Activate the plugin after creation |
--force | Overwrite existing files |
Basic Usage
wp scaffold plugin my-awesome-plugin \
--plugin_name="My Awesome Plugin" \
--plugin_description="Does awesome things." \
--plugin_author="Jane Doe" \
--activate
Output:
Success: Created plugin files.
Success: Created test files.
Activating 'my-awesome-plugin'...
Success: Plugin 'my-awesome-plugin' activated.
Generated File Structure
wp-content/plugins/my-awesome-plugin/
├── my-awesome-plugin.php ← Main plugin file
├── readme.txt
├── includes/
│ └── class-my-awesome-plugin.php
├── admin/
│ ├── class-my-awesome-plugin-admin.php
│ └── css/
│ └── my-awesome-plugin-admin.css
├── public/
│ └── class-my-awesome-plugin-public.php
└── tests/
├── bootstrap.php
└── test-sample.php
Generated Main Plugin File (Example)
<?php
/**
* Plugin Name: My Awesome Plugin
* Description: Does awesome things.
* Version: 1.0.0
* Author: Jane Doe
* License: GPL-2.0+
*/
if ( ! defined( 'ABSPATH' ) ) { exit; }
function my_awesome_plugin_activate() { /* ... */ }
register_activation_hook( __FILE__, 'my_awesome_plugin_activate' );
function my_awesome_plugin_deactivate() { /* ... */ }
register_deactivation_hook( __FILE__, 'my_awesome_plugin_deactivate' );
Real-World Scenarios
Scenario 1: Full plugin with tests
wp scaffold plugin client-portal \
--plugin_name="Client Portal" \
--plugin_author="My Agency"
Scenario 2: Quick utility plugin (no tests)
wp scaffold plugin quick-redirect \
--plugin_name="Quick Redirect" \
--skip-tests \
--activate
Best Practices
- Don't skip tests — even a basic test setup makes it easy to add unit tests later.
- Use the dot-separated slug matching your namespace, e.g.,
mycompany-blog-tools. - Activate immediately with
--activateto verify the scaffolded plugin loads without errors.
Quick Reference
wp scaffold plugin <slug>
wp scaffold plugin <slug> --activate --skip-tests
Next Steps
wp scaffold plugin-tests— add tests to an existing plugin.wp scaffold post-type— add CPTs inside the plugin.