WPTT / WPThemeReview

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

[New Sniff] Check that capabilities are used not roles #27

Open khacoder opened 8 years ago

khacoder commented 8 years ago

[New Sniff]

Rule:

ERROR : Check that capabilities are used not roles. Functions to check: get_role(), current_user_can(), current_user_can_for_blog(), usercan(), add..._page()

Ref: https://make.wordpress.org/themes/handbook/review/required/#core-functionality-and-features

To do:

khacoder commented 8 years ago

I have essentially got this sniff done, but need a little more time for testing.

carolinan commented 8 years ago

Is this only regarding adding menu pages, or other usages too?

jrfnl commented 8 years ago

Is this only regarding adding menu pages, or other usages too?

This should be for all usages

jrfnl commented 8 years ago

Theme check file (partially) covering this rule:

https://github.com/Otto42/theme-check/blob/master/checks/admin_menu.php

jrfnl commented 8 years ago

Also in the handbook (related but not the same):

Use edit_theme_options capability for determining user permission to edit options, rather than rely on a role (e.g. “administrator”), or a different capability (e.g. “edit_themes”, “manage_options”).

https://make.wordpress.org/themes/handbook/review/required/#options-and-settings

khacoder commented 8 years ago

the sniff I have created is for all pages.

jrfnl commented 7 years ago

In the new Theme handbook, the rule has been moved to another section: https://make.wordpress.org/themes/handbook/review/required/#options-and-settings

grappler commented 6 years ago

Created a PR upstream for this https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1364

dingo-d commented 5 years ago

@grappler Any news on the upstream issue for this?