A comprehensive GitHub Action for checking WordPress Coding Standards with PHP compatibility support.
- ✅ WordPress Coding Standards - Full support for WordPress, WordPress-Core, WordPress-Extra
- ✅ PHP Compatibility - Check compatibility across PHP versions (7.4-8.3)
- ✅ Flexible Configuration - Use custom phpcs.xml or built-in defaults
- ✅ Multiple Standards - Support for various coding standards
- ✅ Detailed Reporting - Full violation reports with error/warning counts
- ✅ Customizable Failure - Fail on errors, warnings, or never
- ✅ Path Filtering - Check specific directories or files
- ✅ Pattern Ignoring - Exclude files/directories with patterns
name: WPCS Check
on: [push, pull_request]
jobs:
wpcs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: phpwpcs Check
uses: imjafran/phpwpcs@v1.0.0| Input | Description | Required | Default |
|---|---|---|---|
paths |
Paths to check | No | . |
standards |
PHPCS standards (WordPress,WordPress-Core,WordPress-Extra,PHPCompatibility) | No | WordPress,PHPCompatibility |
php-version |
PHP version (7.4-8.3) | No | 8.0 |
min-php-version |
Minimum PHP version for compatibility | No | 7.4 |
max-php-version |
Maximum PHP version for compatibility | No | 8.3 |
config-url |
Custom phpcs.xml URL | No | Built-in default |
fail-on |
Fail on (error, warning, never) | No | error |
ignore-patterns |
Patterns to ignore | No | vendor/*,node_modules/*,build/*,dist/* |
| Output | Description |
|---|---|
violations |
Total violations (errors + warnings) |
errors |
Error count |
warnings |
Warning count |
files |
Number of files checked |
- name: phpwpcs Check
uses: imjafran/phpwpcs@v1.0.0- name: Plugin Standards Check
uses: imjafran/phpwpcs@v1.0.0
with:
paths: 'includes/ admin/ public/'
standards: 'WordPress,PHPCompatibility'
php-version: '8.0'
min-php-version: '7.4'
max-php-version: '8.3'
ignore-patterns: 'vendor/*,node_modules/*,tests/*'- name: Theme Standards Check
uses: imjafran/phpwpcs@v1.0.0
with:
standards: 'WordPress-Core,WordPress-Extra'
ignore-patterns: 'node_modules/*,build/*,dist/*,assets/*'
fail-on: 'warning'- name: Custom phpwpcs Check
uses: imjafran/phpwpcs@v1.0.0
with:
config-url: 'https://example.com/custom-phpcs.xml'
fail-on: 'never'- WordPress - Complete WordPress coding standards
- WordPress-Core - WordPress core coding standards
- WordPress-Extra - WordPress extra coding standards
- PHPCompatibility - PHP version compatibility checks
- Minimum: PHP 7.4
- Maximum: PHP 8.3
- Default: PHP 8.0
- Type: Composite Action
- Dependencies: PHP_CodeSniffer, WordPress Coding Standards, PHP Compatibility
- Configuration: Uses phpcs.xml for WordPress standards
- Outputs: violations, errors, warnings, files
phpwpcs/
├── action.yml # Main action definition
├── data/phpcs.xml # Default WordPress configuration
├── scripts/
│ ├── setup.sh # Install dependencies
│ ├── run-checks.sh # Execute PHPCS
│ └── validate.sh # Validate action structure
└── examples/ # Usage examples
The action automatically creates a phpcs.xml configuration file if one doesn't exist. You can:
- Use the built-in default - Automatically configured for WordPress standards
- Provide a custom URL - Use
config-urlinput to specify a custom configuration - Use existing file - If
phpcs.xmlexists in your repository, it will be used
Default ignore patterns:
vendor/*- Composer dependenciesnode_modules/*- Node.js dependenciesbuild/*- Build artifactsdist/*- Distribution files
You can customize these using the ignore-patterns input.
- error (default) - Fail only on errors
- warning - Fail on both errors and warnings
- never - Never fail, always pass
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes following WordPress Coding Standards
- Add tests if applicable
- Run validation:
./scripts/validate.sh - Submit a pull request
# Clone the repository
git clone https://github.com/imjafran/phpwpcs.git
cd phpwpcs
# Install dependencies (if needed)
# The action uses composite action, so no additional dependencies
# Validate the action
./scripts/validate.sh
# Test locally
# Create a test workflow using ./This project is licensed under the MIT License - see the LICENSE file for details.
- name: phpwpcs Check
uses: ./# Validate action structure
./scripts/validate.sh
# Run tests
./scripts/release.sh- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: This README and examples in
/examples - Testing: Use the test workflow in
.github/workflows/test.yml
When reporting issues, please include:
- Action version used
- PHP version
- WordPress standards being checked
- Complete error output
- Steps to reproduce