-
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
[New sniff] Check for disallowed theme related WP constants #23
Comments
Here's my snippet: Theme needs to properly load files, but also to be consistent as well. There are several functions available for getting the path:
http://justintadlock.com/archives/2010/11/17/how-to-load-files-within-wordpress-themes |
Is the current list as can be found in https://github.com/Otto42/theme-check/pull/162/files still complete enough as a starting point ? |
Also: looking at the PR - we may want to split this into
I think that would make it easier to maintain and extend. [Edit] Possibly even more groups should be added. I'd prefer one issue for each sniff to be created, so would like to suggest splitting this sniff in three or more issues. |
Also looking at the rule in the handbook, I'd like to add an action item to expand and clarify the rule as it currently isn't explicit enough and doesn't cover all that is covered by the Theme Check PR IMHO:
|
I'd say no to "discouraged" (not sure who decided this was discouraged) PHP constants like |
@justintadlock I guess this was the inspiration: #18 |
The reason to not support the constants is that they have been deprecated. I think the list is good and we can always extend it if necessary. I am looking to find a way we can best document these requirements. |
In that case - let me adjust the PR and name the sniff DeprecatedWPConstants instead of Forbidden. [Edit] Done. |
Covers the sniff + unit test for issue #23. This PR covers the currently known list as can be found in: https://github.com/Otto42/theme-check/pull/162/files
Covers the sniff + unit test for issue #23. This PR covers the currently known list as can be found in: https://github.com/Otto42/theme-check/pull/162/files
Covers the sniff + unit test for issue #23. This PR covers the currently known list as can be found in: https://github.com/Otto42/theme-check/pull/162/files
This sniff is based on a sniff previously pulled to the TRT fork of WPCS as `Theme.DeprecatedConstants`. Related issue: WPTT/WPThemeReview/issues/23 Original PR: WPTT/WPThemeReview/pull/30 Covers the list of constants found in: WordPress/theme-check/pull/162 Differences between that sniff and this one: * This sniff is a **_lot_** more comprehensive in preventing false positives. The original sniff was one of the first ones I wrote and it's kind of sweet to look back at that code which I wrote over a year ago and see how much I've learned about writing sniffs in the mean time. * The original sniff was called `Theme.DeprecatedConstants`, but in reality, most of these constants aren't officially deprecated, though their usage is discouraged and the constants being addressed are not 100% related to themes either. With that in mind, I've renamed the sniff to `WP.DiscouragedConstants` and changed the error level from Error to Warning. Also see: https://core.trac.wordpress.org/ticket/18298 * This version of the sniff also addresses the concerns raised in WPTT/WPThemeReview/issues/110 about themes `define`-ing any of these constants and leverages the `AbstractFunctionParameterSniff` to do so. Includes quite extensive unit tests. More are definitely welcome, especially to prevent false positives. I've added the sniff to the `WordPress-Extra` ruleset. Fixes 97 Will also fix WPTT/WPThemeReview/issues/110 once the original sniff gets removed from the TRT fork and this sniff is added to the TRT ruleset instead.
This sniff is based on a sniff previously pulled to the TRT fork of WPCS as `Theme.DeprecatedConstants`. Related issue: WPTT/WPThemeReview/issues/23 Original PR: WPTT/WPThemeReview/pull/30 Covers the list of constants found in: WordPress/theme-check/pull/162 Differences between that sniff and this one: * This sniff is a **_lot_** more comprehensive in preventing false positives. The original sniff was one of the first ones I wrote and it's kind of sweet to look back at that code which I wrote over a year ago and see how much I've learned about writing sniffs in the mean time. * The original sniff was called `Theme.DeprecatedConstants`, but in reality, most of these constants aren't officially deprecated, though their usage is discouraged and the constants being addressed are not 100% related to themes either. With that in mind, I've renamed the sniff to `WP.DiscouragedConstants` and changed the error level from Error to Warning. Also see: https://core.trac.wordpress.org/ticket/18298 * This version of the sniff also addresses the concerns raised in WPTT/WPThemeReview/issues/110 about themes `define`-ing any of these constants and leverages the `AbstractFunctionParameterSniff` to do so. Includes quite extensive unit tests. More are definitely welcome, especially to prevent false positives. I've added the sniff to the `WordPress-Extra` ruleset. Based on https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-theme-constants and https://core.trac.wordpress.org/ticket/18298#comment:2, I've also added the sniff to the `WordPress-VIP` ruleset. /cc @sboisvert @david-binda @ntwb Fixes 97 Will also fix WPTT/WPThemeReview/issues/110 once the original sniff gets removed from the TRT fork and this sniff is added to the TRT ruleset instead.
Rule:
ERROR : Check for usage of deprecated WP constants relating to themes
and discouraged PHP constants e.g. We could probably extend an existing sniff of similar ilk for this.__FILE__
Ref: https://make.wordpress.org/themes/handbook/review/required/#core-functionality-and-features
Theme check file covering this rule:
https://github.com/Otto42/theme-check/pull/162/files
Decision needed:
Confirmation is needed that the current list is correct. If not, input is needed about which other theme related WP constants should (not) be covered by this sniff.
To do:
The text was updated successfully, but these errors were encountered: