Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>WidgiLabs WordPress Coding StandardsNew to Visual Studio Code? Get it now.
WidgiLabs WordPress Coding Standards

WidgiLabs WordPress Coding Standards

Widgilabs

| (0) | Free
WordPress Coding Standards extension by WidgiLabs - Compatible with Cursor AI IDE and VSCode
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

WidgiLabs WordPress Coding Standards

Extension for Cursor AI IDE and VSCode that integrates PHP_CodeSniffer with WordPress Coding Standards to check and format PHP code following WordPress standards.

🚀 Features

  • 🧠 WordPress IntelliSense: Smart autocomplete for 50+ hooks and 60+ WordPress functions with inline documentation!
  • 🆕 Go to Definition: Smart navigation - Ctrl+Click on functions/methods/classes to go directly to definition (IntelliPHP style)
  • 🆕 Install Dependencies: Automatically installs PHPCS and WordPress Standards via Composer (no manual configuration!)
  • ✅ Check Code: Checks the current PHP file against WordPress Coding Standards
  • 🔧 Format Code: Automatically formats code following WordPress standards
  • 📁 Check Entire Project: Checks all PHP files in the project
  • ⌨️ Keyboard Shortcuts: Pre-configured keyboard shortcuts (Ctrl+Alt+F to format, Ctrl+Alt+C to check)
  • ⚡ Auto Format on Save: Automatically formats when saving PHP files
  • 💡 Quick Fix DocBlock: Adds DocBlocks automatically with one click (PHPStorm style)
  • 🤖 AI-Powered DocBlocks: Generates intelligent and contextual documentation using AI (optional)
  • 🔍 Run Diagnostics: Checks PHPCS and WordPress Standards installation
  • 🔗 Extension Dependencies: Optional support for VS Code Composer extensions

📋 Prerequisites

Quick Installation (Recommended) 🚀

The extension can install dependencies automatically for you!

  1. Install only Composer: https://getcomposer.org/download/
  2. Press Ctrl+Shift+P in Cursor/VSCode
  3. Type "WidgiLabs WPCS: Install Dependencies"
  4. Wait for automatic installation of PHPCS and WordPress Standards
  5. Restart Cursor/VSCode

✅ Done! The extension will install and configure everything automatically.

Manual Installation (Alternative)

If you prefer to install manually:

1. Install PHP

Make sure PHP is installed and in the system PATH.

php --version

2. Install Composer

Download and install Composer: https://getcomposer.org/download/

composer --version

3. Install PHP_CodeSniffer

composer global require "squizlabs/php_codesniffer=*"

4. Install WPCS dependencies (IMPORTANT!)

WordPress Coding Standards 3.0+ requires additional libraries:

composer global require "phpcsstandards/phpcsutils=^1.0"
composer global require "phpcsstandards/phpcsextra=^1.0"

5. Install WordPress Coding Standards

composer global require "wp-coding-standards/wpcs=^3.0"

6. Configure PHPCS to use WordPress Standards (with all dependencies)

Windows:

phpcs --config-set installed_paths "%APPDATA%\Composer\vendor\wp-coding-standards\wpcs,%APPDATA%\Composer\vendor\phpcsstandards\phpcsutils,%APPDATA%\Composer\vendor\phpcsstandards\phpcsextra"

Linux/Mac:

phpcs --config-set installed_paths "~/.composer/vendor/wp-coding-standards/wpcs,~/.composer/vendor/phpcsstandards/phpcsutils,~/.composer/vendor/phpcsstandards/phpcsextra"

7. Verify installation

phpcs -i

You should see: The installed coding standards are MySource, PEAR, PSR1, PSR2, PSR12, Squiz, Zend, WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra, Universal, Modernize, NormalizedArrays

⚠️ Important: If you don't see Universal, Modernize and NormalizedArrays, review steps 4 and 6.

🔧 Usage

Available Commands

Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) to open the command palette and type:

  1. WidgiLabs WPCS: Install Dependencies - 🆕 Automatically installs PHPCS and WordPress Standards via Composer
  2. WidgiLabs WPCS: Check Code - Checks the current file
  3. WidgiLabs WPCS: Format Code - Formats the current file
  4. WidgiLabs WPCS: Check Entire Project - Checks the entire project
  5. WidgiLabs WPCS: Run Diagnostics - Checks installation and configuration

⌨️ Keyboard Shortcuts (Included Automatically!)

The extension comes with pre-configured keyboard shortcuts! No need to configure anything manually.

Command Windows/Linux Mac Description
Format Code Ctrl+Alt+F Cmd+Alt+F Formats the current PHP file
Check Code Ctrl+Alt+C Cmd+Alt+C Checks the current PHP file
Check Project Ctrl+Alt+P Cmd+Alt+P Checks the entire project

💡 Note: Shortcuts only work in open PHP files.

Customizing Shortcuts

