From 5abb1baa8ea6fce91982565a28e9b54457f16153 Mon Sep 17 00:00:00 2001 From: Gary Kealy Date: Thu, 4 Jul 2019 15:51:13 +0100 Subject: [PATCH 1/3] Update phpcs ruleset --- composer.json | 7 ++-- composer.lock | 64 +++++++++++++++++++++++++++-- phpcs.xml | 110 +++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 151 insertions(+), 30 deletions(-) diff --git a/composer.json b/composer.json index 8b19715..798bb5e 100644 --- a/composer.json +++ b/composer.json @@ -15,10 +15,11 @@ }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", - "wp-coding-standards/wpcs": "^2.1" + "wp-coding-standards/wpcs": "^2.1", + "phpcompatibility/php-compatibility": "^9.2" }, "scripts": { - "test": ["phpcs"], - "fix": ["phpcbf"] + "test": ["vendor/bin/phpcs"], + "fix": ["vendor/bin/phpcbf"] } } diff --git a/composer.lock b/composer.lock index 0a08534..2441126 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6f047956cbb4861fde466b775966f717", + "content-hash": "6e38e340aaa610ed48211f151263555e", "packages": [ { "name": "composer/installers", @@ -194,6 +194,64 @@ ], "time": "2018-10-26T13:21:45+00:00" }, + { + "name": "phpcompatibility/php-compatibility", + "version": "9.2.0", + "source": { + "type": "git", + "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", + "reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/3db1bf1e28123fd574a4ae2e9a84072826d51b5e", + "reference": "3db1bf1e28123fd574a4ae2e9a84072826d51b5e", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "squizlabs/php_codesniffer": "^2.3 || ^3.0.2" + }, + "conflict": { + "squizlabs/php_codesniffer": "2.6.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "suggest": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.", + "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors" + }, + { + "name": "Wim Godden", + "homepage": "https://github.com/wimg", + "role": "lead" + }, + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + } + ], + "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.", + "homepage": "http://techblog.wimgodden.be/tag/codesniffer/", + "keywords": [ + "compatibility", + "phpcs", + "standards" + ], + "time": "2019-06-27T19:58:56+00:00" + }, { "name": "squizlabs/php_codesniffer", "version": "3.4.2", @@ -250,12 +308,12 @@ "version": "2.1.1", "source": { "type": "git", - "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", "reference": "bd9c33152115e6741e3510ff7189605b35167908" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/bd9c33152115e6741e3510ff7189605b35167908", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/bd9c33152115e6741e3510ff7189605b35167908", "reference": "bd9c33152115e6741e3510ff7189605b35167908", "shasum": "" }, diff --git a/phpcs.xml b/phpcs.xml index 73bde8a..3d04969 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,10 +1,17 @@ - - - + - A custom set of code standard rules to check for WordPress themes. + A custom set of code standard rules for UnderStrap. + + + + + + + + + @@ -13,31 +20,86 @@ . - ./vendor + */vendor/* + */node_modules/* - - + + + + + + + + + + + + - - + + + - - - - - - - - - - - - - + + + + + + + + + + - - 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 327e0ddb59295ab48e70a153bbbd581d2764de36 Mon Sep 17 00:00:00 2001 From: Gary Kealy Date: Thu, 4 Jul 2019 15:53:03 +0100 Subject: [PATCH 2/3] Fix some minor phpcs errors --- author.php | 2 +- inc/deprecated.php | 13 +++++++------ inc/extras.php | 2 +- inc/setup.php | 4 ++-- woocommerce/cart/mini-cart.php | 1 + woocommerce/myaccount/my-orders.php | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/author.php b/author.php index 032f3cd..a51dd26 100644 --- a/author.php +++ b/author.php @@ -52,7 +52,7 @@ $container = get_theme_mod( 'understrap_container_type' ); user_description ) ) : ?>
-
user_description ); ?>
+
user_description, 'understrap' ); ?>
diff --git a/inc/deprecated.php b/inc/deprecated.php index ebe3eb3..e877d76 100644 --- a/inc/deprecated.php +++ b/inc/deprecated.php @@ -8,13 +8,14 @@ // Exit if accessed directly. defined( 'ABSPATH' ) || exit; -/** - * Count number of widgets in a sidebar - * Used to add classes to widget areas so widgets can be displayed one, two, three or four per row - * - * @deprecated 0.8.9 - */ if ( ! function_exists( 'understrap_slbd_count_widgets' ) ) { + /** + * Count number of widgets in a sidebar + * Used to add classes to widget areas so widgets can be displayed one, two, three or four per row + * + * @param int $sidebar_id The ID of the sidebar. + * @deprecated 0.8.9 + */ function understrap_slbd_count_widgets( $sidebar_id ) { // If loading from front page, consult $_wp_sidebars_widgets rather than options // to see if wp_convert_widget_settings() has made manipulations in memory. diff --git a/inc/extras.php b/inc/extras.php index 9cb5cb5..e80198f 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -83,7 +83,7 @@ if ( ! function_exists( 'understrap_change_logo_class' ) ) { * Display navigation to next/previous post when applicable. */ -if ( ! function_exists ( 'understrap_post_nav' ) ) { +if ( ! function_exists( 'understrap_post_nav' ) ) { function understrap_post_nav() { // Don't print empty markup if there's nowhere to navigate. $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, '', true ); diff --git a/inc/setup.php b/inc/setup.php index 0a22660..9853c1a 100644 --- a/inc/setup.php +++ b/inc/setup.php @@ -15,7 +15,7 @@ if ( ! isset( $content_width ) ) { add_action( 'after_setup_theme', 'understrap_setup' ); -if ( ! function_exists ( 'understrap_setup' ) ) { +if ( ! function_exists( 'understrap_setup' ) ) { /** * Sets up theme defaults and registers support for various WordPress features. * @@ -90,7 +90,7 @@ if ( ! function_exists ( 'understrap_setup' ) ) { // Set up the WordPress Theme logo feature. add_theme_support( 'custom-logo' ); - + // Add support for responsive embedded content. add_theme_support( 'responsive-embeds' ); diff --git a/woocommerce/cart/mini-cart.php b/woocommerce/cart/mini-cart.php index 9c973b9..4ba9451 100644 --- a/woocommerce/cart/mini-cart.php +++ b/woocommerce/cart/mini-cart.php @@ -17,6 +17,7 @@ * @package WooCommerce/Templates * @version 3.6.1 */ + if ( ! defined( 'ABSPATH' ) ) { exit; } diff --git a/woocommerce/myaccount/my-orders.php b/woocommerce/myaccount/my-orders.php index 271b4a9..b9660ec 100644 --- a/woocommerce/myaccount/my-orders.php +++ b/woocommerce/myaccount/my-orders.php @@ -70,7 +70,7 @@ if ( $customer_orders ) : ?> $action ) { echo '' . esc_html( $action['name'] ) . ''; From afca2ffb56d8c303b61919ae042faf95151e1336 Mon Sep 17 00:00:00 2001 From: Gary Kealy Date: Thu, 4 Jul 2019 15:58:08 +0100 Subject: [PATCH 3/3] Remove closing php tags at end of files --- 404.php | 2 +- archive.php | 2 +- author.php | 2 +- global-templates/hero.php | 2 +- global-templates/right-sidebar-check.php | 2 +- inc/pagination.php | 2 +- index.php | 2 +- page-templates/both-sidebarspage.php | 2 +- page-templates/fullwidthpage.php | 2 +- page-templates/left-sidebarpage.php | 2 +- page-templates/right-sidebarpage.php | 2 +- page.php | 2 +- phpcs.xml | 2 +- search.php | 2 +- sidebar-templates/sidebar-footerfull.php | 2 +- sidebar-templates/sidebar-hero.php | 2 +- sidebar-templates/sidebar-herocanvas.php | 2 +- sidebar-templates/sidebar-statichero.php | 2 +- single.php | 2 +- woocommerce/cart/cart-empty.php | 2 +- woocommerce/cart/cart.php | 2 +- woocommerce/cart/mini-cart.php | 2 +- woocommerce/checkout/form-checkout.php | 2 +- woocommerce/myaccount/downloads.php | 2 +- woocommerce/myaccount/form-edit-account.php | 2 +- woocommerce/myaccount/form-edit-address.php | 2 +- woocommerce/myaccount/form-login.php | 2 +- woocommerce/myaccount/my-orders.php | 2 +- woocommerce/myaccount/navigation.php | 2 +- woocommerce/myaccount/orders.php | 2 +- woocommerce/single-product/add-to-cart/simple.php | 2 +- 31 files changed, 31 insertions(+), 31 deletions(-) diff --git a/404.php b/404.php index 6a12926..d0e4a93 100644 --- a/404.php +++ b/404.php @@ -86,4 +86,4 @@ $container = get_theme_mod( 'understrap_container_type' ); - + - + - + - + - + + diff --git a/index.php b/index.php index c5e4417..03750db 100644 --- a/index.php +++ b/index.php @@ -72,4 +72,4 @@ $container = get_theme_mod( 'understrap_container_type' ); - + - + - + - + - + - + - + diff --git a/search.php b/search.php index 205b880..945d203 100644 --- a/search.php +++ b/search.php @@ -75,4 +75,4 @@ $container = get_theme_mod( 'understrap_container_type' ); - + - + - + - + - + - + 0 ) : ?>

- + ?> - + - +is_registration_enabled() && $checkout->is_registration_requir - + - + - + - + - + - + - + - +is_in_stock() ) : ?> - +