From 54ad32a5980d01275d2c63b4fa4ba8ce6a8b726f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 27 Feb 2018 14:14:41 +0100 Subject: [PATCH] :bookmark: CS: whitelist two global variable overrides The one in `functions.php` can be considered a bug in WPCS and has been reported as such. Once that issue is fixed, the whitelisting can be removed. The one in `inc/wpcom.php` will need to remain as WPCS does not keep track of globals introduced by wpcom. --- functions.php | 3 +++ inc/wpcom.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/functions.php b/functions.php index aea2ddad..b7134e76 100644 --- a/functions.php +++ b/functions.php @@ -91,6 +91,9 @@ add_action( 'after_setup_theme', '_s_setup' ); * @global int $content_width */ function _s_content_width() { + // This variable is intended to be overruled from themes. + // Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}. + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $GLOBALS['content_width'] = apply_filters( '_s_content_width', 640 ); } add_action( 'after_setup_theme', '_s_content_width', 0 ); diff --git a/inc/wpcom.php b/inc/wpcom.php index 9439440b..9064c5e5 100644 --- a/inc/wpcom.php +++ b/inc/wpcom.php @@ -17,6 +17,8 @@ function _s_wpcom_setup() { // Set theme colors for third party services. if ( ! isset( $themecolors ) ) { + // Whitelist wpcom specific variable intended to be overruled. + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound $themecolors = array( 'bg' => '', 'border' => '',