If you want to change the default shortcuts:

  1. Go to File > Preferences > Keyboard Shortcuts (or Ctrl+K Ctrl+S)
  2. Search for "WidgiLabs"
  3. Click on the current shortcut and define a new one

📖 Complete Guide: For more details, examples and usage tips, see KEYBOARD-SHORTCUTS.md


🎯 Go to Definition (NEW!)

Navigate through code like a pro! Just like IntelliPHP.

How to use:

  1. Ctrl+Click (or Cmd+Click on Mac) on any function, method or class
  2. Or press F12 with the cursor over the symbol
  3. Or right-click → "Go to Definition"

Works with:

✅ Functions
✅ Class methods
✅ Classes, Interfaces, Traits
✅ Search in current file and entire workspace

Example:

// Definition in inc/helpers.php
function calculate_discount($price, $percent) {
    return $price * (1 - $percent / 100);
}

// Usage in functions.php
// Ctrl+Click on "calculate_discount" → opens inc/helpers.php
$final_price = calculate_discount(100, 20);

📖 Complete Guide: See GO-TO-DEFINITION.md for more examples and advanced tips.


🧠 WordPress IntelliSense (NEW!)

Smart autocomplete for WordPress functions with navigable snippets!

Integration with WordPress Hooks IntelliSense

The extension automatically installs WordPress Hooks IntelliSense which provides:

  • ✅ 1000+ WordPress Hooks (Core Actions and Filters)
  • ✅ Popular Plugin Hooks (WooCommerce, ACF, Yoast, etc.)
  • ✅ Community-updated database

Our Unique Contributions:

  • ✅ 60+ WordPress Functions with navigable snippets (get_post_meta, wp_enqueue_script, is_single, etc.)

Examples:

// Type add_action(' and see list of available actions
add_action('init', function() {
    // ...
});

// Type wp_enqueue_ and see functions with navigable parameters
wp_enqueue_script('handle', 'src', array(), '1.0', true);

// Type get_post_ and see related functions
$meta = get_post_meta($post_id, $key, true);

// Type is_ and see all conditional functions
if (is_single()) {
    // ...
}

Features:

  • 📖 Inline documentation for each hook/function
  • 🎨 Snippets with navigable parameters (Tab)
  • ⚡ Smart contextual suggestions
  • 🔍 Automatic filtering by type (Action/Filter)

📖 Complete Guide: See WORDPRESS-INTELLISENSE.md with all available hooks and functions.


⚙️ Settings

Access settings in File > Preferences > Settings and search for "WidgiLabs":

  • phpcsPath: Path to phpcs executable (default: phpcs)
  • phpcbfPath: Path to phpcbf executable (default: phpcbf)
  • standard: WordPress standard to use (options: WordPress, WordPress-Core, WordPress-Extra, WordPress-Docs)
  • autoFormat: Automatically format on save (default: false)

🚀 Enable Auto Format on Save

To enable automatic formatting when you save PHP files:

  1. Via Interface:

    • Press Ctrl+, to open Settings
    • Search for "WidgiLabs"
    • Check the "Auto Format" option
  2. Via settings.json:

    • Press Ctrl+Shift+P and type "Open Settings (JSON)"
    • Add or change:
    {
      "widgilabswpcs.autoFormat": true
    }
    
  3. Use the example file:

    • Copy .vscode/settings.json.example to .vscode/settings.json
    • The file already comes with autoFormat: true configured

Complete configuration example in settings.json:

{
  "widgilabswpcs.phpcsPath": "phpcs",
  "widgilabswpcs.phpcbfPath": "phpcbf",
  "widgilabswpcs.standard": "WordPress",
  "widgilabswpcs.autoFormat": true
}

📦 Available WordPress Standards

  • WordPress: Complete standard (recommended)
  • WordPress-Core: WordPress main standards
  • WordPress-Extra: Extra rules beyond Core
  • WordPress-Docs: Documentation standards

🐛 Troubleshooting

Error "Referenced sniff does not exist" (PHPCSUtils, Universal, etc.)

If you see errors like:

ERROR: Referenced sniff "PHPCSUtils" does not exist.
ERROR: Referenced sniff "Universal.*" does not exist.

Cause: WPCS 3.0+ dependencies are not installed.

Quick Solution:

  1. Ctrl+Shift+P → "WidgiLabs WPCS: Install Dependencies"
  2. Restart Cursor/VSCode

Manual Solution: See the complete guide at FIX-DEPENDENCIES.md

PHPCS not found

If you get the error "PHP_CodeSniffer not found":

  1. Check if Composer is installed globally
  2. Add the Composer bin directory to PATH:
    • Windows: %APPDATA%\Composer\vendor\bin
    • Linux/Mac: ~/.composer/vendor/bin

WordPress Standards not found

Run (including all dependencies):

