-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Implement sniff] Everything in the global namespace should be prefixed #129
Comments
The requirement reads |
@carolinan Excellent! Thanks. In that case, only the sniff needs to be added to the ruleset. |
Just want to note that I'm a bit iffy on meta necessarily being prefixed. In general, I usually say that it must be. However, there are some common keys that theme authors use from theme to theme. Using a common key gives you a bit more portability in an area where WP sucks at portability. Prefixing should be done here if it's something specific to this one particular theme. For example, suppose we allowed themes to register post types, I wouldn't want them prefixing their "testimonial" post type as I'd treat metadata the same. If it's specific to the theme, prefix. If it's something that other themes could use, stick with a un-prefixed, common naming system. |
@justintadlock The sniff (currently) does not check meta keys or post types. It only checks PHP globals (variables, functions, classes, constants) and hook names for WP. |
Rule type:
Error
Rule:
I'm not sure whether anything about this is currently in the handbook, but it is best practice to prefix all function/class/constant/variable/hook names used in the global namespace to prevent naming collisions with plugins and potentially the parent-theme.
Decision needed:
Check whether this is currently covered the handbook and if it isn't, a decision is needed on whether it should be added.
Advice: Add to the handbook.
Notes for implementation:
WordPress.NamingConventions.PrefixAllGlobals
- for this in WPCS upstream which will be in WPCS 0.12.0. The sniff does require a set of prefixes to be passed otherwise it will not have anything to check against.See: ✨ New sniff to verify that everything in the global namespace is prefixed. WordPress/WordPress-Coding-Standards#907
To do:
WordPress.NamingConventions.PrefixAllGlobals
sniff to the ruleset after the current version of WPCS has been merged back into TRTCS.The text was updated successfully, but these errors were encountered: