WordPress-Coding-Standards | PHP_CodeSniffer rules to enforce WordPress | Content Management System library
kandi X-RAY | WordPress-Coding-Standards Summary
kandi X-RAY | WordPress-Coding-Standards Summary
This project is a collection of PHP_CodeSniffer rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official WordPress Coding Standards.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Process multi - line array .
- Process a token .
- Checks if a variable is valid .
- Process comments .
- Process a global variable declaration .
- Check for missing arguments .
- Process variable variable .
- Process a variable .
- Process an arbitrary constant declaration .
- Process method declaration .
WordPress-Coding-Standards Key Features
WordPress-Coding-Standards Examples and Code Snippets
Community Discussions
Trending Discussions on WordPress-Coding-Standards
QUESTION
In VSCode, in settings.json for one of my extensions is a line
"extends": "C:/Users/snarl/.vscode/extensions/stylelint-config-wordpress",
But that line is dimmed compared to the rest of the text in the file, as if disabled, or path not found (screenshot). Is that indicating some kind of error I need to resolve? That folder does indeed exist at that location (screenshot).
Motivation For My Question
I ask because this is a line of code I manually added to settings.json, as part of installation instructions for a particular extension. I'm currently using the stylelint extension to help notify me of errors while I type. I am now trying to install a separate extension--stylelint-config-wordpress--which is a set of rules to be used with stylelint. But that new ruleset doesn't seem to be working properly. So I am now trying to troubleshoot why the new rules are not working properly. The settings.json file I edited is part of the stylelint-config-wordpress extension.
Of Note
I am running Windows 10.
When I initially installed stylelint, I installed it globally. I can confirm it was installed properly and linting errors in my code, as expected.
In the GitHub repo for stylelint-config-wordpress, there is one issue related to this (see here). I posted there and received some initial replies. But nothing worked, and I've not heard back since.
ANSWER
Answered 2019-Oct-06 at 09:53After opening an issue in the relevant GitHub repo, I was able to understand the answer to my question.
Short Answer: The code I was adding was incorrect. I was adding:
QUESTION
How can we customize Wordpress coding standards on Windows and use them with VSCode? I am trying to do this globally so I don't have to do it for every project (I don't think currently that this is a bad idea?) but I guess the same thing can be applied to local project, only paths should be changed.
First, I have installed them in C:\wamp64\www\_standards\wpcs
and I have set correct path using:
ANSWER
Answered 2018-Aug-22 at 19:16A couple of pointers:
- The
phpcs.xml
file (can also bephpcs.xml.dist
and other similar variations that have a preferred order) (notruleset.xml
), should be in the root of your project code, not in the directory you installed WPCS. The VS Code config would then be the path (absolute or relative) to that
phpcs.xml
file:"phpcs.standard": "/path/to/project/phpcs.xml"
or
"phpcs.standard": "./phpcs.xml"
You'll still need to ensure that the phpcs
executable you're referring to has got the WordPress
standards registered.
Reference: https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs
QUESTION
I have installed git in my pc(windows 10) and set environment variable path also. But when I try to download WPCS using git git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
getting an error
'git' is not recognized as an internal or external command,
operable program or batch file.
Git directory path is C:\Program Files\Git
and I have set the environment variable as C:\Program Files\Git\cmd
. Can anyone suggest me what might be the problem here? I have tried this commands also
ANSWER
Answered 2018-Nov-08 at 08:23If you already installed the git-scm.com version, you can use my second favourite on top of it, Git for Windows (https://gitforwindows.org)
It will support your Git installation out of the box without messing around with environment variables and it uses Git Bash, which emulates a common Linux command line, so most git commands you will find around on the web will work for you
If you do this, you shouldn't try to run git directly from the Windows command line, but from the Git Bash command line, which will be accessible everywhere in Windows from the right click menu
QUESTION
Is there a way to install PHPCodeSniffer and WordPress Coding Standards for PHP_CodeSniffer per project via Composer? I've installed both as dev dependencies and set the installed path to WordPress Coding Standards in CodeSniffer.conf. Unfortunately phpcs can not resolve to the config file when I run the command in the terminal because it is looking in "vendor" folder for "vendor/squizlabs/php_codesniffer/CodeSniffer.conf"
Here is my project setup:
composer.json
...ANSWER
Answered 2018-Feb-27 at 19:32First, you don't need to require PHP CodeSniffer explicitly, because wp-coding-standards/wpcs
pulls it automatically.
composer.json
QUESTION
I'm trying to add WordPress Coding Standards to ESLint in Atom. Unfortunately there are no package I could add via Atom's installer. I've found one (I think) suitable package here but whenever I try to install it using Windows CMD or XAMPP shell I get "npm is ot recognized as internal or external command". I installed ESLint for Atom, so I've got the prerequisite met. Is it possible to add it to Atom on Windows at all?
Cheers, best regards.
...ANSWER
Answered 2017-Aug-19 at 18:10Ok,
I digged into the topic and pparently I didn't have Node.js installed so I couldn't manage any npm packages. After installing Node.js I was able to install WordPress-Coding-Standards. Unfortunately I installed the wrong package at first, which was eslint-plugin-wordpress. After trying to set it up eslint started giving me plenty of errors. Then I found out (with a little help from guys on Github) that there are other WordPress Coding Standards plugin for eslint - eslint-config-wordpress which I installed as well. Now everything works like a charm. It's good to learn something new everyday.
Thanks, Dan.
QUESTION
I’ve installed the WordPress Coding Standards for phpcs
. Running phpcs -i
confirms this:
ANSWER
Answered 2017-Jul-21 at 20:58Greg Sherwood’s comment above pointed me in the right direction. The two commands were symlinks pointing at different installs. I figured this out by running
which phpcs
and which phpcbf
and running readlink
(to see if they were symlinks) on the results.
which phpcs
gave me /usr/local/bin/phpcs
and readlink /usr/local/bin/phpcs
gave me the path to the actual executable.
Once I figured out that phpcbf
was a symlink to an executable in a different install I deleted it and replaced it with a symlink to phpcbf
in the same install as phpcs
, which solved my issue.
QUESTION
I'm using the WordPress-Core rules for a project I just started in PhpStorm (involves developing a custom plugin and theme), and I find it strange that most of the default php files in a clean WordPress install (for example, wp-config.php, wp-mail.php, etc.) don't pass the phpcs test when any of the WordPress rules in that repo are used.
Most of the times I see the open and close bracket warning:
...ANSWER
Answered 2017-Jun-25 at 07:27Historically, WordPress has avoided cleaning up the Core code style, for several reasons:
- The tools for checking coding standards were not particularly reliable. This has changed in recent years, with the WordPress Coding Standards (WPCS) project maturing, and many of the little edge cases being fixed in PHPCS.
- With no reliable automated tools, this would be a manual job, requiring many commits. This causes unnecessary code churn, and makes it harder to look through revision logs.
- It just hasn't been a high priority. ~4% of WordPress' PHP violates the coding standard, so most folks just don't encounter it.
With the tools maturing, that position changed recently, there's now an in-progress effort to get PHPCS and WPCS working with WordPress Core. With appropriate automated testing, WordPress will continue to match it's own coding standards in the future.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install WordPress-Coding-Standards
PHP requires the Visual C runtime (CRT). The Microsoft Visual C++ Redistributable for Visual Studio 2019 is suitable for all these PHP versions, see visualstudio.microsoft.com. You MUST download the x86 CRT for PHP x86 builds and the x64 CRT for PHP x64 builds. The CRT installer supports the /quiet and /norestart command-line switches, so you can also script it.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page