phpcs --config-set installed_paths "%APPDATA%\Composer\vendor\wp-coding-standards\wpcs,%APPDATA%\Composer\vendor\phpcsstandards\phpcsutils,%APPDATA%\Composer\vendor\phpcsstandards\phpcsextra"

💡 Quick Fix for DocBlocks with AI (NEW!)

The extension now detects functions without DocBlock and offers automatic Quick Fix, just like PHPStorm!

⚡ Basic Mode (Default - Free)

  1. Open a PHP file with functions without DocBlock
  2. You will see a yellow warning (⚠️) on the function
  3. Click the bulb 💡 or press Ctrl+.
  4. Select "💡 Add DocBlock for function_name()"
  5. ✅ DocBlock is generated automatically!

🤖 AI Mode (Optional - OpenAI API)

Want even better and contextual descriptions? Enable AI!

Configure:

{
  "widgilabswpcs.aiDocBlock": true,
  "widgilabswpcs.openaiApiKey": "sk-your-key-here"
}

Result: AI analyzes your code and generates specific and professional descriptions!

📖 Complete guide: DOCBLOCK-AI.md

Example:

// Before (shows warning ⚠️)
function get_user_posts(int $user_id, string $status): array {
    return get_posts(['author' => $user_id, 'post_status' => $status]);
}

// After applying Quick Fix (Ctrl+.)
/**
 * Gets the user posts.
 *
 * @param int    $user_id Description for $user_id.
 * @param string $status Description for $status.
 *
 * @return array
 */
function get_user_posts(int $user_id, string $status): array {
    return get_posts(['author' => $user_id, 'post_status' => $status]);
}

📖 Complete documentation: See AUTO-DOCBLOCK.md

📝 Usage Example

  1. Open a WordPress PHP file
  2. Press Ctrl+Shift+P
  3. Type "WidgiLabs WPCS: Check Code"
  4. See problems in the Output panel
  5. Use "WidgiLabs WPCS: Format Code" to fix automatically
  6. Use Ctrl+. on functions without DocBlock to add documentation automatically

📦 Build and Installation

Install the Extension

Method 1: Automatic Script (Recommended)

Windows:

.\build-extension.ps1

Linux/Mac:

chmod +x build-extension.sh
./build-extension.sh

Method 2: Manual

  1. Install vsce:
npm install -g @vscode/vsce
  1. Create the package:
vsce package
  1. Install:
cursor --install-extension widgilabswpcs-0.0.1.vsix

📖 Complete guide: BUILD-INSTALL.md

🤝 Contributing

Developed by WidgiLabs to facilitate WordPress development following best practices.

🔗 Extension Dependencies

This extension declares optional dependency on the Composer PHP Support extension (devsense.composer-php-vscode). This means:

  • ✅ When you install this extension, VS Code/Cursor suggests automatically installing the Composer extension
  • ✅ You get extra features to manage PHP dependencies via Composer
  • ✅ Graphical interface for Composer integrated into the IDE
  • ℹ️ It's optional - the extension works without it, but with the Composer extension you have even more features

Alternative Composer Extensions

If you prefer another Composer extension, you can install manually:

  • devsense.composer-php-vscode - Composer PHP Support (recommended)
  • ikappas.composer - Composer (alternative)

📄 License

MIT

📦 Publishing and Distribution

Install Extension

The extension is available on the Visual Studio Marketplace:

# Via VS Code/Cursor
code --install-extension widgilabs.widgilabswpcs
# or
cursor --install-extension widgilabs.widgilabswpcs

Or search for "WidgiLabs WPCS" in the extensions tab.

For Developers

If you want to publish your own version or contribute:

  1. Build: See BUILD-INSTALL.md
  2. Publish: See PUBLISH-MARKETPLACE.md

📚 Complete Documentation

  • README.md - This file (overview)
  • CHANGELOG.md - 🆕 Version history and changes
  • QUICK-START.md - Quick start guide
  • BUILD-INSTALL.md - How to build and install
  • PUBLISH-MARKETPLACE.md - 🆕 How to publish to VS Code Marketplace
  • WORDPRESS-INTELLISENSE.md - 🆕 Autocomplete for WordPress hooks and functions
  • GO-TO-DEFINITION.md - 🆕 Smart navigation with Ctrl+Click (IntelliPHP style)
  • FIX-DEPENDENCIES.md - 🆕 Fix dependency errors (PHPCSUtils, Universal, etc.)
  • KEYBOARD-SHORTCUTS.md - 🆕 Complete keyboard shortcuts guide
  • EXTENSION-DEPENDENCIES.md - 🆕 How to use extensions as dependencies and automatic installation
  • AUTO-FORMATTING.md - Configure automatic formatting
  • AUTO-DOCBLOCK.md - DocBlocks with Quick Fix
  • DOCBLOCK-AI.md - DocBlocks with Artificial Intelligence
  • SETUP-WINDOWS.md - Detailed Windows configuration

Enjoy the extension and develop WordPress with quality! 🚀

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft