wptrt / wpthemereview
PHP_CodeSniffer rules (sniffs) to verify theme compliance with the rules for theme hosting on wordpress.org
Installs: 468 025
Dependents: 36
Suggesters: 0
Security: 0
Stars: 209
Watchers: 25
Forks: 37
Type:phpcodesniffer-standard
Requires
- php: >=5.4
- phpcompatibility/phpcompatibility-wp: ^2.0
- squizlabs/php_codesniffer: ^3.3.1
- wp-coding-standards/wpcs: ^2.2.0
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^0.5.0
- phpcompatibility/php-compatibility: ^9.0
- phpunit/phpunit: ^4.0 || ^5.0 || ^6.0 || ^7.0
- roave/security-advisories: dev-master
Suggests
- dealerdirect/phpcodesniffer-composer-installer: ^0.5.0 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.
- dev-develop
- 0.2.1
- 0.2.0
- 0.1.0
- dev-try/254
- dev-feature/add-new-upstream-sniffs
- dev-feature/disallow-tracking-sniff
- dev-william/tweak/fix-travis-for-lastest-phpcs
- dev-master
- dev-feature/minor-optimizations-and-fixes
- dev-feature/required-templates
- dev-feature/add-documentation
- dev-feature/issue-9-forbidden-functions
- dev-feature/issue-136-non-presentational-meta
- dev-feature/issue-125-google-search-and-ad-codes
- dev-feature/issue-127-removing-customizer-active-theme
- dev-JRF/searchform
- dev-feature/composer
This package is auto-updated.
Last update: 2024-10-22 13:33:49 UTC
README
WPThemeReview Standard for PHP_CodeSniffer
Introduction
WordPress Themes for which a hosting application has been made for the theme to be hosted in the theme repository on wordpress.org have to comply with a set of requirements before such an application can be approved. Additionally, there are also recommendations for best practices for themes.
This project attempts to automate the code analysis part of the Theme Review Process as much as possible using static code analysis.
PHP_CodeSniffer is the base tool upon which this project is build and is a PHP command-line tool.
This project is a work in progress and passing the checks is no guarantee that your theme will be approved.
Requirements
The WPThemeReview Standard requires:
- PHP 5.4 or higher.
- PHP_CodeSniffer version 3.3.1 or higher.
- WordPress Coding Standards version 2.2.0 or higher.
- PHPCompatibilityWP version 2.0.0 or higher.
Installation
The only supported installation method is via Composer.
- Make sure you have PHP installed on your system.
- If not installed yet, install Composer.
Installing WPThemeReview globally
If you would like to have the WPThemeReview standard available to all projects on your system, you can install it in a central location.
From the command-line, run the following command:
$ php composer.phar global require wptrt/wpthemereview dealerdirect/phpcodesniffer-composer-installer
Installing WPThemeReview as a project dependency
If you use Composer to manage dependencies from your project anyway or are considering using it, you can also choose to install the WPThemeReview standard for an individual project.
From the command-line, run the following command from the root directory of your project:
$ php composer.phar require --dev wptrt/wpthemereview:* dealerdirect/phpcodesniffer-composer-installer:^0.7
Note:
- The
--dev
means that WPThemeReview will be installed as a development requirement, not as a requirement for using the Theme.- The second package -
dealerdirect/phpcodesniffer-composer-installer
-, is a Composer plugin which will automatically sort out that PHP_CodeSniffer recognizes the WPThemeReview standard and the various WordPress standards.
Checking your installation was successful
# For a global install: $ phpcs -i # For a project install: $ vendor/bin/phpcs -i
If everything went well, the output should look something like this:
The installed coding standards are MySource, PEAR, PSR1, PSR12, PSR2, Squiz, Zend, PHPCompatibility,
PHPCompatibilityParagonieRandomCompat, PHPCompatibilityParagonieSodiumCompat, PHPCompatibilityWP,
WordPress, WordPress-Core, WordPress-Docs, WordPress-Extra and WPThemeReview
Using the WPThemeReview standard
You can now test your theme code against the WPThemeReview standard by running the following command from the root directory of your theme:
# For a global install: $ phpcs -p . --standard=WPThemeReview # For a project install: $ vendor/bin/phpcs -p . --standard=WPThemeReview
If any issues are found, PHP_CodeSniffer will display a report with all the errors (must fix) and warnings (recommended to fix) for each file.
More information about running PHP_CodeSniffer can be found in the PHP_CodeSniffer Wiki.
Contributing
See CONTRIBUTING, including information about unit testing the standard.
License
See LICENSE (MIT).