Skip to content
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

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

Open
2 tasks done
khacoder opened this issue Jul 13, 2016 · 9 comments
Open
2 tasks done

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

khacoder opened this issue Jul 13, 2016 · 9 comments

Comments

@khacoder
Copy link
Contributor

khacoder commented Jul 13, 2016

[New Sniff]

Rule:

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

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

To do:

  • Create Unit Tests
  • Create Unit Sniff
@khacoder
Copy link
Contributor Author

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

@jrfnl jrfnl changed the title Chec that capabilities are used not roles [New Sniff] Check that capabilities are used not roles Jul 13, 2016
@carolinan
Copy link

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

@jrfnl
Copy link
Contributor

jrfnl commented Jul 13, 2016

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

This should be for all usages

@jrfnl
Copy link
Contributor

jrfnl commented Jul 13, 2016

Theme check file (partially) covering this rule:

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

@jrfnl
Copy link
Contributor

jrfnl commented Jul 13, 2016

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
Copy link
Contributor Author

the sniff I have created is for all pages.

@jrfnl
Copy link
Contributor

jrfnl commented Mar 21, 2017

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
Copy link
Member

Created a PR upstream for this WordPress/WordPress-Coding-Standards#1364

@dingo-d
Copy link
Member

dingo-d commented May 18, 2019

@grappler Any news on the upstream issue for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants