WPTT / WPThemeReview

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

Ensure theme template headers in style.css has proper line breaks/spacing in it #191

Open rebeccahum opened 5 years ago

rebeccahum commented 5 years ago
Basic Info -
Rule type: Error
Sniff Category: CoreFunctionality (I think?)

Having bad spacing/incorrect line breaks in the theme style.css "Template:" header will prevent a child theme from working properly.

Rule:

Couldn't find anything in the handbook but I found this: https://codex.wordpress.org/Theme_Development#Theme_Stylesheet

Theme check file covering this rule:

https://github.com/WordPress/theme-check/blob/da79a6f17b126b52998474cd234e4210de5a2d6f/checks/style_needed.php https://github.com/WordPress/theme-check/blob/da79a6f17b126b52998474cd234e4210de5a2d6f/checks/style_suggested.php Closest I could find ^^

[For new sniffs only] Code Samples:

// Code sample(s) which should pass.
/*
Template: test-dir/test-template
Version: 1.0
*/
// Code sample(s) which should be flagged by the sniff.
/*
Template: test-dir/test-template Version: 1.0
*/

When get_file_data() will try to parse the above, it will attempt to process the template as test-dir/test-template Version: 1.0 instead of test-dir/test-template

To do: