diff --git a/.travis.yml b/.travis.yml index 170d075ef60..4eed346afbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ sudo: false php: - 5.6 - 7.0 - - 7.1 env: - WP_VERSION=latest WP_MULTISITE=0 @@ -20,6 +19,8 @@ matrix: dist: precise - php: 5.2 dist: precise + - php: 7.1 + env: WP_VERSION=latest WP_MULTISITE=0 RUN_PHPCS=1 - php: 7.1 env: WP_VERSION=latest WP_MULTISITE=0 RUN_CODE_COVERAGE=1 allow_failures: @@ -27,7 +28,6 @@ matrix: before_script: - export PATH="$HOME/.composer/vendor/bin:$PATH" - - if [[ $TRAVIS_PHP_VERSION == '7.1' ]]; then composer install; fi - bash tests/bin/install.sh woocommerce_test root '' localhost $WP_VERSION - bash tests/bin/travis.sh before @@ -37,3 +37,10 @@ script: after_script: - bash tests/bin/travis.sh after + +# Specifies that Travis should create builds for master and release branches and also tags. +branches: + only: + - master + - /^\d+\.\d+(\.\d+)?(-\S*)?$/ + - /^release\// diff --git a/Gruntfile.js b/Gruntfile.js index fd287077e7a..5e39bd00f32 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -334,9 +334,9 @@ module.exports = function( grunt ) { // Register tasks grunt.registerTask( 'default', [ - 'jshint', - 'uglify', - 'css' + 'js', + 'css', + 'i18n' ]); grunt.registerTask( 'js', [ @@ -358,8 +358,13 @@ module.exports = function( grunt ) { 'shell:apigen' ]); + // Only an alias to 'default' task. grunt.registerTask( 'dev', [ - 'default', + 'default' + ]); + + grunt.registerTask( 'i18n', [ + 'checktextdomain', 'makepot' ]); diff --git a/assets/js/admin/wc-shipping-classes.js b/assets/js/admin/wc-shipping-classes.js index eefd8374b89..526076c431f 100644 --- a/assets/js/admin/wc-shipping-classes.js +++ b/assets/js/admin/wc-shipping-classes.js @@ -145,7 +145,7 @@ classes = _.indexBy( model.get( 'classes' ), 'term_id' ), changes = {}, size = _.size( classes ), - newRow = _.extend( {}, data.default_class, { + newRow = _.extend( {}, data.default_shipping_class, { term_id: 'new-' + size + '-' + Date.now(), editing: true, newRow : true diff --git a/composer.json b/composer.json index be3bd973671..6b5edf1febc 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ }, "require-dev": { "squizlabs/php_codesniffer": "*", - "wp-coding-standards/wpcs": "0.13.1", + "wp-coding-standards/wpcs": "^0.14", "phpunit/phpunit": "6.2.3", "woocommerce/woocommerce-git-hooks": "1.0.3", "wimg/php-compatibility": "^8.0", diff --git a/composer.lock b/composer.lock index 3abf28c7d12..6c3ea1d6aa4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "9a9c7e81cc3a30935c03b1b2d64c201c", + "content-hash": "f8dbe5807f695e87ad3453a8b629b6bf", "packages": [ { "name": "composer/installers", @@ -1783,16 +1783,16 @@ }, { "name": "wp-coding-standards/wpcs", - "version": "0.13.1", + "version": "0.14.0", "source": { "type": "git", "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git", - "reference": "1f64b1a0b5b789822d0303436ee4e30e0135e4dc" + "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/1f64b1a0b5b789822d0303436ee4e30e0135e4dc", - "reference": "1f64b1a0b5b789822d0303436ee4e30e0135e4dc", + "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/8cadf48fa1c70b2381988e0a79e029e011a8f41c", + "reference": "8cadf48fa1c70b2381988e0a79e029e011a8f41c", "shasum": "" }, "require": { @@ -1800,7 +1800,7 @@ "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1" + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -1819,7 +1819,7 @@ "standards", "wordpress" ], - "time": "2017-08-05T16:08:58+00:00" + "time": "2017-11-01T15:10:46+00:00" } ], "aliases": [], diff --git a/includes/abstracts/abstract-wc-data.php b/includes/abstracts/abstract-wc-data.php index 8644e15190c..a252e5b9ed2 100644 --- a/includes/abstracts/abstract-wc-data.php +++ b/includes/abstracts/abstract-wc-data.php @@ -285,7 +285,7 @@ abstract class WC_Data { if ( ! $has_setter_or_getter ) { return false; } - + /* translators: %s: $key Key to check */ wc_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'woocommerce' ), $key ), '3.2.0' ); return true; @@ -400,7 +400,7 @@ abstract class WC_Data { * @param string $value * @param int $meta_id */ - public function update_meta_data( $key, $value, $meta_id = '' ) { + public function update_meta_data( $key, $value, $meta_id = 0 ) { if ( $this->is_internal_meta_key( $key ) ) { $function = 'set_' . $key; diff --git a/includes/abstracts/abstract-wc-product.php b/includes/abstracts/abstract-wc-product.php index 01f529627c5..301faa05b73 100644 --- a/includes/abstracts/abstract-wc-product.php +++ b/includes/abstracts/abstract-wc-product.php @@ -1531,7 +1531,7 @@ class WC_Product extends WC_Abstract_Legacy_Product { * @return bool */ public function is_shipping_taxable() { - return $this->get_tax_status() === 'taxable' || $this->get_tax_status() === 'shipping'; + return $this->needs_shipping() && ( $this->get_tax_status() === 'taxable' || $this->get_tax_status() === 'shipping' ); } /** diff --git a/includes/admin/class-wc-admin-settings.php b/includes/admin/class-wc-admin-settings.php index 861784851bc..90e95a4b39a 100644 --- a/includes/admin/class-wc-admin-settings.php +++ b/includes/admin/class-wc-admin-settings.php @@ -83,11 +83,11 @@ class WC_Admin_Settings { self::add_message( __( 'Your settings have been saved.', 'woocommerce' ) ); self::check_download_folder_protection(); - // Clear any unwanted data and flush rules + // Clear any unwanted data and flush rules on next init. + add_option( 'woocommerce_queue_flush_rewrite_rules', 'true' ); delete_transient( 'woocommerce_cache_excluded_uris' ); WC()->query->init_query_vars(); WC()->query->add_endpoints(); - wp_schedule_single_event( time(), 'woocommerce_flush_rewrite_rules' ); do_action( 'woocommerce_settings_saved' ); } diff --git a/includes/admin/class-wc-admin-setup-wizard.php b/includes/admin/class-wc-admin-setup-wizard.php index 50ac35e751d..f3aff414ce7 100644 --- a/includes/admin/class-wc-admin-setup-wizard.php +++ b/includes/admin/class-wc-admin-setup-wizard.php @@ -1664,7 +1664,7 @@ class WC_Admin_Setup_Wizard { $docs_url = 'https://docs.woocommerce.com/documentation/plugins/woocommerce/getting-started/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin'; $help_text = sprintf( /* translators: %1$s: link to videos, %2$s: link to docs */ - __( 'Watch our guided tour videos to learn more about WooCommerce, and visit WooCommerce.com to learn more about getting started.' ), + __( 'Watch our guided tour videos to learn more about WooCommerce, and visit WooCommerce.com to learn more about getting started.', 'woocommerce' ), $videos_url, $docs_url ); diff --git a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php index c15ab9c8133..a4c57c545ba 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-product-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-product-data.php @@ -284,12 +284,18 @@ class WC_Meta_Box_Product_Data { $attribute_key = sanitize_title( $attribute->get_name() ); if ( ! is_null( $index ) ) { - $value = isset( $_POST[ $key_prefix . $attribute_key ][ $index ] ) ? stripslashes( $_POST[ $key_prefix . $attribute_key ][ $index ] ) : ''; + $value = isset( $_POST[ $key_prefix . $attribute_key ][ $index ] ) ? wp_unslash( $_POST[ $key_prefix . $attribute_key ][ $index ] ) : ''; } else { - $value = isset( $_POST[ $key_prefix . $attribute_key ] ) ? stripslashes( $_POST[ $key_prefix . $attribute_key ] ) : ''; + $value = isset( $_POST[ $key_prefix . $attribute_key ] ) ? wp_unslash( $_POST[ $key_prefix . $attribute_key ] ) : ''; + } + + if ( $attribute->is_taxonomy() ) { + // Don't use wc_clean as it destroys sanitized characters. + $value = sanitize_title( $value ); + } else { + $value = html_entity_decode( wc_clean( $value ), ENT_QUOTES, get_bloginfo( 'charset' ) ); // WPCS: sanitization ok. } - $value = $attribute->is_taxonomy() ? sanitize_title( $value ) : wc_clean( $value ); // Don't use wc_clean as it destroys sanitized characters in terms. $attributes[ $attribute_key ] = $value; } } diff --git a/includes/admin/meta-boxes/views/html-order-download-permission.php b/includes/admin/meta-boxes/views/html-order-download-permission.php index 13da3f0dce1..e9fe6a28ff5 100644 --- a/includes/admin/meta-boxes/views/html-order-download-permission.php +++ b/includes/admin/meta-boxes/views/html-order-download-permission.php @@ -5,7 +5,7 @@ if ( ! defined( 'ABSPATH' ) ) { ?>

