WPTT / WPThemeReview

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

[New Sniff] Check that style.css contain a text-domain entry. #34

Open jrfnl opened 8 years ago

jrfnl commented 8 years ago

Rule type:

Error

Rule:

From what I can see, there are actually 5 distinct i18n related rules which may need sniffs - this issue covers the second item on the list.

  1. All theme text strings are to be translatable. (#33)
  2. Include a text domain in style.css
  3. Use a single unique theme slug – as the theme slug appears in style.css. If it uses a framework then no more than 2 unique slugs. (#35)
  4. Can use any language for text, but only use the same one for all text. (#33)
  5. Correct usage of the WP i18n functions. (#31)

Refs: https://make.wordpress.org/themes/handbook/review/required/#language https://make.wordpress.org/themes/handbook/review/required/theme-check-plugin/#additional-checks

The second item should be quite doable to implement as a sniff which checks the CSS files until it finds the one called style.css and only then searches for the required text string.

Theme check file covering this rule:

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

To do:

khacoder commented 8 years ago

The text domain in style.css needs to be the theme slug as well. It would be good if this could be checked at the same time I think. Though getting the theme slug might prove tricky.

jrfnl commented 8 years ago

The text domain in style.css needs to be the theme slug as well. It would be good if this could be checked at the same time I think. Though getting the theme slug might prove tricky.

That's in point 3 / #35, but yes these two items might possible be combined implementation wise.

khacoder commented 8 years ago

I have included action item 2 above in Issue #50

dingo-d commented 5 years ago

Is this something we want to work on, any volunteers? Or should I leave this for the Theme Sniffer?