theme-sniffer
theme-sniffer copied to clipboard
Prefix error for $GLOBALS['content_width']
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.
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
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.
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 😕
$content_width should be white listed.
$content_width
should get a setter method :smile:
Can you open an issue, or comment on a new one in the WPCS repo? 🙂
Related Trac ticket: https://core.trac.wordpress.org/ticket/21256