WordPress-Coding-Standards
WordPress-Coding-Standards copied to clipboard
PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
> When formatting SQL statements you may break it into several lines and indent if it is sufficiently complex to warrant it. Most statements work well as one line though....
According to [WordPress documentation](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/php/#since-section-changelogs), every function, hook, class, and method should have a corresponding `@since` version associated with it. How I can get that sniff?
## Bug Description When I replace ```php _doing_it_wrong( __FUNCTION__, 'My message', '1.0.0' ); ``` with ```php const MY_MESSAGE = 'My message'; _doing_it_wrong( __FUNCTION__, MY_MESSAGE, '1.0.0' ); ``` I get a...
### Current situation The WordPress Coding Standards currently enforce file names to: 1. Be all lowercase; 2. Use hyphens instead of underscores as word separators; 3. Have a `class-` prefix...
Worth adding a directory of exports from IDEs, with instructions on how to import them, so that the code formatted by IDEs at least start off as close to WP...
I'd like to consider what sniffs could be written that address programatically testable accessibility concerns. The first is to check for the use of the `title` attribute, and flag it...
## Bug Description `ClassName::class` is safe for use and doesn't need escaping. ## Minimal Code Snippet ```php function foo() { _deprecated_function( __METHOD__, 'x.x.x', ClassName::class ); } ``` ## Error Code...
PHPCS 3.1, WPCS 0.13.0, PHP 5.6.30 A backslash used to indicate the global namespace prevents customAutoEscapedFunctions from being recognized. I have a ruleset like this: ``` ``` And some code...
## Describe the solution you'd like Sometimes difficult to determine logic bugs occur when `switch_to_blog()` is called without a subsequent restoration. It would be worth flagging to the user that...
## Bug Description When all that's done with a superglobal value is to _unset_ it, no nonceverification should be necessary. Currently, the sniff will throw a warning for this: ```...