phpcs + WP coding standards
phpcs for VS Code
Note It might be easier to just go for the composer instalatio documented here instead of following the steps below
- install phpcs, see here
- install phpcs VS Code Plugin
- switch to ROOT (
cd), test phpcs:.composer/vendor/bin/phpcs -h - open VS Code user settings (
cmd+;) and modify thephpcs.executablePath` setting to {root}/.composer/vendor/bin/phpcs -h, {root} beingcd; pwd - clone WordPress Standard reps to a desired location (see Step #2 of the Standalone installation on the WordPress Coding standards GitHub page )
git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs - Add the path of the new repository to the phpcs configs:
{root}/.composer/vendor/bin/phpcs --config-set installed_paths /path/to/wpcs
{root}/.composer/vendor/bin/phpcs -ishould now list WordPress - VS Code Settings: add
"phpcs.standard": "WordPress".
VS Code settings
to meet the standards
Spaces to tabs
Change indent setting in the bottom right of the Editor, see here
WP x Intelephense
To support WordPress functions for Intelephense, add element wordpress to Intelephense stubs in the VS Code Intelephense settigns, as explained here (=> Adding a missing function definition).