Install PHP, WooCommerce, and WordPress Coding Standards
WordPress coding standards are used to verify the coding standard of WordPress plugins and themes. If you want to publish your plugin or theme in any market, you should first set the standards and then upload your zip file for submission.
I am explaining a few steps to easily install standards on windows.
Download Composer-Setup.exe and run it – follow the steps and install it for all users.
Install PHP code sniffer
Open your command prompt and run this command.
composer global require "squizlabs/php_codesniffer=*"
Download WordPress Coding Standards
Download the package and make move it to a safe folder. Make sure you don’t have a folder in the path that contains space(s) in the name. You will not be able to set it as a path of standards through the command prompt.
Read more about WordPress Coding standards
PHP Coding Standard WordPress
The following are the themes of the standards for PHP.
- Declare Statements, Namespace, and Import Statements
- Object Oriented Programming
Visit the link below to read WordPress Coding Standards for PHP.
HTML Coding Standard
Visit the link below to read WordPress Coding Standards for HTML.
CSS Coding Standard
Visit the link below to read WordPress Coding Standards for CSS.
WooCommerce Code Sniffer / WooCommerce Coding Standards
Install by Command.
composer global require woocommerce/woocommerce-sniffs
Or Download the package and move it to the same folder of WordPress standards.
Set path of WordPress and WooCommerce Standards in PHP code sniffer
Add Folder path to the PHP_CodeSniffer configuration:
phpcs --config-set installed_paths path to WordPress and WooCommerce coding standards
phpcs --config-set installed_paths D:\xampp\wpcs
Run the command to check whether everything is configured successfully.
WordPress Standards Command for Command Prompt
phpcs --standard=wordpress D:\xampp\htdocs\wordpress\wp-content\plugins\woocommerce
WordPress Standards Auto Fix Command for Command Prompt
phpcbf --standard=wordpress D:\xampp\htdocs\wordpress\wp-content\plugins\woocommerce
Raja Aman Ullah is a highly skilled WordPress and WooCommerce plugin developer working as a lead plugin developer. He developed numerous famous extensions including b2b, request a quote, ultimate membership, custom fields, and many others for WooCommerce that are trending on Extension Store. His products on WooCommerce have more than 100,000 active subscriptions and happy clients.