reinstate phpcs php linting (#1463)

* update squizlabs/php_codesniffer and WP coding standards to latest

* revamp phpcs sniffer rulesets:
- update to php-compatibility (wimg is defunct)
- add version for woocommerce-sniffs

* streamline phpcs config (get it working at all):
- update min WP version to 5.3
- remove references to rules we don't have installed
  - WordPress.VIP
  - WordPress.XSS

* fix 2x phpcs errors (automatically via phpcbf)

* update phps ignore unescaped output comment to current format

* add npm scripts for php linter and linter autofixer

* auto-fix PHP linter errors using phpcbf :

Before phpcbf:

[x] PEAR      Functions           Function call signature multiple arguments          127
[x] Generic   White space         Disallow space indent spaces used                   10
[ ] WordPres  WP                  Enqueued resource parameters missing version        6
[ ] PHPCompa  Language construct  New language constructs t_ns_separator found        4
[ ] WordPres  Security            Escape output output not escaped                    4
[ ] PHPCompa  Parameter values    New HTMLEntities encoding default not set           2
[ ] WordPres  Date time           Restricted functions date_date                      2
[x] Generic   Files               End file newline not found                          1
[x] PEAR      Functions           Function call signature close bracket line          1
[x] PEAR      Functions           Function call signature content after open bracket  1
[x] Squiz     White space         Superfluous whitespace end line                     1
[x] WordPres  Arrays              Comma after array item no comma                     1

phpcbf fixed all [x] violations, all whitespace/formatting

After phpcbf:

WordPres  WP                  Enqueued resource parameters missing version      6
PHPCompa  Language construct  New language constructs t_ns_separator found      4
WordPres  Security            Escape output output not escaped                  4
PHPCompa  Parameter values    New HTMLEntities encoding default not set         2
WordPres  Date time           Restricted functions date_date                    2

Note - this commit does not include auto-fixed files with other
violations. These will follow in separate commit (after fixing!)

* fix phpcs violations:
- numerous formatting issues fixed automatically
- manually fix missing version param in calls to wp_enqueue_style

* fix phpcs violations:
- numerous formatting issues fixed automatically
- fix missing deps param in call to wp_enqueue_style

* update phpcs test php version to match min requirement (5.6)

* fix phpcs violations including some missing escaping:
- numerous formatting issues fixed automatically
- prefer gmdate() over potentially ambiguous date()
- escape output (a real issue!) of comment dates

* fix violations (all automated formatting fixes)

* reinstate WordPress rule/standard in phpcs.xml (minimise PR changes)

* exclude build (pre-zip) ./storefront & tighten excludes for dep folders

* bulk-update Security.EscapeOutput.OutputNotEscaped ignore comment:
- the previous comment format is no longer supported
- bulk replacing these to reduce phpcs warning overhead
This commit is contained in:
Rua Haszard 2020-09-17 11:28:22 +12:00 committed by Seghir Nadir
parent 5189064d7a
commit 7bd2171866
No known key found for this signature in database
GPG key ID: 65750D713E9C2DC0
20 changed files with 595 additions and 344 deletions

View file

@ -39,7 +39,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
*/
public function get_storefront_default_setting_values() {
return apply_filters(
'storefront_setting_default_values', $args = array(
'storefront_setting_default_values',
$args = array(
'storefront_heading_color' => '#333333',
'storefront_text_color' => '#6d6d6d',
'storefront_accent_color' => '#96588a',
@ -132,21 +133,24 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
$wp_customize->selective_refresh->add_partial(
'custom_logo', array(
'custom_logo',
array(
'selector' => '.site-branding',
'render_callback' => array( $this, 'get_site_logo' ),
)
);
$wp_customize->selective_refresh->add_partial(
'blogname', array(
'blogname',
array(
'selector' => '.site-title.beta a',
'render_callback' => array( $this, 'get_site_name' ),
)
);
$wp_customize->selective_refresh->add_partial(
'blogdescription', array(
'blogdescription',
array(
'selector' => '.site-description',
'render_callback' => array( $this, 'get_site_description' ),
)
@ -167,7 +171,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Add the typography section
*/
$wp_customize->add_section(
'storefront_typography', array(
'storefront_typography',
array(
'title' => __( 'Typography', 'storefront' ),
'priority' => 45,
)
@ -177,7 +182,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Heading color
*/
$wp_customize->add_setting(
'storefront_heading_color', array(
'storefront_heading_color',
array(
'default' => apply_filters( 'storefront_default_heading_color', '#484c51' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -185,7 +191,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_heading_color', array(
$wp_customize,
'storefront_heading_color',
array(
'label' => __( 'Heading color', 'storefront' ),
'section' => 'storefront_typography',
'settings' => 'storefront_heading_color',
@ -198,7 +206,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Text Color
*/
$wp_customize->add_setting(
'storefront_text_color', array(
'storefront_text_color',
array(
'default' => apply_filters( 'storefront_default_text_color', '#43454b' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -206,7 +215,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_text_color', array(
$wp_customize,
'storefront_text_color',
array(
'label' => __( 'Text color', 'storefront' ),
'section' => 'storefront_typography',
'settings' => 'storefront_text_color',
@ -219,7 +230,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Accent Color
*/
$wp_customize->add_setting(
'storefront_accent_color', array(
'storefront_accent_color',
array(
'default' => apply_filters( 'storefront_default_accent_color', '#96588a' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -227,7 +239,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_accent_color', array(
$wp_customize,
'storefront_accent_color',
array(
'label' => __( 'Link / accent color', 'storefront' ),
'section' => 'storefront_typography',
'settings' => 'storefront_accent_color',
@ -240,7 +254,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Hero Heading Color
*/
$wp_customize->add_setting(
'storefront_hero_heading_color', array(
'storefront_hero_heading_color',
array(
'default' => apply_filters( 'storefront_default_hero_heading_color', '#000000' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -248,11 +263,13 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_hero_heading_color', array(
'label' => __( 'Hero heading color', 'storefront' ),
'section' => 'storefront_typography',
'settings' => 'storefront_hero_heading_color',
'priority' => 50,
$wp_customize,
'storefront_hero_heading_color',
array(
'label' => __( 'Hero heading color', 'storefront' ),
'section' => 'storefront_typography',
'settings' => 'storefront_hero_heading_color',
'priority' => 50,
)
)
);
@ -261,7 +278,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Hero Text Color
*/
$wp_customize->add_setting(
'storefront_hero_text_color', array(
'storefront_hero_text_color',
array(
'default' => apply_filters( 'storefront_default_hero_text_color', '#000000' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -269,18 +287,22 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_hero_text_color', array(
'label' => __( 'Hero text color', 'storefront' ),
'section' => 'storefront_typography',
'settings' => 'storefront_hero_text_color',
'priority' => 60,
$wp_customize,
'storefront_hero_text_color',
array(
'label' => __( 'Hero text color', 'storefront' ),
'section' => 'storefront_typography',
'settings' => 'storefront_hero_text_color',
'priority' => 60,
)
)
);
$wp_customize->add_control(
new Arbitrary_Storefront_Control(
$wp_customize, 'storefront_header_image_heading', array(
$wp_customize,
'storefront_header_image_heading',
array(
'section' => 'header_image',
'type' => 'heading',
'label' => __( 'Header background image', 'storefront' ),
@ -293,7 +315,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Header Background
*/
$wp_customize->add_setting(
'storefront_header_background_color', array(
'storefront_header_background_color',
array(
'default' => apply_filters( 'storefront_default_header_background_color', '#2c2d33' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -301,7 +324,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_header_background_color', array(
$wp_customize,
'storefront_header_background_color',
array(
'label' => __( 'Background color', 'storefront' ),
'section' => 'header_image',
'settings' => 'storefront_header_background_color',
@ -314,7 +339,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Header text color
*/
$wp_customize->add_setting(
'storefront_header_text_color', array(
'storefront_header_text_color',
array(
'default' => apply_filters( 'storefront_default_header_text_color', '#9aa0a7' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -322,7 +348,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_header_text_color', array(
$wp_customize,
'storefront_header_text_color',
array(
'label' => __( 'Text color', 'storefront' ),
'section' => 'header_image',
'settings' => 'storefront_header_text_color',
@ -335,7 +363,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Header link color
*/
$wp_customize->add_setting(
'storefront_header_link_color', array(
'storefront_header_link_color',
array(
'default' => apply_filters( 'storefront_default_header_link_color', '#d5d9db' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -343,7 +372,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_header_link_color', array(
$wp_customize,
'storefront_header_link_color',
array(
'label' => __( 'Link color', 'storefront' ),
'section' => 'header_image',
'settings' => 'storefront_header_link_color',
@ -356,7 +387,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Footer section
*/
$wp_customize->add_section(
'storefront_footer', array(
'storefront_footer',
array(
'title' => __( 'Footer', 'storefront' ),
'priority' => 28,
'description' => __( 'Customize the look & feel of your website footer.', 'storefront' ),
@ -367,7 +399,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Footer Background
*/
$wp_customize->add_setting(
'storefront_footer_background_color', array(
'storefront_footer_background_color',
array(
'default' => apply_filters( 'storefront_default_footer_background_color', '#f0f0f0' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -375,7 +408,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_footer_background_color', array(
$wp_customize,
'storefront_footer_background_color',
array(
'label' => __( 'Background color', 'storefront' ),
'section' => 'storefront_footer',
'settings' => 'storefront_footer_background_color',
@ -388,7 +423,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Footer heading color
*/
$wp_customize->add_setting(
'storefront_footer_heading_color', array(
'storefront_footer_heading_color',
array(
'default' => apply_filters( 'storefront_default_footer_heading_color', '#494c50' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -396,7 +432,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_footer_heading_color', array(
$wp_customize,
'storefront_footer_heading_color',
array(
'label' => __( 'Heading color', 'storefront' ),
'section' => 'storefront_footer',
'settings' => 'storefront_footer_heading_color',
@ -409,7 +447,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Footer text color
*/
$wp_customize->add_setting(
'storefront_footer_text_color', array(
'storefront_footer_text_color',
array(
'default' => apply_filters( 'storefront_default_footer_text_color', '#61656b' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -417,7 +456,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_footer_text_color', array(
$wp_customize,
'storefront_footer_text_color',
array(
'label' => __( 'Text color', 'storefront' ),
'section' => 'storefront_footer',
'settings' => 'storefront_footer_text_color',
@ -430,7 +471,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Footer link color
*/
$wp_customize->add_setting(
'storefront_footer_link_color', array(
'storefront_footer_link_color',
array(
'default' => apply_filters( 'storefront_default_footer_link_color', '#2c2d33' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -438,7 +480,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_footer_link_color', array(
$wp_customize,
'storefront_footer_link_color',
array(
'label' => __( 'Link color', 'storefront' ),
'section' => 'storefront_footer',
'settings' => 'storefront_footer_link_color',
@ -451,7 +495,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Buttons section
*/
$wp_customize->add_section(
'storefront_buttons', array(
'storefront_buttons',
array(
'title' => __( 'Buttons', 'storefront' ),
'priority' => 45,
'description' => __( 'Customize the look & feel of your website buttons.', 'storefront' ),
@ -462,7 +507,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Button background color
*/
$wp_customize->add_setting(
'storefront_button_background_color', array(
'storefront_button_background_color',
array(
'default' => apply_filters( 'storefront_default_button_background_color', '#96588a' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -470,7 +516,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_button_background_color', array(
$wp_customize,
'storefront_button_background_color',
array(
'label' => __( 'Background color', 'storefront' ),
'section' => 'storefront_buttons',
'settings' => 'storefront_button_background_color',
@ -483,7 +531,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Button text color
*/
$wp_customize->add_setting(
'storefront_button_text_color', array(
'storefront_button_text_color',
array(
'default' => apply_filters( 'storefront_default_button_text_color', '#ffffff' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -491,7 +540,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_button_text_color', array(
$wp_customize,
'storefront_button_text_color',
array(
'label' => __( 'Text color', 'storefront' ),
'section' => 'storefront_buttons',
'settings' => 'storefront_button_text_color',
@ -504,7 +555,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Button alt background color
*/
$wp_customize->add_setting(
'storefront_button_alt_background_color', array(
'storefront_button_alt_background_color',
array(
'default' => apply_filters( 'storefront_default_button_alt_background_color', '#2c2d33' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -512,7 +564,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_button_alt_background_color', array(
$wp_customize,
'storefront_button_alt_background_color',
array(
'label' => __( 'Alternate button background color', 'storefront' ),
'section' => 'storefront_buttons',
'settings' => 'storefront_button_alt_background_color',
@ -525,7 +579,8 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Button alt text color
*/
$wp_customize->add_setting(
'storefront_button_alt_text_color', array(
'storefront_button_alt_text_color',
array(
'default' => apply_filters( 'storefront_default_button_alt_text_color', '#ffffff' ),
'sanitize_callback' => 'sanitize_hex_color',
)
@ -533,7 +588,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize, 'storefront_button_alt_text_color', array(
$wp_customize,
'storefront_button_alt_text_color',
array(
'label' => __( 'Alternate button text color', 'storefront' ),
'section' => 'storefront_buttons',
'settings' => 'storefront_button_alt_text_color',
@ -546,14 +603,16 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
* Layout
*/
$wp_customize->add_section(
'storefront_layout', array(
'storefront_layout',
array(
'title' => __( 'Layout', 'storefront' ),
'priority' => 50,
)
);
$wp_customize->add_setting(
'storefront_layout', array(
'storefront_layout',
array(
'default' => apply_filters( 'storefront_default_layout', $layout = is_rtl() ? 'left' : 'right' ),
'sanitize_callback' => 'storefront_sanitize_choices',
)
@ -561,7 +620,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new Storefront_Custom_Radio_Image_Control(
$wp_customize, 'storefront_layout', array(
$wp_customize,
'storefront_layout',
array(
'settings' => 'storefront_layout',
'section' => 'storefront_layout',
'label' => __( 'General Layout', 'storefront' ),
@ -579,14 +640,16 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
*/
if ( apply_filters( 'storefront_customizer_more', true ) ) {
$wp_customize->add_section(
'storefront_more', array(
'storefront_more',
array(
'title' => __( 'More', 'storefront' ),
'priority' => 999,
)
);
$wp_customize->add_setting(
'storefront_more', array(
'storefront_more',
array(
'default' => null,
'sanitize_callback' => 'sanitize_text_field',
)
@ -594,7 +657,9 @@ if ( ! class_exists( 'Storefront_Customizer' ) ) :
$wp_customize->add_control(
new More_Storefront_Control(
$wp_customize, 'storefront_more', array(
$wp_customize,
'storefront_more',
array(
'label' => __( 'Looking for more options?', 'storefront' ),
'section' => 'storefront_more',
'settings' => 'storefront_more',