theme-sniffer icon indicating copy to clipboard operation
theme-sniffer copied to clipboard

Prefix error for $GLOBALS['content_width']

Open surimohnot opened this issue 6 years ago • 7 comments

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.

surimohnot avatar Feb 26 '19 13:02 surimohnot

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

dingo-d avatar Feb 26 '19 14:02 dingo-d

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.

timelsass avatar Mar 02 '19 03:03 timelsass

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 😕

dingo-d avatar Mar 02 '19 16:03 dingo-d

$content_width should be white listed.

joyously avatar Mar 02 '19 17:03 joyously

$content_width should get a setter method :smile:

timelsass avatar Mar 04 '19 10:03 timelsass

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

dingo-d avatar Mar 04 '19 10:03 dingo-d

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

justintadlock avatar Mar 07 '19 16:03 justintadlock