From 1a99235dc85193b43b43e03fa225aef9a69fde89 Mon Sep 17 00:00:00 2001 From: fuzzguard Date: Sat, 11 Mar 2017 11:43:21 +1100 Subject: [PATCH 1/9] Adding in proper error handling from 'lostpassword_post' Since WP version 4.4.0 the 'lostpassword_post' hook has had the ability to handle error messages from the WP_Error class. This allows errors to to occur BEFORE the username or email address are validated against the WP. wp-login.php /** * Fires before errors are returned from a password reset request. * * @since 2.1.0 * @since 4.4.0 Added the `$errors` parameter. * * @param WP_Error $errors A WP_Error object containing any errors generated * by using invalid credentials. */ do_action( 'lostpassword_post', $errors ); if ( $errors->get_error_code() ) return $errors; Proposal is to have this same process be respected by WooCommerce Lost Password process. --- includes/shortcodes/class-wc-shortcode-my-account.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/shortcodes/class-wc-shortcode-my-account.php b/includes/shortcodes/class-wc-shortcode-my-account.php index 33b93e25836..c8749ab1461 100644 --- a/includes/shortcodes/class-wc-shortcode-my-account.php +++ b/includes/shortcodes/class-wc-shortcode-my-account.php @@ -246,8 +246,14 @@ class WC_Shortcode_My_Account { if ( ! $user_data && is_email( $login ) && apply_filters( 'woocommerce_get_username_from_email', true ) ) { $user_data = get_user_by( 'email', $login ); } + + $errors = new WP_Error(); + do_action( 'lostpassword_post', $errors ); - do_action( 'lostpassword_post' ); + if ( $errors->get_error_code() ) { + wc_add_notice( $allow->get_error_message(), 'error' ); + return false; + } if ( ! $user_data ) { wc_add_notice( __( 'Invalid username or email.', 'woocommerce' ), 'error' ); From 591327287a665bdd2701f96e70e17feb1b454725 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 13 Mar 2017 21:24:59 -0300 Subject: [PATCH 2/9] Do not set remaining downloads when is unlimited --- includes/class-wc-download-handler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-download-handler.php b/includes/class-wc-download-handler.php index 39a7a5b9734..93195b74c7f 100644 --- a/includes/class-wc-download-handler.php +++ b/includes/class-wc-download-handler.php @@ -75,7 +75,9 @@ class WC_Download_Handler { $count = $download->get_download_count(); $remaining = $download->get_downloads_remaining(); $download->set_download_count( $count + 1 ); - $download->set_downloads_remaining( $remaining - 1 ); + if ( '' !== $remaining ) { + $download->set_downloads_remaining( $remaining - 1 ); + } $download->save(); self::download( $product->get_file_download_path( $download->get_download_id() ), $download->get_product_id() ); From 53b7844412425a2d747cf49e4955c5c865210dc1 Mon Sep 17 00:00:00 2001 From: James Koster Date: Tue, 14 Mar 2017 10:42:21 +0000 Subject: [PATCH 3/9] Replace figure tags with divs. closes #13546 For easier theme support --- templates/single-product/product-image.php | 8 ++++---- templates/single-product/product-thumbnails.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/single-product/product-image.php b/templates/single-product/product-image.php index 5b70531697b..a638fd9e1ea 100644 --- a/templates/single-product/product-image.php +++ b/templates/single-product/product-image.php @@ -45,13 +45,13 @@ $wrapper_classes = apply_filters( 'woocommerce_single_product_image_gallery_cl ); if ( has_post_thumbnail() ) { - $html = ''; + $html .= ''; } else { - $html = ''; + $html .= ''; } echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, get_post_thumbnail_id( $post->ID ) ); diff --git a/templates/single-product/product-thumbnails.php b/templates/single-product/product-thumbnails.php index 120cea46c11..5c36f1498d3 100644 --- a/templates/single-product/product-thumbnails.php +++ b/templates/single-product/product-thumbnails.php @@ -38,9 +38,9 @@ if ( $attachment_ids && has_post_thumbnail() ) { 'data-large-image-height' => $full_size_image[2], ); - $html = ''; + $html .= ''; echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', $html, $attachment_id ); } From 4f8030aafb83ec2fa522e9cd22295c758a28beeb Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 14 Mar 2017 11:19:22 +0000 Subject: [PATCH 4/9] Remove clear divs from address forms #13583 --- templates/checkout/form-billing.php | 1 - templates/myaccount/form-edit-account.php | 2 -- 2 files changed, 3 deletions(-) diff --git a/templates/checkout/form-billing.php b/templates/checkout/form-billing.php index a7b03fb4698..8f3197d5f49 100644 --- a/templates/checkout/form-billing.php +++ b/templates/checkout/form-billing.php @@ -65,7 +65,6 @@ if ( ! defined( 'ABSPATH' ) ) { get_checkout_fields( 'account' ) as $key => $field ) : ?> get_value( $key ) ); ?> -
diff --git a/templates/myaccount/form-edit-account.php b/templates/myaccount/form-edit-account.php index e76c6a0f6c7..4fa19c4c6a2 100644 --- a/templates/myaccount/form-edit-account.php +++ b/templates/myaccount/form-edit-account.php @@ -34,7 +34,6 @@ do_action( 'woocommerce_before_edit_account_form' ); ?>

-

@@ -57,7 +56,6 @@ do_action( 'woocommerce_before_edit_account_form' ); ?>

-
From 7f787fac8424da0c066ea503f55bda59053da298 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 14 Mar 2017 12:17:49 +0000 Subject: [PATCH 5/9] Check empty strings literally Closes #13565 --- includes/admin/meta-boxes/views/html-order-fee.php | 2 +- includes/admin/meta-boxes/views/html-order-shipping.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/admin/meta-boxes/views/html-order-fee.php b/includes/admin/meta-boxes/views/html-order-fee.php index 3bcfe1be1ea..f7e823b7274 100644 --- a/includes/admin/meta-boxes/views/html-order-fee.php +++ b/includes/admin/meta-boxes/views/html-order-fee.php @@ -56,7 +56,7 @@ if ( ! defined( 'ABSPATH' ) ) {
$order->get_currency() ) ) : '–'; + echo ( '' !== $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '–'; if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'fee' ) ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; diff --git a/includes/admin/meta-boxes/views/html-order-shipping.php b/includes/admin/meta-boxes/views/html-order-shipping.php index 905fe7372c1..e81d1848364 100644 --- a/includes/admin/meta-boxes/views/html-order-shipping.php +++ b/includes/admin/meta-boxes/views/html-order-shipping.php @@ -82,7 +82,7 @@ if ( ! defined( 'ABSPATH' ) ) {
$order->get_currency() ) ) : '–'; + echo ( '' !== $tax_item_total ) ? wc_price( wc_round_tax_total( $tax_item_total ), array( 'currency' => $order->get_currency() ) ) : '–'; if ( $refunded = $order->get_tax_refunded_for_item( $item_id, $tax_item_id, 'shipping' ) ) { echo '-' . wc_price( $refunded, array( 'currency' => $order->get_currency() ) ) . ''; From 08c6cfdea83a3e03dc115289f6ce517b988c4cee Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 14 Mar 2017 12:28:48 +0000 Subject: [PATCH 6/9] composer version --- tests/bin/travis.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/bin/travis.sh b/tests/bin/travis.sh index 1ed7426b53f..9e50956bbda 100755 --- a/tests/bin/travis.sh +++ b/tests/bin/travis.sh @@ -9,6 +9,7 @@ if [ $1 == 'before' ]; then # No Xdebug and therefore no coverage in PHP 5.3 [[ ${TRAVIS_PHP_VERSION} == '5.3' ]] && exit; + composer require phpunit/phpunit:5.6 composer self-update composer install --no-interaction From a9e224fa78fed267bc661ac7ea3ec845ef355fe4 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 14 Mar 2017 12:32:34 +0000 Subject: [PATCH 7/9] Wrap rating with esc_html --- includes/widgets/class-wc-widget-layered-nav-filters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/widgets/class-wc-widget-layered-nav-filters.php b/includes/widgets/class-wc-widget-layered-nav-filters.php index afb0801ae04..1d85c6e7404 100644 --- a/includes/widgets/class-wc-widget-layered-nav-filters.php +++ b/includes/widgets/class-wc-widget-layered-nav-filters.php @@ -163,7 +163,7 @@ class WC_Widget_Layered_Nav_Filters extends WC_Widget { foreach ( $rating_filter as $rating ) { $link_ratings = implode( ',', array_diff( $rating_filter, array( $rating ) ) ); $link = $link_ratings ? add_query_arg( 'rating_filter', $link_ratings ) : remove_query_arg( 'rating_filter', $base_link ); - echo '
  • ' . sprintf( esc_html__( 'Rated %s out of 5', 'woocommerce' ), $rating ) . '
  • '; + echo '
  • ' . sprintf( esc_html__( 'Rated %s out of 5', 'woocommerce' ), esc_html( $rating ) ) . '
  • '; } } From 49b782d20e1a3c7f98738a57d7629bfbe91f3dc2 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 14 Mar 2017 12:34:20 +0000 Subject: [PATCH 8/9] Correct formatting --- includes/shortcodes/class-wc-shortcode-my-account.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/shortcodes/class-wc-shortcode-my-account.php b/includes/shortcodes/class-wc-shortcode-my-account.php index c8749ab1461..599f94458f9 100644 --- a/includes/shortcodes/class-wc-shortcode-my-account.php +++ b/includes/shortcodes/class-wc-shortcode-my-account.php @@ -246,11 +246,12 @@ class WC_Shortcode_My_Account { if ( ! $user_data && is_email( $login ) && apply_filters( 'woocommerce_get_username_from_email', true ) ) { $user_data = get_user_by( 'email', $login ); } - - $errors = new WP_Error(); - do_action( 'lostpassword_post', $errors ); - if ( $errors->get_error_code() ) { + $errors = new WP_Error(); + + do_action( 'lostpassword_post', $errors ); + + if ( $errors->get_error_code() ) { wc_add_notice( $allow->get_error_message(), 'error' ); return false; } From ed09c20715de77454232c7fe6c002faef69298be Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 14 Mar 2017 12:50:54 +0000 Subject: [PATCH 9/9] Trying to fix travis tests --- tests/bin/phpunit.sh | 3 +++ tests/bin/travis.sh | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/bin/phpunit.sh b/tests/bin/phpunit.sh index bb7a731ab40..37c452db0b9 100755 --- a/tests/bin/phpunit.sh +++ b/tests/bin/phpunit.sh @@ -1,3 +1,6 @@ +composer require phpunit/phpunit:5.6 +composer install + if [[ ${TRAVIS_BRANCH} == 'master' ]] && [[ ${TRAVIS_EVENT_TYPE} != 'pull_request' ]] && [[ ${TRAVIS_PHP_VERSION} == ${PHP_LATEST_STABLE} ]]; then phpunit -c phpunit.xml.dist --coverage-clover ./tmp/clover.xml else diff --git a/tests/bin/travis.sh b/tests/bin/travis.sh index 9e50956bbda..1ed7426b53f 100755 --- a/tests/bin/travis.sh +++ b/tests/bin/travis.sh @@ -9,7 +9,6 @@ if [ $1 == 'before' ]; then # No Xdebug and therefore no coverage in PHP 5.3 [[ ${TRAVIS_PHP_VERSION} == '5.3' ]] && exit; - composer require phpunit/phpunit:5.6 composer self-update composer install --no-interaction