Markdown Converter
Agent skill for markdown-converter
This is a comprehensive WordPress plugin boilerplate that follows modern PHP development standards, WordPress coding guidelines, and includes advanced tooling for professional plugin development. It's designed to be a starting point for creating robust, scalable WordPress plugins.
Sign in to like and favorite skills
This is a comprehensive WordPress plugin boilerplate that follows modern PHP development standards, WordPress coding guidelines, and includes advanced tooling for professional plugin development. It's designed to be a starting point for creating robust, scalable WordPress plugins.
WordPress_Plugin_Boilerplate\wordpress-plugin-boilerplate/ āāā .github/ # GitHub workflows and templates ā āāā workflows/ ā ā āāā build-zip.yml # Automated plugin zip creation ā ā āāā wordpress-plugin-deploy.yml # WordPress.org deployment ā āāā copilot-instructions.md # AI agent instructions āāā .wordpress-org/ # WordPress.org assets ā āāā banner-1544x500.jpg # Plugin banner (large) ā āāā banner-772x250.jpg # Plugin banner (small) ā āāā icon-128x128.jpg # Plugin icon (small) ā āāā icon-256x256.jpg # Plugin icon (large) āāā admin/ # Admin area functionality ā āāā Main.php # Admin main class ā āāā partials/ # Admin templates ā āāā menu.php # Admin menu template ā āāā index.php # Security file āāā build/ # Compiled assets (auto-generated) ā āāā css/ # Compiled CSS files ā āāā js/ # Compiled JavaScript files ā āāā media/ # Processed media files āāā includes/ # Core plugin classes ā āāā main.php # Main plugin class ā āāā loader.php # Hook loader class ā āāā activator.php # Plugin activation logic ā āāā deactivator.php # Plugin deactivation logic ā āāā i18n.php # Internationalization ā āāā Autoloader.php # PSR-4 autoloader āāā languages/ # Translation files ā āāā wordpress-plugin-boilerplate.pot āāā public/ # Public-facing functionality ā āāā Main.php # Public main class ā āāā partials/ # Public templates āāā src/ # Source assets (development) ā āāā js/ # JavaScript source files ā āāā scss/ # SCSS source files ā āāā media/ # Media source files āāā vendor/ # Composer dependencies āāā composer.json # Composer configuration āāā package.json # npm configuration āāā webpack.config.js # Webpack build configuration āāā init-plugin.sh # Plugin initialization script āāā wordpress-plugin-boilerplate.php # Main plugin file
The
init-plugin.sh script automates the creation of a new plugin from the boilerplate:
Plugin Name Input:
my-awesome-plugin), prefix (my_awesome_plugin), namespace (MyAwesomePlugin)GitHub Organization:
mycompany/my-awesome-plugin)Automated Transformations:
my-awesome-plugin.phplanguages/my-awesome-plugin.potwordpress-plugin-boilerplate ā my-awesome-pluginWordPress Plugin Boilerplate ā My Awesome Pluginwordpress_plugin_boilerplate ā my_awesome_pluginWORDPRESS_PLUGIN_BOILERPLATE ā MY_AWESOME_PLUGINWordPress_Plugin_Boilerplate ā My_Awesome_PluginProject Setup:
# Clone the repository git clone https://github.com/WPBoilerplate/wordpress-plugin-boilerplate.git my-plugin-name # Navigate to directory cd my-plugin-name # Run initialization script ./init-plugin.sh # Or install dependencies manually composer install npm install
CRITICAL FIRST STEP: Always verify PHP version before any development work:
# Check PHP version BEFORE starting development php -v # Expected output: PHP 7.4.0 or higher # Example: PHP 8.0.30 (cli) (built: Aug 5 2023 10:50:05)
ESSENTIAL VALIDATION:
PHP Version Benefits for Development:
The plugin uses WordPress's official build tools for modern development:
# Development build (with source maps) npm run start # Production build (optimized) npm run build # Check for JavaScript errors npm run lint:js # Fix JavaScript formatting npm run lint:js:fix # Check for CSS errors npm run lint:css # Generate translation files npm run makepot
MANDATORY: All packages require PHP 7.4+ enforced in
composer.json:
{ "require": { "php": ">=7.4", "wpboilerplate/wpb-register-blocks": "^1.0" } }
ESSENTIAL ENFORCEMENT:
The
init-plugin.sh script provides an interactive interface for selecting WPBoilerplate packages during setup:
composer.jsonincludes/main.phpCRITICAL: When modifying or enhancing
init-plugin.sh, always maintain:
NOTE: Mozart is already included in the base
composer.json as a core development tool and doesn't need to be added to the interactive package selection process.
Mozart is a Composer plugin that helps prevent conflicts between WordPress plugins by:
{ "extra": { "mozart": { "dep_namespace": "WordPress_Plugin_Boilerplate\\Vendor\\", "dep_directory": "/src/dependencies/", "classmap_directory": "/classes/dependencies/", "classmap_prefix": "WPBP_", "packages": [ "vendor/package-name" ] } } }
# 1. Mozart is already installed in composer.json # composer require coenjacobs/mozart:^0.7 # Already included # 2. Configure Mozart in composer.json (see above) # 3. Install your dependencies composer require vendor/library-name # 4. Run Mozart to scope dependencies vendor/bin/mozart compose # 5. Use scoped dependencies in code use WordPress_Plugin_Boilerplate\Vendor\LibraryName\ClassName;
{ "autoload": { "psr-4": { "WordPress_Plugin_Boilerplate\\Includes\\": "includes/", "WordPress_Plugin_Boilerplate\\Admin\\": "admin/", "WordPress_Plugin_Boilerplate\\Public\\": "public/" } } }
Create a block folder inside the
directory and scaffold a block:src/blocks
mkdir -p src/blocks cd src/blocks npx @wordpress/create-block my-plugin-name-block --no-plugin
This will scaffold a new block inside
src/blocks/my-plugin-name-block.
Add Block Registration Package:
composer require wpboilerplate/wpb-register-blocks
Integration Code (automatically added in
includes/main.php):
/** * Auto-register blocks from build/blocks directory */ if ( class_exists( 'WPBoilerplate\\RegisterBlocks\\RegisterBlocks' ) ) { new \WPBoilerplate\RegisterBlocks\RegisterBlocks( $this->plugin_dir ); }
Build Blocks:
npm run build
build/blocks/ directoryESSENTIAL REFERENCE: We use the comprehensive x3p0-ideas block example as the AUTHORITATIVE STANDARD for advanced block development.
CRITICAL IMPLEMENTATION: Always implement blocks using multiple input files for maintainability and performance:
src/blocks/ āāā {block-name}/ ā āāā block.json # REQUIRED: Block metadata ā āāā index.js # REQUIRED: Main registration entry ā āāā edit.js # REQUIRED: Editor component (SEPARATE FILE) ā āāā save.js # REQUIRED: Save component (SEPARATE FILE) ā āāā view.js # OPTIONAL: Frontend interactivity (SEPARATE FILE) ā āāā style.scss # REQUIRED: Frontend styles ā āāā editor.scss # REQUIRED: Editor-specific styles ā āāā variations.js # OPTIONAL: Block variations (SEPARATE FILE) ā āāā controls/ # OPTIONAL: Custom control components ā āāā inspector.js # Custom inspector panels ā āāā toolbar.js # Custom toolbar controls
Block Registration Pattern (ALWAYS USE):
// index.js - Main registration ONLY import { registerBlockType } from '@wordpress/blocks'; import Edit from './edit'; import Save from './save'; import metadata from './block.json'; registerBlockType( metadata.name, { ...metadata, edit: Edit, save: Save, } );
Modular Edit Component (REQUIRED):
// edit.js - Editor interface ONLY import { useBlockProps } from '@wordpress/block-editor'; import { PanelBody, TextControl } from '@wordpress/components'; import Inspector from './controls/inspector'; export default function Edit( { attributes, setAttributes } ) { const blockProps = useBlockProps(); return ( <> <Inspector attributes={attributes} setAttributes={setAttributes} /> <div {...blockProps}> {/* Edit interface */} </div> </> ); }
Separate Save Component (REQUIRED):
// save.js - Static output ONLY import { useBlockProps } from '@wordpress/block-editor'; export default function Save( { attributes } ) { const blockProps = useBlockProps.save(); return ( <div {...blockProps}> {/* Saved content */} </div> ); }
Frontend Interactivity (WHEN NEEDED):
// view.js - Frontend behavior ONLY import domReady from '@wordpress/dom-ready'; domReady( () => { // Frontend JavaScript for block interactions // Event handlers, dynamic content, etc. } );
{ "name": "my-plugin/block-name", "title": "Block Title", "category": "common", "editorScript": "file:./index.js", "viewScript": "file:./view.js", "style": "file:./style.css", "editorStyle": "file:./editor.css", "attributes": { // Block attributes }, "supports": { // Block supports } }
CRITICAL: The @wordpress/scripts build system AUTOMATICALLY handles multiple input files:
// webpack.config.js (AUTO-GENERATED) // DO NOT MODIFY - automatically processes: // - All .js files in src/blocks/{block-name}/ // - All .scss/.css files in src/blocks/{block-name}/ // - Outputs to build/blocks/{block-name}/
REFERENCE IMPLEMENTATION: https://github.com/x3p0-dev/x3p0-ideas/tree/block-example
ALWAYS document when implementing multiple input file blocks:
The plugin uses a centralized loader system for managing WordPress hooks:
// Add action hook $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); // Add filter hook $this->loader->add_filter( 'the_content', $plugin_public, 'filter_content' );
The main class follows dependency injection patterns:
WordPress_Plugin_Boilerplate\Includes\ - Core functionalityWordPress_Plugin_Boilerplate\Admin\ - Admin area featuresWordPress_Plugin_Boilerplate\Public\ - Public-facing featuresThe project follows WordPress Coding Standards with custom ruleset:
<!-- phpcs.xml.dist --> <?xml version="1.0"?> <ruleset name="WordPress Plugin Boilerplate"> <description>WordPress Coding Standards for Plugin</description> <file>.</file> <exclude-pattern>*/vendor/*</exclude-pattern> <exclude-pattern>*/build/*</exclude-pattern> <exclude-pattern>*/node_modules/*</exclude-pattern> <rule ref="WordPress"> <exclude name="WordPress.Files.FileName"/> </rule> </ruleset>
The boilerplate supports easy REST API endpoint creation:
// In your main class or dedicated API class add_action( 'rest_api_init', array( $this, 'register_api_endpoints' ) ); public function register_api_endpoints() { register_rest_route( 'my-plugin/v1', '/endpoint', array( 'methods' => 'GET', 'callback' => array( $this, 'api_callback' ), 'permission_callback' => array( $this, 'api_permissions' ), ) ); }
your-plugin/v1For plugins requiring custom database tables:
// In activator.php public static function create_tables() { global $wpdb; $table_name = $wpdb->prefix . 'my_plugin_table'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE $table_name ( id mediumint(9) NOT NULL AUTO_INCREMENT, name tinytext NOT NULL, created_at datetime DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (id) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); }
For configuration storage:
get_option() and update_option()my_plugin_option_name// Sanitize text input $clean_text = sanitize_text_field( $_POST['user_input'] ); // Sanitize email $clean_email = sanitize_email( $_POST['email'] ); // Validate and sanitize URLs $clean_url = esc_url_raw( $_POST['url'] );
// Generate nonce wp_nonce_field( 'my_plugin_action', 'my_plugin_nonce' ); // Verify nonce if ( ! wp_verify_nonce( $_POST['my_plugin_nonce'], 'my_plugin_action' ) ) { wp_die( 'Security check failed' ); }
// Check user capabilities if ( ! current_user_can( 'manage_options' ) ) { wp_die( 'Insufficient permissions' ); }
WP_Query, get_posts())Text Domain: Use plugin slug as text domain
Translation Functions:
__( 'Text to translate', 'my-plugin-textdomain' ); _e( 'Text to echo', 'my-plugin-textdomain' ); _n( 'Singular', 'Plural', $count, 'my-plugin-textdomain' );
Generate POT File:
npm run makepot
The boilerplate includes GitHub Actions for automated deployment:
# Local development with WordPress # Use Docker docker-compose up -d # Or use Local by Flywheel, XAMPP, etc.
// wp-config.php additions for development define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); define( 'SCRIPT_DEBUG', true );
// Register custom post type add_action( 'init', array( $this, 'register_custom_post_types' ) ); public function register_custom_post_types() { register_post_type( 'my_custom_type', array( 'labels' => array( 'name' => __( 'Custom Types', 'textdomain' ), ), 'public' => true, 'supports' => array( 'title', 'editor' ), ) ); }
// Register widgets add_action( 'widgets_init', array( $this, 'register_widgets' ) ); public function register_widgets() { register_widget( 'My_Custom_Widget' ); }
// Register shortcodes add_shortcode( 'my_shortcode', array( $this, 'shortcode_callback' ) ); public function shortcode_callback( $atts ) { $atts = shortcode_atts( array( 'attribute' => 'default_value', ), $atts ); return '<div class="my-shortcode">' . esc_html( $atts['attribute'] ) . '</div>'; }
The boilerplate includes dedicated packages for popular plugin integrations:
WooCommerce Integration
BuddyPress/BuddyBoss Integration
Advanced Custom Fields Pro
CRITICAL: Always update the
README.md file when making changes to the project. This is essential for documentation accuracy and developer experience.
Adding New Composer Packages:
# After running composer require composer require new/package # IMMEDIATELY update README.md with: # - Package name and purpose # - Installation command # - Integration code example # - Usage instructions
npm Package Updates:
# After adding new npm dependencies npm install new-package # Update README.md sections: # - Build system dependencies # - Available npm commands # - Development workflow changes
Project Structure Changes:
Feature Additions:
For Composer Packages:
## š¦ Composer Packages ### [Package Category] (if new category) ```bash # [Package description] composer require vendor/package-name
// Add to load_composer_dependencies() method if ( class_exists( 'Vendor\\Package\\ClassName' ) ) { new Vendor\Package\ClassName( $this->plugin_dir ); }
**For npm Packages:** ```markdown ## š ļø Build System ### Updated Dependencies ```json { "devDependencies": { "new-package": "^1.0.0" } }
# New command description npm run new-command
#### Standard README.md Sections to Maintain: 1. **Features List** - Keep current with new capabilities 2. **Requirements** - Update version requirements 3. **Installation Instructions** - Reflect current setup process 4. **Build Commands** - Keep npm scripts current 5. **Package Lists** - Maintain accurate dependency lists 6. **Code Examples** - Update integration examples 7. **Project Structure** - Reflect current directory organization 8. **Usage Examples** - Keep code samples current #### Documentation Standards: 1. **Code Examples**: Always include working, tested code 2. **Version Numbers**: Keep package versions current 3. **Links**: Ensure all repository links are valid 4. **Structure**: Maintain consistent formatting 5. **Clarity**: Write for developers of all skill levels #### Automated Documentation Workflow: ```bash # Suggested workflow after changes 1. Make code changes 2. Update README.md immediately 3. Test all code examples in README.md 4. Commit both code and documentation changes 5. Create descriptive commit messages mentioning docs updates
// Activation hook register_activation_hook( __FILE__, array( 'Activator', 'activate' ) ); // Deactivation hook register_deactivation_hook( __FILE__, array( 'Deactivator', 'deactivate' ) );
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) ); public function add_admin_menu() { add_menu_page( __( 'My Plugin', 'textdomain' ), __( 'My Plugin', 'textdomain' ), 'manage_options', 'my-plugin-slug', array( $this, 'admin_page_callback' ) ); }
add_action( 'admin_init', array( $this, 'settings_init' ) ); public function settings_init() { register_setting( 'my_plugin_settings', 'my_plugin_options' ); add_settings_section( 'my_plugin_section', __( 'Settings Section', 'textdomain' ), null, 'my_plugin_settings' ); }
CRITICAL RULE: Every time you add a package, modify configuration, or change project structure, you MUST update the README.md file immediately. This is not optional.
Composer Package Addition:
composer require vendor/package-name
Action Required: Add package to README.md with installation command, integration code, and usage examples.
š CRITICAL: PHP Version Requirement Changes:
{ "require": { "php": ">=7.4" } }
MANDATORY Action: Update both README.md and agents.md with:
CRITICAL: Block Development with Multiple Input Files:
# When implementing x3p0-ideas patterns
MANDATORY Action: Update README.md "Advanced Block Development" section with:
npm Package Changes:
npm install package-name
Action Required: Update build system documentation and available commands.
File Structure Modifications:
Configuration Changes:
For New Composer Packages:
#### [Package Name] - [Brief Description] ```bash composer require vendor/package-name
Integration (add to
load_composer_dependencies() method):
if ( class_exists( 'Vendor\\Package\\MainClass' ) ) { new Vendor\Package\MainClass( $this->plugin_dir ); }
Purpose: Explain what this package does and why it's included.
**For npm Dependencies:** ```markdown #### [Package Name] ```bash npm install package-name
Usage: Explain how this affects the build process or development workflow.
#### Quality Assurance Checklist: - [ ] All new packages documented with installation commands - [ ] Integration code examples provided and tested - [ ] Project structure diagram reflects current state - [ ] All links are functional and up-to-date - [ ] Code examples use current file paths and class names - [ ] Version requirements are accurate - [ ] Build commands list is complete and current #### Documentation Workflow: 1. **Before Making Changes**: Note current README.md state 2. **During Development**: Track what needs documentation updates 3. **After Changes**: Immediately update README.md 4. **Verification**: Test all documented commands and code examples 5. **Commit**: Include README.md changes in the same commit as code changes #### Common Documentation Patterns: **Package Documentation Pattern:** 1. Brief description of package purpose 2. Installation command 3. Integration code (where to add in the codebase) 4. Configuration options (if any) 5. Usage examples or notes **Build System Updates:** 1. New npm commands with descriptions 2. Updated dependencies list 3. Modified workflow instructions 4. Changed file output locations **Architecture Changes:** 1. Updated directory structure 2. New file locations 3. Modified class namespaces 4. Changed integration patterns This comprehensive guide provides LLMs with detailed information about the WordPress Plugin Boilerplate structure, development workflows, best practices for creating professional WordPress plugins, and mandatory documentation maintenance protocols.