WPTT / theme-sniffer

Theme Sniffer plugin using sniffs.
MIT License
270 stars 3 forks source link

Prefix error for $GLOBALS['content_width'] #103

Open surimohnot opened 5 years ago

surimohnot commented 5 years ago

Plugin gives error for not prefixing $GLOBALS['content_width'] (mostly in any theme's functions.php file). It should not be prefixed.

This error is only visible if you have added theme prefix/s.

dingo-d commented 5 years ago

This is triggered because of the $GLOBALS variable. And could be related to: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1437

Can you open an issue on the https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/ repo about this issue with the code example?

Thanks

timelsass commented 5 years ago

As a note on this topic - wooCommerce uses a lot of globals in their templates, and themes that copy over templates with their own logic do get a lot of errors reported even though there might not be a way to work around that for the author.

dingo-d commented 5 years ago

One option would be to ignore woocommerce folder from the theme, but I wouldn't do that (those files shouldn't have errors or things like iframes for instance).

The globals thing is known in the WPCS and I think there are tons of issues opened about it 😕

joyously commented 5 years ago

$content_width should be white listed.

timelsass commented 5 years ago

$content_width should get a setter method :smile:

dingo-d commented 5 years ago

Can you open an issue, or comment on a new one in the WPCS repo? 🙂

justintadlock commented 5 years ago

Related Trac ticket: https://core.trac.wordpress.org/ticket/21256