- +
get_file_download_path( $download->get_download_id() ) ) ) ); printf( _n( 'Downloaded %s time', 'Downloaded %s times', $download->get_download_count(), 'woocommerce' ), esc_html( $download->get_download_count() ) ) - ?> + ?>

+ @@ -41,10 +41,10 @@ if ( ! defined( 'ABSPATH' ) ) { ?> @@ -65,10 +65,10 @@ if ( ! defined( 'ABSPATH' ) ) { ?> diff --git a/includes/admin/meta-boxes/views/html-order-item-meta.php b/includes/admin/meta-boxes/views/html-order-item-meta.php index 7e2dc47996d..c4e3a8055a1 100644 --- a/includes/admin/meta-boxes/views/html-order-item-meta.php +++ b/includes/admin/meta-boxes/views/html-order-item-meta.php @@ -18,8 +18,9 @@ $hidden_order_itemmeta = apply_filters( 'woocommerce_hidden_order_itemmeta', arr ?>
get_formatted_meta_data( '' ) ) : ?>
- - + + - + diff --git a/includes/admin/meta-boxes/views/html-order-fee.php b/includes/admin/meta-boxes/views/html-order-fee.php index b04e1fbb7ff..a300126d93b 100644 --- a/includes/admin/meta-boxes/views/html-order-fee.php +++ b/includes/admin/meta-boxes/views/html-order-fee.php @@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; } ?> -
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) { - +
- $meta ) : - if ( in_array( $meta->key, $hidden_order_itemmeta ) ) { + $meta ) : + if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) { continue; } ?> @@ -35,8 +36,9 @@ $hidden_order_itemmeta = apply_filters( 'woocommerce_hidden_order_itemmeta', arr
get_formatted_meta_data( '' ) ) : ?> - $meta ) : - if ( in_array( $meta->key, $hidden_order_itemmeta ) ) { + $meta ) : + if ( in_array( $meta->key, $hidden_order_itemmeta, true ) ) { continue; } ?> @@ -52,7 +54,7 @@ $hidden_order_itemmeta = apply_filters( 'woocommerce_hidden_order_itemmeta', arr - +
diff --git a/includes/admin/meta-boxes/views/html-order-item.php b/includes/admin/meta-boxes/views/html-order-item.php index 55bc8f02b16..bbc2823272f 100644 --- a/includes/admin/meta-boxes/views/html-order-item.php +++ b/includes/admin/meta-boxes/views/html-order-item.php @@ -12,7 +12,7 @@ $product = $item->get_product(); $product_link = $product ? admin_url( 'post.php?post=' . $item->get_product_id() . '&action=edit' ) : ''; $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnail', $product->get_image( 'thumbnail', array( 'title' => '' ), false ), $item_id, $item ) : ''; ?> - + ' . wp_kses_post( $thumbnail ) . '
'; ?> @@ -21,11 +21,11 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai echo $product_link ? '' . esc_html( $item->get_name() ) . '' : '
' . esc_html( $item->get_name() ) . '
'; if ( $product && $product->get_sku() ) { - echo '
' . __( 'SKU:', 'woocommerce' ) . ' ' . esc_html( $product->get_sku() ) . '
'; + echo '
' . esc_html__( 'SKU:', 'woocommerce' ) . ' ' . esc_html( $product->get_sku() ) . '
'; } if ( $item->get_variation_id() ) { - echo '
' . __( 'Variation ID:', 'woocommerce' ) . ' '; + echo '
' . esc_html__( 'Variation ID:', 'woocommerce' ) . ' '; if ( 'product_variation' === get_post_type( $item->get_variation_id() ) ) { echo esc_html( $item->get_variation_id() ); } else { @@ -38,9 +38,9 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai - + - + @@ -67,10 +67,10 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai ?>
@@ -91,16 +91,16 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
- +
- +
@@ -114,7 +114,7 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
$order->get_currency() ) ); } else { echo '–'; @@ -137,16 +137,16 @@ $thumbnail = $product ? apply_filters( 'woocommerce_admin_order_item_thumbnai
- +
- +
- + - - - + + + $tax_item ) : $tax_class = wc_get_tax_class_by_tax_id( $tax_item['rate_id'] ); $tax_class_name = isset( $classes_options[ $tax_class ] ) ? $classes_options[ $tax_class ] : __( 'Tax', 'woocommerce' ); $column_label = ! empty( $tax_item['label'] ) ? $tax_item['label'] : __( 'Tax', 'woocommerce' ); + /* translators: %1$s: tax item name %2$s: tax class name */ $column_tip = sprintf( esc_html__( '%1$s (%2$s)', 'woocommerce' ), $tax_item['name'], $tax_class_name ); ?> - - + +
@@ -108,7 +109,7 @@ if ( wc_tax_enabled() ) { ?>