WPTT / WPThemeReview

PHP_CodeSniffer rules (sniffs) to enforce WordPress theme review coding conventions
MIT License
209 stars 37 forks source link

[New sniff] No hard-coded menu names in nav_menu functions #93

Open jrfnl opened 7 years ago

jrfnl commented 7 years ago

Rule type:

Error / Warning

Rule:

nav-menu check

In the (register|wp)_nav_menu() function, the theme should only use a variable for the menu name. No hard-coded menu names allowed.

The rule should be clarified and added to the handbook before any action is taken on this issue.

Ref: https://make.wordpress.org/themes/handbook/review/required/theme-check-plugin/#info

Theme check file covering this rule:

Unknown Loosely related: https://github.com/WordPress/theme-check/issues/142

Decision needed:

To do:

grappler commented 7 years ago

This falls under

Avoid hard coding to modify content. Instead, use function parameters, filters and action hooks where appropriate.

This should be an error.

By using a hardcoded a hard coded menu name it would require the menu to have the exactly same name which does not make sense for a publically released theme.

joyously commented 7 years ago

I think you are mistaken. A theme names its menu locations, not the user. They should not have to be in variables. The menu location is not "content" as mentioned in that rule you quoted.

grappler commented 7 years ago

A theme names its menu locations, not the user.

You are right but we are not talking about the location but the menu name.

These are the two parameter which is causing the confusing. We want to restrict the first not the second.

I hope this makes sense.