WordPress-Coding-Standards icon indicating copy to clipboard operation
WordPress-Coding-Standards copied to clipboard

Extra: sniff to check for usage of reserved words

Open jrfnl opened this issue 8 years ago • 2 comments

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

jrfnl avatar Mar 11 '17 23:03 jrfnl

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.

johnbillion avatar May 27 '17 13:05 johnbillion

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

jrfnl avatar Dec 03 '22 15:12 jrfnl