WordPress / WordPress-Coding-Standards

PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
MIT License
2.55k stars 482 forks source link

Extra: sniff to check for usage of reserved words #871

Open jrfnl opened 7 years ago

jrfnl commented 7 years ago

WordPress has a list of words which are reserved for use as query vars. See: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp.php#L18

If we can gather a list of functions in which these should not be used, I can imagine we could create a sniff to check against this.

One typical function in which they should not be used is register_taxonomy(), but I imagine there may be more functions in which these would lead to difficult to debug problems (with register_taxonomy() you end up with an unexplained 404). Ref: https://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms

johnbillion commented 7 years ago

The same applies to post type names.

It also applies to general form fields. An example is a contact form where the field name for the visitor's name is name, which causes a conflict with the name query var in WordPress. No idea how you could approach sniffing that in a reliable manner.

jrfnl commented 1 year ago

Any sniff like this would greatly benefit from tooling to create the initial lists and allow for updating the lists with ease. See #1803