This directory contains modular PHPCS (PHP_CodeSniffer) rulesets based on the WordPress Plugin Check plugin standards.
phpcs-xml/
├── plugin-check-security.xml # Security-focused rules
├── plugin-check-performance.xml # Performance optimization rules
├── plugin-check-general.xml # General WordPress coding standards
├── plugin-check-accessibility.xml # Accessibility compliance rules
└── plugin-check-plugin-repo.xml # WordPress.org plugin repository requirements
Comprehensive security checks including:
- Database Security: SQL injection prevention, prepared statements
- Input Validation: Nonce verification, sanitization
- Output Escaping: XSS prevention
- Dangerous Functions: eval, passthru, create_function, etc.
- PHP Security: Short tags, alternative tags prevention
- WordPress Security: Deprecated functions, safe redirects
Performance optimization checks:
- Alternative WordPress functions for better performance
- Slow database query detection
- Transient and cron usage optimization
WordPress coding best practices:
- WordPress coding standards compliance
- Proper resource enqueuing
- Global variable handling
- Internationalization (i18n)
- PHP best practices
Accessibility compliance checks:
- Image alt attributes
- Form label associations
- Heading structure
- HTML semantic structure
WordPress.org plugin repository requirements:
- Includes all security rules
- PHP compatibility (5.6+)
- Third-party library exclusions
- GPL compatibility (manual check)
vendor/bin/phpcs --standard=phpcs.xml.dist# Security only
vendor/bin/phpcs --standard=phpcs-xml/plugin-check-security.xml .
# Performance only
vendor/bin/phpcs --standard=phpcs-xml/plugin-check-performance.xml .
# General only
vendor/bin/phpcs --standard=phpcs-xml/plugin-check-general.xml .vendor/bin/phpcs --standard=phpcs-xml/plugin-check-security.xml,phpcs-xml/plugin-check-performance.xml .vendor/bin/phpcbf --standard=phpcs.xml.distTo enable/disable specific rulesets, edit the main phpcs.xml.dist file:
<!-- Enable security rules -->
<rule ref="./phpcs-xml/plugin-check-security.xml"/>
<!-- Disable performance rules (comment out) -->
<!-- <rule ref="./phpcs-xml/plugin-check-performance.xml"/> -->- Error (severity 7): Must be fixed (security critical issues)
- Error (default): Should be fixed (important issues)
- Warning: Should be reviewed (potential issues)
The following directories are excluded from all checks:
assets/- Frontend assetssrc/- Source files (if using build process)lib/- Third-party librariesbuild/- Build artifactsnode_modules/- NPM dependenciesvendor/- Composer dependenciestests/- Test filesbin/- Binary files
These rulesets are based on the official WordPress Plugin Check plugin: https://wordpress.org/plugins/plugin-check/
They follow the same categories and standards used for WordPress.org plugin reviews.