From 7f4c0d033449b35700f068965ea9b6451eee6588 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Thu, 20 Jun 2019 14:43:19 +0200 Subject: [PATCH 001/153] Store template cache value without ABSPATH to avoid issues with multi container environments. --- includes/wc-core-functions.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 67d245dbcdf..918536acab7 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -185,7 +185,16 @@ function wc_get_template_part( $slug, $name = '' ) { ); } - wp_cache_set( $cache_key, $template, 'woocommerce' ); + // Remove ABSPATH from template cache to avoid issues with multi container having different paths. + if ( 0 === strpos( $template, ABSPATH ) ) { + $template = str_replace( ABSPATH, '', $template ); + wp_cache_set( $cache_key, $template, 'woocommerce' ); + } + } + + // Add back ABSPATH to template location so it loads correctly, only if it does not exist yet. + if ( false === strpos( $template, ABSPATH ) ) { + $template = ABSPATH . $template; } // Allow 3rd party plugins to filter template file from their plugin. @@ -210,7 +219,16 @@ function wc_get_template( $template_name, $args = array(), $template_path = '', if ( ! $template ) { $template = wc_locate_template( $template_name, $template_path, $default_path ); - wp_cache_set( $cache_key, $template, 'woocommerce' ); + // Remove ABSPATH from template cache to avoid issues with multi container having different paths. + if ( 0 === strpos( $template, ABSPATH ) ) { + $template = str_replace( ABSPATH, '', $template ); + wp_cache_set( $cache_key, $template, 'woocommerce' ); + } + } + + // Add back ABSPATH to template location so it loads correctly, only if it does not exist yet. + if ( false === strpos( $template, ABSPATH ) ) { + $template = ABSPATH . $template; } // Allow 3rd party plugin filter template file from their plugin. From c4096a1d8f0a021f1ee0cd7901538410b831cc12 Mon Sep 17 00:00:00 2001 From: Gerhard Date: Thu, 20 Jun 2019 15:10:58 +0200 Subject: [PATCH 002/153] Cater for blank paths, do not prepend ABSPATH when template path blank. --- includes/wc-core-functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 918536acab7..203ceec8239 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -193,7 +193,7 @@ function wc_get_template_part( $slug, $name = '' ) { } // Add back ABSPATH to template location so it loads correctly, only if it does not exist yet. - if ( false === strpos( $template, ABSPATH ) ) { + if ( false === strpos( $template, ABSPATH ) && ! empty( $template ) ) { $template = ABSPATH . $template; } @@ -227,7 +227,7 @@ function wc_get_template( $template_name, $args = array(), $template_path = '', } // Add back ABSPATH to template location so it loads correctly, only if it does not exist yet. - if ( false === strpos( $template, ABSPATH ) ) { + if ( false === strpos( $template, ABSPATH ) && ! empty( $template ) ) { $template = ABSPATH . $template; } From 8a046ab0cdc816a2ba53df53c30f102578a9303c Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Thu, 30 Jan 2020 16:24:07 -0800 Subject: [PATCH 003/153] Cleaned up the template path replacement and fixed the wc_cache_set positioning --- includes/wc-core-functions.php | 28 +++++++-------- .../util/class-wc-tests-core-functions.php | 34 +++++++++++++++++++ 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 381bcaf3b3f..2d23abffd80 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -185,17 +185,16 @@ function wc_get_template_part( $slug, $name = '' ) { ); } - // Remove ABSPATH from template cache to avoid issues with multi container having different paths. + // Don't cache the absolute path so that it can be shared between web servers with different paths. if ( 0 === strpos( $template, ABSPATH ) ) { - $template = str_replace( ABSPATH, '', $template ); - wp_cache_set( $cache_key, $template, 'woocommerce' ); + $template = str_replace( ABSPATH, '{{ABSPATH}}', $template ); } + + wp_cache_set( $cache_key, $template, 'woocommerce' ); } - // Add back ABSPATH to template location so it loads correctly, only if it does not exist yet. - if ( false === strpos( $template, ABSPATH ) && ! empty( $template ) ) { - $template = ABSPATH . $template; - } + // Make sure that the absolute path to the template is resolved. + $template = str_replace( '{{ABSPATH}}', ABSPATH, $template ); // Allow 3rd party plugins to filter template file from their plugin. $template = apply_filters( 'wc_get_template_part', $template, $slug, $name ); @@ -219,17 +218,18 @@ function wc_get_template( $template_name, $args = array(), $template_path = '', if ( ! $template ) { $template = wc_locate_template( $template_name, $template_path, $default_path ); - // Remove ABSPATH from template cache to avoid issues with multi container having different paths. + + // Don't cache the absolute path so that it can be shared between web servers with different paths. if ( 0 === strpos( $template, ABSPATH ) ) { - $template = str_replace( ABSPATH, '', $template ); - wp_cache_set( $cache_key, $template, 'woocommerce' ); + // Use a token that we can easily replace. + $template = str_replace( ABSPATH, '{{ABSPATH}}', $template ); } + + wp_cache_set( $cache_key, $template, 'woocommerce' ); } - // Add back ABSPATH to template location so it loads correctly, only if it does not exist yet. - if ( false === strpos( $template, ABSPATH ) && ! empty( $template ) ) { - $template = ABSPATH . $template; - } + // Make sure that the absolute path to the template is resolved. + $template = str_replace( '{{ABSPATH}}', ABSPATH, $template ); // Allow 3rd party plugin filter template file from their plugin. $filter_template = apply_filters( 'wc_get_template', $template, $template_name, $args, $template_path, $default_path ); diff --git a/tests/unit-tests/util/class-wc-tests-core-functions.php b/tests/unit-tests/util/class-wc-tests-core-functions.php index 4ae30ddb806..e59a987fe56 100644 --- a/tests/unit-tests/util/class-wc-tests-core-functions.php +++ b/tests/unit-tests/util/class-wc-tests-core-functions.php @@ -604,6 +604,28 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { $this->assertNotEmpty( $template ); } + /** + * This test ensures that the absolute path to template files is replaced with a token. We do this so + * that the path can be made relative to each installation, and the cache can be shared. + */ + public function test_wc_get_template_cleans_absolute_path() { + add_filter( 'woocommerce_locate_template', array( $this, 'force_template_path' ), 10, 2 ); + + ob_start(); + try { + wc_get_template( 'global/wrapper-start.php' ); + } catch ( \Exception $exception ) { + // Since the file doesn't really exist this is going to throw an exception (which is fine for our test). + } + ob_end_clean(); + + remove_filter( 'woocommerce_locatsdae_template', array( $this, 'force_template_path' ) ); + + $file_path = wp_cache_get( sanitize_key( 'template-global/wrapper-start.php---' . WC_VERSION ), 'woocommerce' ); + + $this->assertEquals( '{{ABSPATH}}global/wrapper-start.php', $file_path ); + } + /** * Test wc_get_image_size function. * @@ -965,4 +987,16 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { $this->assertInstanceOf( 'WC_Session', $this->wc->session ); } + + /** + * Allows us to force the template path. Since the ABSPATH is to /tmp/wordpress in tests, we need to do this + * in order to keep the paths consistent for testing purposes. + * + * @param string $template The path to the template file. + * @param string $template_name The name of the template file. + * @return string The path to be used instead. + */ + public function force_template_path( $template, $template_name ) { + return ABSPATH . $template_name; + } } From b6046930c6187b29bc124c90f7201b4ab2a0e2fb Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Thu, 30 Jan 2020 18:12:00 -0800 Subject: [PATCH 004/153] Corrected a misspelled filter name --- tests/unit-tests/util/class-wc-tests-core-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit-tests/util/class-wc-tests-core-functions.php b/tests/unit-tests/util/class-wc-tests-core-functions.php index e59a987fe56..63311972ad4 100644 --- a/tests/unit-tests/util/class-wc-tests-core-functions.php +++ b/tests/unit-tests/util/class-wc-tests-core-functions.php @@ -619,7 +619,7 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { } ob_end_clean(); - remove_filter( 'woocommerce_locatsdae_template', array( $this, 'force_template_path' ) ); + remove_filter( 'woocommerce_locate_template', array( $this, 'force_template_path' ) ); $file_path = wp_cache_get( sanitize_key( 'template-global/wrapper-start.php---' . WC_VERSION ), 'woocommerce' ); From f1b6b488b80292a37a7d8594ef1ff2838fe58a51 Mon Sep 17 00:00:00 2001 From: Lee Willis Date: Fri, 20 Mar 2020 14:58:12 +0000 Subject: [PATCH 005/153] Add label to unlabelled taxonomies --- includes/class-wc-post-types.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/class-wc-post-types.php b/includes/class-wc-post-types.php index 7de16656db5..ab9dcbc07d2 100644 --- a/includes/class-wc-post-types.php +++ b/includes/class-wc-post-types.php @@ -59,6 +59,7 @@ class WC_Post_Types { 'query_var' => is_admin(), 'rewrite' => false, 'public' => false, + 'label' => _x( 'Product type', 'Taxonomy name', 'woocommerce' ), ) ) ); @@ -75,6 +76,7 @@ class WC_Post_Types { 'query_var' => is_admin(), 'rewrite' => false, 'public' => false, + 'label' => _x( 'Product visibility', 'Taxonomy name', 'woocommerce' ), ) ) ); From 8f3d8f0495bbbc9bbad6e5dc132f2e1c03354965 Mon Sep 17 00:00:00 2001 From: vedanshujain Date: Mon, 30 Mar 2020 18:05:13 +0000 Subject: [PATCH 006/153] Also cache with WC_ABSPATH to account for when WC is out of ABSPATH. We already substitute ABSPATH with {{ABSPATH}} token to make sure that exact template path is not cached to support deployment with multiple servers. This patch also add tokenizing WC_ABSPATH to account for when WooCommerce is installed outside of ABSPATH. --- includes/wc-core-functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 2d23abffd80..c607bbbd34a 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -190,11 +190,16 @@ function wc_get_template_part( $slug, $name = '' ) { $template = str_replace( ABSPATH, '{{ABSPATH}}', $template ); } + if ( 0 === strpos( $template, WC_ABSPATH ) ) { + $template = str_replace( WC_ABSPATH, '{{WC_ABSPATH}}', $template ); + } + wp_cache_set( $cache_key, $template, 'woocommerce' ); } // Make sure that the absolute path to the template is resolved. $template = str_replace( '{{ABSPATH}}', ABSPATH, $template ); + $template = str_replace( '{{WC_ABSPATH}}', WC_ABSPATH, $template ); // Allow 3rd party plugins to filter template file from their plugin. $template = apply_filters( 'wc_get_template_part', $template, $slug, $name ); From e270dfce2e8f0ffa7fcf468936447eb9835bc466 Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Sun, 5 Apr 2020 12:06:04 -0700 Subject: [PATCH 007/153] Extracted the template path tokenization so that it can be applied to more than one define more readily --- includes/wc-core-functions.php | 86 ++++++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 20 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 2c0bc76d147..2ce2981f83d 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -150,6 +150,42 @@ function wc_update_order( $args ) { return wc_create_order( $args ); } +/** + * Given a path, this will convert any of the subpaths into their corresponding tokens. + * + * @since 4.1.0 + * @param string $path The absolute path to tokenize. + * @param array $path_tokens An array keyed with the token, containing paths that should be replaced. + * @return string The tokenized path. + */ +function wc_tokenize_path( $path, $path_tokens ) { + foreach ( $path_tokens as $token => $token_path ) { + if ( 0 !== strpos( $path, $token_path ) ) { + continue; + } + + $path = str_replace( $token_path, '{{' . $token . '}}', $path ); + } + + return $path; +} + +/** + * Given a tokenized path, this will expand the tokens to their full path. + * + * @since 4.1.0 + * @param string $path The absolute path to expand. + * @param array $path_tokens An array keyed with the token, containing paths that should be expanded. + * @return string The absolute path. + */ +function wc_untokenize_path( $path, $path_tokens ) { + foreach ( $path_tokens as $token => $token_path ) { + $path = str_replace( '{{' . $token . '}}', $token_path, $path ); + } + + return $path; +} + /** * Get template part (for templates like the shop-loop). * @@ -188,21 +224,24 @@ function wc_get_template_part( $slug, $name = '' ) { } // Don't cache the absolute path so that it can be shared between web servers with different paths. - if ( 0 === strpos( $template, ABSPATH ) ) { - $template = str_replace( ABSPATH, '{{ABSPATH}}', $template ); - } + $cache_path = wc_tokenize_path( + $template, + array( + 'ABSPATH' => ABSPATH, + ) + ); - if ( 0 === strpos( $template, WC_ABSPATH ) ) { - $template = str_replace( WC_ABSPATH, '{{WC_ABSPATH}}', $template ); - } - - wp_cache_set( $cache_key, $template, 'woocommerce' ); + wp_cache_set( $cache_key, $cache_path, 'woocommerce' ); + } else { + // Make sure that the absolute path to the template is resolved. + $template = wc_untokenize_path( + $template, + array( + 'ABSPATH' => ABSPATH, + ) + ); } - // Make sure that the absolute path to the template is resolved. - $template = str_replace( '{{ABSPATH}}', ABSPATH, $template ); - $template = str_replace( '{{WC_ABSPATH}}', WC_ABSPATH, $template ); - // Allow 3rd party plugins to filter template file from their plugin. $template = apply_filters( 'wc_get_template_part', $template, $slug, $name ); @@ -227,17 +266,24 @@ function wc_get_template( $template_name, $args = array(), $template_path = '', $template = wc_locate_template( $template_name, $template_path, $default_path ); // Don't cache the absolute path so that it can be shared between web servers with different paths. - if ( 0 === strpos( $template, ABSPATH ) ) { - // Use a token that we can easily replace. - $template = str_replace( ABSPATH, '{{ABSPATH}}', $template ); - } + $cache_path = wc_tokenize_path( + $template, + array( + 'ABSPATH' => ABSPATH, + ) + ); - wp_cache_set( $cache_key, $template, 'woocommerce' ); + wp_cache_set( $cache_key, $cache_path, 'woocommerce' ); + } else { + // Make sure that the absolute path to the template is resolved. + $template = wc_untokenize_path( + $template, + array( + 'ABSPATH' => ABSPATH, + ) + ); } - // Make sure that the absolute path to the template is resolved. - $template = str_replace( '{{ABSPATH}}', ABSPATH, $template ); - // Allow 3rd party plugin filter template file from their plugin. $filter_template = apply_filters( 'wc_get_template', $template, $template_name, $args, $template_path, $default_path ); From 4aab99614a40c8b756214072e056382a77b97f74 Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Sun, 5 Apr 2020 12:15:39 -0700 Subject: [PATCH 008/153] Added tests for path tokenization/untokenization --- .../util/class-wc-tests-core-functions.php | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/unit-tests/util/class-wc-tests-core-functions.php b/tests/unit-tests/util/class-wc-tests-core-functions.php index ac186ab74fd..8ec37acccaf 100644 --- a/tests/unit-tests/util/class-wc-tests-core-functions.php +++ b/tests/unit-tests/util/class-wc-tests-core-functions.php @@ -569,6 +569,72 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { $this->assertEmpty( wc_get_template_part( 'nothinghere' ) ); } + /** + * Tests the wc_tokenize_path function. + */ + public function test_wc_tokenize_path() { + $path = wc_tokenize_path( ABSPATH . '/test', array() ); + $this->assertEquals( ABSPATH . '/test', $path ); + + $path = wc_tokenize_path( + ABSPATH . '/test', + array( + 'ABSPATH' => ABSPATH, + ) + ); + $this->assertEquals( '{{ABSPATH}}/test', $path ); + + $path = wc_tokenize_path( + ABSPATH . '/test', + array( + 'WP_CONTENT_DIR' => WP_CONTENT_DIR, + ) + ); + $this->assertEquals( ABSPATH . '/test', $path ); + + $path = wc_tokenize_path( + WP_CONTENT_DIR . '/test', + array( + 'WP_CONTENT_DIR' => WP_CONTENT_DIR, + 'ABSPATH' => ABSPATH, + ) + ); + $this->assertEquals( '{{WP_CONTENT_DIR}}/test', $path ); + } + + /** + * Tests the wc_untokenize_path function. + */ + public function test_wc_untokenize_path() { + $path = wc_untokenize_path( '{{ABSPATH}}/test', array() ); + $this->assertEquals( '{{ABSPATH}}/test', $path ); + + $path = wc_untokenize_path( + '{{ABSPATH}}/test', + array( + 'ABSPATH' => ABSPATH, + ) + ); + $this->assertEquals( ABSPATH . '/test', $path ); + + $path = wc_untokenize_path( + '{{ABSPATH}}/test', + array( + 'WP_CONTENT_DIR' => WP_CONTENT_DIR, + ) + ); + $this->assertEquals( '{{ABSPATH}}/test', $path ); + + $path = wc_untokenize_path( + '{{WP_CONTENT_DIR}}/test', + array( + 'WP_CONTENT_DIR' => WP_CONTENT_DIR, + 'ABSPATH' => ABSPATH, + ) + ); + $this->assertEquals( WP_CONTENT_DIR . '/test', $path ); + } + /** * Test wc_get_template. * From 33e81654a9d5766edf8169f4a433741a5b6cb398 Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Sun, 5 Apr 2020 12:41:39 -0700 Subject: [PATCH 009/153] Made the path tokenization deterministic Since the tokens are replaced in a first-discovered first-replaced order, we may accidentally create tokenized paths like '{{ABSPATH}}/test' instead of the desired '{{WP_CONTENT_DIR}}test'. By ordering them according to specificity however, we ensure that we tokenize as much of the path as possible. --- includes/wc-core-functions.php | 19 +++++++++ .../util/class-wc-tests-core-functions.php | 42 ++++++++++--------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 2ce2981f83d..ec2bc429d22 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -159,6 +159,25 @@ function wc_update_order( $args ) { * @return string The tokenized path. */ function wc_tokenize_path( $path, $path_tokens ) { + // Order most to least specific so that the token can encompass as much of the path as possible. + uasort( + $path_tokens, + function ( $a, $b ) { + $a = strlen( $a ); + $b = strlen( $b ); + + if ( $a > $b ) { + return -1; + } + + if ( $b > $a ) { + return 1; + } + + return 0; + } + ); + foreach ( $path_tokens as $token => $token_path ) { if ( 0 !== strpos( $path, $token_path ) ) { continue; diff --git a/tests/unit-tests/util/class-wc-tests-core-functions.php b/tests/unit-tests/util/class-wc-tests-core-functions.php index 8ec37acccaf..28508b6abbb 100644 --- a/tests/unit-tests/util/class-wc-tests-core-functions.php +++ b/tests/unit-tests/util/class-wc-tests-core-functions.php @@ -283,7 +283,7 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { public function test_wc_get_log_file_path() { $log_dir = trailingslashit( WC_LOG_DIR ); $hash_name = sanitize_file_name( wp_hash( 'unit-tests' ) ); - $date_suffix = date( 'Y-m-d', time() ); + $date_suffix = date( 'Y-m-d', time() ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date $this->assertEquals( $log_dir . 'unit-tests-' . $date_suffix . '-' . $hash_name . '.log', wc_get_log_file_path( 'unit-tests' ) ); } @@ -573,66 +573,66 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { * Tests the wc_tokenize_path function. */ public function test_wc_tokenize_path() { - $path = wc_tokenize_path( ABSPATH . '/test', array() ); - $this->assertEquals( ABSPATH . '/test', $path ); + $path = wc_tokenize_path( ABSPATH . 'test', array() ); + $this->assertEquals( ABSPATH . 'test', $path ); $path = wc_tokenize_path( - ABSPATH . '/test', + ABSPATH . 'test', array( 'ABSPATH' => ABSPATH, ) ); - $this->assertEquals( '{{ABSPATH}}/test', $path ); + $this->assertEquals( '{{ABSPATH}}test', $path ); $path = wc_tokenize_path( - ABSPATH . '/test', + ABSPATH . 'test', array( 'WP_CONTENT_DIR' => WP_CONTENT_DIR, ) ); - $this->assertEquals( ABSPATH . '/test', $path ); + $this->assertEquals( ABSPATH . 'test', $path ); $path = wc_tokenize_path( - WP_CONTENT_DIR . '/test', + WP_CONTENT_DIR . 'test', array( - 'WP_CONTENT_DIR' => WP_CONTENT_DIR, 'ABSPATH' => ABSPATH, + 'WP_CONTENT_DIR' => WP_CONTENT_DIR, ) ); - $this->assertEquals( '{{WP_CONTENT_DIR}}/test', $path ); + $this->assertEquals( '{{WP_CONTENT_DIR}}test', $path ); } /** * Tests the wc_untokenize_path function. */ public function test_wc_untokenize_path() { - $path = wc_untokenize_path( '{{ABSPATH}}/test', array() ); - $this->assertEquals( '{{ABSPATH}}/test', $path ); + $path = wc_untokenize_path( '{{ABSPATH}}test', array() ); + $this->assertEquals( '{{ABSPATH}}test', $path ); $path = wc_untokenize_path( - '{{ABSPATH}}/test', + '{{ABSPATH}}test', array( 'ABSPATH' => ABSPATH, ) ); - $this->assertEquals( ABSPATH . '/test', $path ); + $this->assertEquals( ABSPATH . 'test', $path ); $path = wc_untokenize_path( - '{{ABSPATH}}/test', + '{{ABSPATH}}test', array( 'WP_CONTENT_DIR' => WP_CONTENT_DIR, ) ); - $this->assertEquals( '{{ABSPATH}}/test', $path ); + $this->assertEquals( '{{ABSPATH}}test', $path ); $path = wc_untokenize_path( - '{{WP_CONTENT_DIR}}/test', + '{{WP_CONTENT_DIR}}test', array( 'WP_CONTENT_DIR' => WP_CONTENT_DIR, 'ABSPATH' => ABSPATH, ) ); - $this->assertEquals( WP_CONTENT_DIR . '/test', $path ); + $this->assertEquals( WP_CONTENT_DIR . 'test', $path ); } /** @@ -682,7 +682,7 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { ob_start(); try { wc_get_template( 'global/wrapper-start.php' ); - } catch ( \Exception $exception ) { + } catch ( \Exception $exception ) { // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch // Since the file doesn't really exist this is going to throw an exception (which is fine for our test). } ob_end_clean(); @@ -1044,7 +1044,9 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { $this->assertInstanceOf( 'WC_Customer', $this->wc->customer ); $this->assertInstanceOf( 'WC_Session', $this->wc->session ); - $this->wc->cart = $this->wc->customer = $this->wc->session = null; + $this->wc->cart = null; + $this->wc->customer = null; + $this->wc->session = null; $this->assertNull( $this->wc->cart ); $this->assertNull( $this->wc->customer ); $this->assertNull( $this->wc->session ); From a7c0dec33a0054f807819e3b3cc9ce914e6d3ff2 Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Sun, 5 Apr 2020 13:07:49 -0700 Subject: [PATCH 010/153] Added a function to fetch all of the path define tokens that may be present in template paths --- includes/wc-core-functions.php | 53 ++++++++++--------- .../util/class-wc-tests-core-functions.php | 9 ++++ 2 files changed, 38 insertions(+), 24 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index ec2bc429d22..c972adc2aea 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -205,6 +205,31 @@ function wc_untokenize_path( $path, $path_tokens ) { return $path; } +/** + * Fetches an array containing all of the configurable path constants to be used in tokenization. + * + * @return array The key is the define and the path is the constant. + */ +function wc_get_path_define_tokens() { + $defines = array( + 'ABSPATH', + 'WC_ABSPATH', + 'WP_CONTENT_DIR', + 'WP_PLUGIN_DIR', + 'PLUGINDIR', + 'WP_THEME_DIR', + ); + + $path_tokens = array(); + foreach ( $defines as $define ) { + if ( defined( $define ) ) { + $path_tokens[ $define ] = constant( $define ); + } + } + + return apply_filters( 'wc_get_path_define_tokens', $path_tokens ); +} + /** * Get template part (for templates like the shop-loop). * @@ -243,22 +268,12 @@ function wc_get_template_part( $slug, $name = '' ) { } // Don't cache the absolute path so that it can be shared between web servers with different paths. - $cache_path = wc_tokenize_path( - $template, - array( - 'ABSPATH' => ABSPATH, - ) - ); + $cache_path = wc_tokenize_path( $template, wc_get_path_define_tokens() ); wp_cache_set( $cache_key, $cache_path, 'woocommerce' ); } else { // Make sure that the absolute path to the template is resolved. - $template = wc_untokenize_path( - $template, - array( - 'ABSPATH' => ABSPATH, - ) - ); + $template = wc_untokenize_path( $template, wc_get_path_define_tokens() ); } // Allow 3rd party plugins to filter template file from their plugin. @@ -285,22 +300,12 @@ function wc_get_template( $template_name, $args = array(), $template_path = '', $template = wc_locate_template( $template_name, $template_path, $default_path ); // Don't cache the absolute path so that it can be shared between web servers with different paths. - $cache_path = wc_tokenize_path( - $template, - array( - 'ABSPATH' => ABSPATH, - ) - ); + $cache_path = wc_tokenize_path( $template, wc_get_path_define_tokens() ); wp_cache_set( $cache_key, $cache_path, 'woocommerce' ); } else { // Make sure that the absolute path to the template is resolved. - $template = wc_untokenize_path( - $template, - array( - 'ABSPATH' => ABSPATH, - ) - ); + $template = wc_untokenize_path( $template, wc_get_path_define_tokens() ); } // Allow 3rd party plugin filter template file from their plugin. diff --git a/tests/unit-tests/util/class-wc-tests-core-functions.php b/tests/unit-tests/util/class-wc-tests-core-functions.php index 28508b6abbb..5db7b9dfec4 100644 --- a/tests/unit-tests/util/class-wc-tests-core-functions.php +++ b/tests/unit-tests/util/class-wc-tests-core-functions.php @@ -635,6 +635,15 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case { $this->assertEquals( WP_CONTENT_DIR . 'test', $path ); } + /** + * Tests the wc_get_path_define_tokens function. + */ + public function test_wc_get_path_define_tokens() { + $defines = wc_get_path_define_tokens(); + $this->assertArrayHasKey( 'ABSPATH', $defines ); + $this->assertEquals( ABSPATH, $defines['ABSPATH'] ); + } + /** * Test wc_get_template. * From b43ad106efae5dedecb2eb226d98ef31ec7abc34 Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Mon, 6 Apr 2020 07:17:01 -0700 Subject: [PATCH 011/153] Added WPMU_PLUGIN_DIR and removed the path define token for ABSPATH There's no need for the ABSPATH define since the WC plugin is always a child of a plugin directory anyway. --- includes/wc-core-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index c972adc2aea..24b2273a154 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -213,9 +213,9 @@ function wc_untokenize_path( $path, $path_tokens ) { function wc_get_path_define_tokens() { $defines = array( 'ABSPATH', - 'WC_ABSPATH', 'WP_CONTENT_DIR', 'WP_PLUGIN_DIR', + 'WPMU_PLUGIN_DIR', 'PLUGINDIR', 'WP_THEME_DIR', ); From 2fedf9306e6642dee414caf95d00b6c19a713aaa Mon Sep 17 00:00:00 2001 From: Christopher Allford Date: Tue, 7 Apr 2020 10:25:57 -0700 Subject: [PATCH 012/153] Corrected the filter prefix for get_path_define_tokens --- includes/wc-core-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index 24b2273a154..b9fe3a41651 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -227,7 +227,7 @@ function wc_get_path_define_tokens() { } } - return apply_filters( 'wc_get_path_define_tokens', $path_tokens ); + return apply_filters( 'woocommerce_get_path_define_tokens', $path_tokens ); } /** From fbdbecbcf6453de94cde552494637999b08467c2 Mon Sep 17 00:00:00 2001 From: Sagar Tamang Date: Thu, 23 Apr 2020 01:20:21 +0545 Subject: [PATCH 013/153] Hide only the tab content under the tab wrapper --- assets/js/frontend/single-product.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/frontend/single-product.js b/assets/js/frontend/single-product.js index 30b3d6fd991..618791c6a47 100644 --- a/assets/js/frontend/single-product.js +++ b/assets/js/frontend/single-product.js @@ -9,7 +9,7 @@ jQuery( function( $ ) { $( 'body' ) // Tabs .on( 'init', '.wc-tabs-wrapper, .woocommerce-tabs', function() { - $( '.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)' ).hide(); + $( this ).find( '.wc-tab, .woocommerce-tabs .panel:not(.panel .panel)' ).hide(); var hash = window.location.hash; var url = window.location.href; From ab8ee194c8aff1710774ecd236fe2ea223d06e53 Mon Sep 17 00:00:00 2001 From: Sagar Tamang Date: Sat, 25 Apr 2020 21:10:11 +0545 Subject: [PATCH 014/153] Fix: Show password toggle not working in checkout page --- assets/js/frontend/woocommerce.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/js/frontend/woocommerce.js b/assets/js/frontend/woocommerce.js index 6c6047558cd..8c0414fff1b 100644 --- a/assets/js/frontend/woocommerce.js +++ b/assets/js/frontend/woocommerce.js @@ -81,15 +81,17 @@ jQuery( function( $ ) { // Show password visiblity hover icon on woocommerce forms $( '.woocommerce form .woocommerce-Input[type="password"]' ).wrap( '' ); + // Add 'password-input' class to the password wrapper in checkout page. + $( '.woocommerce form input' ).filter(':password').parent('span').addClass('password-input'); $( '.password-input' ).append( '' ); $( '.show-password-input' ).click( function() { $( this ).toggleClass( 'display-password' ); if ( $( this ).hasClass( 'display-password' ) ) { - $( this ).siblings( ['input[name^="password"]', 'input[type="password"]'] ).prop( 'type', 'text' ); + $( this ).siblings( ['input[type="password"]'] ).prop( 'type', 'text' ); } else { - $( this ).siblings( 'input[name^="password"]' ).prop( 'type', 'password' ); + $( this ).siblings( 'input[type="text"]' ).prop( 'type', 'password' ); } } ); From fc683bdb80f6f6d822f253a785b6f68ef2becac0 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Tue, 21 Apr 2020 17:43:15 -0500 Subject: [PATCH 015/153] Update unit tests to account for issue 24000 --- tests/legacy/unit-tests/cart/cart.php | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index 7c0fe0cb972..1ba5290e64b 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2051,6 +2051,49 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { $this->assertEquals( 70.86, WC()->cart->get_total( 'edit' ) ); } + /** + * Test that adding a variation with URL parameter increases the quantity appropriately + * as described in issue 24000. + */ + public function test_add_variation_with_url() { + add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + update_option( 'woocommerce_cart_redirect_after_add', 'no' ); + WC()->cart->empty_cart(); + + $product = WC_Helper_Product::create_variation_product(); + $variations = $product->get_available_variations(); + $variation = array_pop( $variations ); + + // Add variation with add_to_cart_action. + $_REQUEST['add-to-cart'] = $variation['variation_id']; + WC_Form_Handler::add_to_cart_action( false ); + $notices = WC()->session->get( 'wc_notices', array() ); + + // Reset filter / REQUEST variables. + unset( $_REQUEST['add-to-cart'] ); + remove_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + + // Check if the item is in the cart. + $this->assertEquals( 1, count( WC()->cart->get_cart_contents() ) ); + $this->assertEquals( 1, WC()->cart->get_cart_contents_count() ); + + // Add variation using parent id. + WC()->cart->add_to_cart( + $product->get_id(), + 1, + $variation['variation_id'], + array( + 'attribute_pa_size' => 'huge', + 'attribute_pa_color' => 'red', + 'attribute_pa_number' => '2', + ) + ); + + // Check that the second add to cart call increases the quantity of the existing cart-item. + $this->assertEquals( 1, count( WC()->cart->get_cart_contents() ) ); + $this->assertEquals( 2, WC()->cart->get_cart_contents_count() ); + } + /** * Helper function. Adds 1.5 taxable fees to cart. */ From 31bdce3725334c4677e1ecc88dc57eefa2d4f3f7 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Tue, 21 Apr 2020 18:03:21 -0500 Subject: [PATCH 016/153] Fix typo in test_add_variation_with_url test (use British spelling of colour) --- tests/legacy/unit-tests/cart/cart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index 1ba5290e64b..fa02219875b 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2084,7 +2084,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { $variation['variation_id'], array( 'attribute_pa_size' => 'huge', - 'attribute_pa_color' => 'red', + 'attribute_pa_colour' => 'red', 'attribute_pa_number' => '2', ) ); From 0c2b97ead29668e15c3645b6361d83e9d0e9124f Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Tue, 21 Apr 2020 18:11:45 -0500 Subject: [PATCH 017/153] Load variation attributes when adding to cart by variation id --- includes/class-wc-form-handler.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index 3565b642a6b..43544f64c85 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -862,11 +862,12 @@ class WC_Form_Handler { */ private static function add_to_cart_handler_variable( $product_id ) { try { - $variation_id = empty( $_REQUEST['variation_id'] ) ? '' : absint( wp_unslash( $_REQUEST['variation_id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $quantity = empty( $_REQUEST['quantity'] ) ? 1 : wc_stock_amount( wp_unslash( $_REQUEST['quantity'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $missing_attributes = array(); - $variations = array(); - $adding_to_cart = wc_get_product( $product_id ); + $variation_id = empty( $_REQUEST['variation_id'] ) ? '' : absint( wp_unslash( $_REQUEST['variation_id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $quantity = empty( $_REQUEST['quantity'] ) ? 1 : wc_stock_amount( wp_unslash( $_REQUEST['quantity'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $missing_attributes = array(); + $variations = array(); + $variation_attributes = array(); + $adding_to_cart = wc_get_product( $product_id ); if ( ! $adding_to_cart ) { return false; @@ -874,6 +875,7 @@ class WC_Form_Handler { // If the $product_id was in fact a variation ID, update the variables. if ( $adding_to_cart->is_type( 'variation' ) ) { + $variation_attributes = $adding_to_cart->get_variation_attributes(); $variation_id = $product_id; $product_id = $adding_to_cart->get_parent_id(); $adding_to_cart = wc_get_product( $product_id ); @@ -904,6 +906,9 @@ class WC_Form_Handler { } } + // Merge variation attributes and posted attributes. + $posted_and_variation_attributes = array_merge( $posted_attributes, $variation_attributes ); + // If no variation ID is set, attempt to get a variation ID from posted attributes. if ( empty( $variation_id ) ) { $data_store = WC_Data_Store::load( 'product' ); @@ -932,8 +937,8 @@ class WC_Form_Handler { * * If no attribute was posted, only error if the variation has an 'any' attribute which requires a value. */ - if ( isset( $posted_attributes[ $attribute_key ] ) ) { - $value = $posted_attributes[ $attribute_key ]; + if ( isset( $posted_and_variation_attributes[ $attribute_key ] ) ) { + $value = $posted_and_variation_attributes[ $attribute_key ]; // Allow if valid or show error. if ( $valid_value === $value ) { From f8066a81419ffbae24a27f98f9352b5e6b9b7d8e Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 24 Apr 2020 13:48:00 -0500 Subject: [PATCH 018/153] Swap order of array_merge so that posted attributes do not get clobbered --- includes/class-wc-form-handler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index 43544f64c85..25e0e97cf62 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -907,7 +907,7 @@ class WC_Form_Handler { } // Merge variation attributes and posted attributes. - $posted_and_variation_attributes = array_merge( $posted_attributes, $variation_attributes ); + $posted_and_variation_attributes = array_merge( $variation_attributes, $posted_attributes ); // If no variation ID is set, attempt to get a variation ID from posted attributes. if ( empty( $variation_id ) ) { From 3d0bfd8ee248369988298123c509979a8535850c Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 24 Apr 2020 13:52:16 -0500 Subject: [PATCH 019/153] Add test to check for notice when invalid attribute is provided for a variant --- tests/legacy/unit-tests/cart/cart.php | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index fa02219875b..d374430c6c4 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2094,6 +2094,36 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { $this->assertEquals( 2, WC()->cart->get_cart_contents_count() ); } + /** + * Test that adding a variation via URL parameter fails when specifying a value for the attribute + * that differs from a value belonging to that variant. + */ + public function test_add_variation_with_invalid_attribute() { + add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + update_option( 'woocommerce_cart_redirect_after_add', 'no' ); + WC()->cart->empty_cart(); + + $product = WC_Helper_Product::create_variation_product(); + $variations = $product->get_available_variations(); + $variation = array_pop( $variations ); + + // Attempt adding variation with add_to_cart_action, specifying a different colour. + $_REQUEST['add-to-cart'] = $variation['variation_id']; + $_REQUEST['attribute_pa_colour'] = 'green'; + WC_Form_Handler::add_to_cart_action( false ); + $notices = WC()->session->get( 'wc_notices', array() ); + + // Reset filter / REQUEST variables. + unset( $_REQUEST['add-to-cart'] ); + unset( $_REQUEST['attribute_pa_colour'] ); + remove_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + + // Check that the notices contain an error message about an invalid colour. + $this->assertArrayHasKey( 'error', $notices ); + $this->assertCount( 1, $notices['error'] ); + $this->assertEquals( 'Invalid value posted for colour', $notices['error'][0]['notice'] ); + } + /** * Helper function. Adds 1.5 taxable fees to cart. */ From 3f70f70f3a2df1d3417c3653464e2da8d234c7e3 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 24 Apr 2020 13:54:12 -0500 Subject: [PATCH 020/153] Switch to assertCount for count assertions in test --- tests/legacy/unit-tests/cart/cart.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index d374430c6c4..5e0fa7d414a 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2074,7 +2074,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { remove_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); // Check if the item is in the cart. - $this->assertEquals( 1, count( WC()->cart->get_cart_contents() ) ); + $this->assertCount( 1, WC()->cart->get_cart_contents() ); $this->assertEquals( 1, WC()->cart->get_cart_contents_count() ); // Add variation using parent id. @@ -2090,7 +2090,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { ); // Check that the second add to cart call increases the quantity of the existing cart-item. - $this->assertEquals( 1, count( WC()->cart->get_cart_contents() ) ); + $this->assertCount( 1, WC()->cart->get_cart_contents() ); $this->assertEquals( 2, WC()->cart->get_cart_contents_count() ); } From 790c8ae8ae5378652071ff61f49dc5cd5d7c021a Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 24 Apr 2020 14:02:14 -0500 Subject: [PATCH 021/153] Update the test to make sure there are no error notices --- tests/legacy/unit-tests/cart/cart.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index 5e0fa7d414a..8768395d352 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2077,6 +2077,9 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { $this->assertCount( 1, WC()->cart->get_cart_contents() ); $this->assertEquals( 1, WC()->cart->get_cart_contents_count() ); + // Check that there are no error notices. + $this->assertArrayNotHasKey( 'error', $notices ); + // Add variation using parent id. WC()->cart->add_to_cart( $product->get_id(), @@ -2088,10 +2091,14 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { 'attribute_pa_number' => '2', ) ); + $notices = WC()->session->get( 'wc_notices', array() ); // Check that the second add to cart call increases the quantity of the existing cart-item. $this->assertCount( 1, WC()->cart->get_cart_contents() ); $this->assertEquals( 2, WC()->cart->get_cart_contents_count() ); + + // Check that there are no error notices. + $this->assertArrayNotHasKey( 'error', $notices ); } /** From 3f47608228ad7b4ecac6c44d7c3902464d2af869 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 24 Apr 2020 14:20:21 -0500 Subject: [PATCH 022/153] Test adding a variation with 'any' attributes --- tests/legacy/unit-tests/cart/cart.php | 32 +++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index 8768395d352..4a04dabfd11 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2055,7 +2055,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { * Test that adding a variation with URL parameter increases the quantity appropriately * as described in issue 24000. */ - public function test_add_variation_with_url() { + public function test_add_variation_by_url() { add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); update_option( 'woocommerce_cart_redirect_after_add', 'no' ); WC()->cart->empty_cart(); @@ -2105,7 +2105,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { * Test that adding a variation via URL parameter fails when specifying a value for the attribute * that differs from a value belonging to that variant. */ - public function test_add_variation_with_invalid_attribute() { + public function test_add_variation_by_url_with_invalid_attribute() { add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); update_option( 'woocommerce_cart_redirect_after_add', 'no' ); WC()->cart->empty_cart(); @@ -2131,6 +2131,34 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { $this->assertEquals( 'Invalid value posted for colour', $notices['error'][0]['notice'] ); } + /** + * Test that adding a variation via URL parameter succeeds when some attributes belong to the + * variation and others are specificed via URL parameter. + */ + public function test_add_variation_by_url_with_valid_attribute() { + add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + update_option( 'woocommerce_cart_redirect_after_add', 'no' ); + WC()->cart->empty_cart(); + + $product = WC_Helper_Product::create_variation_product(); + $variations = $product->get_available_variations(); + $variation = array_shift( $variations ); + + // Attempt adding variation with add_to_cart_action, specifying attributes not defined in the variation. + $_REQUEST['add-to-cart'] = $variation['variation_id']; + $_REQUEST['attribute_pa_colour'] = 'red'; + $_REQUEST['attribute_pa_number'] = '1'; + WC_Form_Handler::add_to_cart_action( false ); + $notices = WC()->session->get( 'wc_notices', array() ); + + // Check if the item is in the cart. + $this->assertCount( 1, WC()->cart->get_cart_contents() ); + $this->assertEquals( 1, WC()->cart->get_cart_contents_count() ); + + // Check that there are no error notices. + $this->assertArrayNotHasKey( 'error', $notices ); + } + /** * Helper function. Adds 1.5 taxable fees to cart. */ From c0a72c9185019d85bc617161423cd79daf5abf30 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 24 Apr 2020 14:21:03 -0500 Subject: [PATCH 023/153] Reset notices at the start of each test --- tests/legacy/unit-tests/cart/cart.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index 4a04dabfd11..51ab38ec256 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2059,6 +2059,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); update_option( 'woocommerce_cart_redirect_after_add', 'no' ); WC()->cart->empty_cart(); + WC()->session->set( 'wc_notices', null ); $product = WC_Helper_Product::create_variation_product(); $variations = $product->get_available_variations(); @@ -2109,6 +2110,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); update_option( 'woocommerce_cart_redirect_after_add', 'no' ); WC()->cart->empty_cart(); + WC()->session->set( 'wc_notices', null ); $product = WC_Helper_Product::create_variation_product(); $variations = $product->get_available_variations(); @@ -2139,6 +2141,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); update_option( 'woocommerce_cart_redirect_after_add', 'no' ); WC()->cart->empty_cart(); + WC()->session->set( 'wc_notices', null ); $product = WC_Helper_Product::create_variation_product(); $variations = $product->get_available_variations(); From 53c905f49388a65db882ff7caf72694b2f53c707 Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Fri, 24 Apr 2020 14:22:48 -0500 Subject: [PATCH 024/153] Reset request vars in any attribute test --- tests/legacy/unit-tests/cart/cart.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index 51ab38ec256..f28e36ac4af 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2154,6 +2154,12 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { WC_Form_Handler::add_to_cart_action( false ); $notices = WC()->session->get( 'wc_notices', array() ); + // Reset filter / REQUEST variables. + unset( $_REQUEST['add-to-cart'] ); + unset( $_REQUEST['attribute_pa_colour'] ); + unset( $_REQUEST['attribute_pa_number'] ); + remove_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + // Check if the item is in the cart. $this->assertCount( 1, WC()->cart->get_cart_contents() ); $this->assertEquals( 1, WC()->cart->get_cart_contents_count() ); From a0a8cf7ab38b4ebffc5ca72f36dd9488addaa57a Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Tue, 5 May 2020 14:16:01 -0500 Subject: [PATCH 025/153] Add test to ensure that a notice is displayed when an any attribute is omitted --- tests/legacy/unit-tests/cart/cart.php | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/legacy/unit-tests/cart/cart.php b/tests/legacy/unit-tests/cart/cart.php index f28e36ac4af..67759435034 100644 --- a/tests/legacy/unit-tests/cart/cart.php +++ b/tests/legacy/unit-tests/cart/cart.php @@ -2168,6 +2168,40 @@ class WC_Tests_Cart extends WC_Unit_Test_Case { $this->assertArrayNotHasKey( 'error', $notices ); } + /** + * Test that adding a varition via URL parameter fails when an 'any' attribute is missing. + */ + public function test_add_variation_by_url_fails_with_missing_any_attribute() { + add_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + update_option( 'woocommerce_cart_redirect_after_add', 'no' ); + WC()->cart->empty_cart(); + WC()->session->set( 'wc_notices', null ); + + $product = WC_Helper_Product::create_variation_product(); + $variations = $product->get_available_variations(); + $variation = array_shift( $variations ); + + // Attempt adding variation with add_to_cart_action, without specifying attribute_pa_colour. + $_REQUEST['add-to-cart'] = $variation['variation_id']; + $_REQUEST['attribute_pa_number'] = '0'; + WC_Form_Handler::add_to_cart_action( false ); + $notices = WC()->session->get( 'wc_notices', array() ); + + // Reset filter / REQUEST variables. + unset( $_REQUEST['add-to-cart'] ); + unset( $_REQUEST['attribute_pa_number'] ); + remove_filter( 'woocommerce_add_to_cart_redirect', '__return_false' ); + + // Verify that there is nothing in the cart. + $this->assertCount( 0, WC()->cart->get_cart_contents() ); + $this->assertEquals( 0, WC()->cart->get_cart_contents_count() ); + + // Check that the notices contain an error message about an invalid colour. + $this->assertArrayHasKey( 'error', $notices ); + $this->assertCount( 1, $notices['error'] ); + $this->assertEquals( 'colour is a required field', $notices['error'][0]['notice'] ); + } + /** * Helper function. Adds 1.5 taxable fees to cart. */ From 2db4da7055ab81a72df179dd6799c4cb77dca67b Mon Sep 17 00:00:00 2001 From: Jonathan Sadowski Date: Tue, 5 May 2020 14:16:37 -0500 Subject: [PATCH 026/153] Update variation_attributes to filter out any attributes, as they must be specified --- includes/class-wc-form-handler.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/class-wc-form-handler.php b/includes/class-wc-form-handler.php index 25e0e97cf62..28a78df71de 100644 --- a/includes/class-wc-form-handler.php +++ b/includes/class-wc-form-handler.php @@ -876,6 +876,8 @@ class WC_Form_Handler { // If the $product_id was in fact a variation ID, update the variables. if ( $adding_to_cart->is_type( 'variation' ) ) { $variation_attributes = $adding_to_cart->get_variation_attributes(); + // Filter out 'any' variations, which are empty, as they need to be explicitly specified while adding to cart. + $variation_attributes = array_filter( $variation_attributes ); $variation_id = $product_id; $product_id = $adding_to_cart->get_parent_id(); $adding_to_cart = wc_get_product( $product_id ); From 8e21f10b3d09ad14de3d45a3ba710a89b6974aa0 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 6 May 2020 14:07:46 -0300 Subject: [PATCH 027/153] Update since tags --- includes/wc-core-functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/wc-core-functions.php b/includes/wc-core-functions.php index b9fe3a41651..30e5de4f4f8 100644 --- a/includes/wc-core-functions.php +++ b/includes/wc-core-functions.php @@ -153,7 +153,7 @@ function wc_update_order( $args ) { /** * Given a path, this will convert any of the subpaths into their corresponding tokens. * - * @since 4.1.0 + * @since 4.2.0 * @param string $path The absolute path to tokenize. * @param array $path_tokens An array keyed with the token, containing paths that should be replaced. * @return string The tokenized path. @@ -192,7 +192,7 @@ function wc_tokenize_path( $path, $path_tokens ) { /** * Given a tokenized path, this will expand the tokens to their full path. * - * @since 4.1.0 + * @since 4.2.0 * @param string $path The absolute path to expand. * @param array $path_tokens An array keyed with the token, containing paths that should be expanded. * @return string The absolute path. From 7634f54235b900e0581ae3fd9b19fa481ec1e1cd Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 6 May 2020 23:20:56 -0300 Subject: [PATCH 028/153] Use "Options -Indexes" for redirect download method --- includes/class-wc-install.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index a219d7d8323..6debbd914fd 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -1206,15 +1206,12 @@ CREATE TABLE {$wpdb->prefix}wc_tax_rate_classes ( 'file' => 'index.html', 'content' => '', ), - ); - - if ( 'redirect' !== $download_method ) { - $files[] = array( + array( 'base' => $upload_dir['basedir'] . '/woocommerce_uploads', 'file' => '.htaccess', - 'content' => 'deny from all', - ); - } + 'content' => 'redirect' === $download_method ? 'Options -Indexes' : 'deny from all', + ), + ); foreach ( $files as $file ) { if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) { From 39633855f3e4b438cfffd7f8a5b7d7edf87638bc Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 6 May 2020 23:21:31 -0300 Subject: [PATCH 029/153] Only fetch the uploads info and do not attempt to create the uploads directory --- includes/class-wc-install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index 6debbd914fd..0fa82cf35fd 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -1187,7 +1187,7 @@ CREATE TABLE {$wpdb->prefix}wc_tax_rate_classes ( } // Install files and folders for uploading files and prevent hotlinking. - $upload_dir = wp_upload_dir(); + $upload_dir = wp_get_upload_dir(); $download_method = get_option( 'woocommerce_file_download_method', 'force' ); $files = array( From dcabbcb964946a3d0367f4cc8f4fc92e81e60b15 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 6 May 2020 23:25:33 -0300 Subject: [PATCH 030/153] Open file in binary mode --- includes/class-wc-install.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index 0fa82cf35fd..4061f1a7c9d 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -1215,7 +1215,7 @@ CREATE TABLE {$wpdb->prefix}wc_tax_rate_classes ( foreach ( $files as $file ) { if ( wp_mkdir_p( $file['base'] ) && ! file_exists( trailingslashit( $file['base'] ) . $file['file'] ) ) { - $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'w' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen + $file_handle = @fopen( trailingslashit( $file['base'] ) . $file['file'], 'wb' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen if ( $file_handle ) { fwrite( $file_handle, $file['content'] ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose From 16ec0007cfa3c839b9ad973d485987063a5a1629 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Wed, 6 May 2020 23:42:33 -0300 Subject: [PATCH 031/153] Set "Options -Indexes" for redirect download method Stop the .htaccess to get removed and stop directory listing --- includes/admin/class-wc-admin-settings.php | 34 ++++++++++++---------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/includes/admin/class-wc-admin-settings.php b/includes/admin/class-wc-admin-settings.php index 837ffbc8230..3a68ae50739 100644 --- a/includes/admin/class-wc-admin-settings.php +++ b/includes/admin/class-wc-admin-settings.php @@ -869,25 +869,29 @@ if ( ! class_exists( 'WC_Admin_Settings', false ) ) : * If using force or x-sendfile, this ensures the .htaccess is in place. */ public static function check_download_folder_protection() { - $upload_dir = wp_upload_dir(); - $downloads_url = $upload_dir['basedir'] . '/woocommerce_uploads'; + $upload_dir = wp_get_upload_dir(); + $downloads_path = $upload_dir['basedir'] . '/woocommerce_uploads'; $download_method = get_option( 'woocommerce_file_download_method' ); + $file_path = $downloads_path . '/.htaccess'; + $file_content = 'redirect' === $download_method ? 'Options -Indexes' : 'deny from all'; + $create = false; - if ( 'redirect' === $download_method ) { - - // Redirect method - don't protect. - if ( file_exists( $downloads_url . '/.htaccess' ) ) { - unlink( $downloads_url . '/.htaccess' ); // @codingStandardsIgnoreLine - } + if ( wp_mkdir_p( $downloads_path ) && ! file_exists( $file_path ) ) { + $create = true; } else { + $current_content = @file_get_contents( $file_path ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents - // Force method - protect, add rules to the htaccess file. - if ( ! file_exists( $downloads_url . '/.htaccess' ) ) { - $file_handle = @fopen( $downloads_url . '/.htaccess', 'w' ); // @codingStandardsIgnoreLine - if ( $file_handle ) { - fwrite( $file_handle, 'deny from all' ); // @codingStandardsIgnoreLine - fclose( $file_handle ); // @codingStandardsIgnoreLine - } + if ( $current_content !== $file_content ) { + unlink( $file_path ); + $create = true; + } + } + + if ( $create ) { + $file_handle = @fopen( $file_path, 'wb' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.WP.AlternativeFunctions.file_system_read_fopen + if ( $file_handle ) { + fwrite( $file_handle, $file_content ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fwrite + fclose( $file_handle ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_read_fclose } } } From 611d5aac828d364018b2fdce13d02ae721c61f68 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Thu, 7 May 2020 11:43:18 +0200 Subject: [PATCH 032/153] Added packages to list of contributors. --- Gruntfile.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0a8316eb8c9..f64f9a05845 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -215,11 +215,32 @@ module.exports = function( grunt ) { }, contributors: { command: [ - 'echo "Generating contributor list since <%= fromDate %>"', + 'echo "

WooCommerce Admin

" > contributors.md', + 'echo "Generating contributor list for WC Admin since <%= fromDate %>"', + './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-admin --fromDate <%= fromDate %>' + + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', + 'echo "

WooCommerce Blocks

" >> contributors.md', + 'echo "Generating contributor list for WC Blocks since <%= fromDate %>"', + './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-gutenberg-products-block' + + ' --fromDate <%= fromDate %> --authToken <%= authToken %> --cols 6 --sortBy contributions --format html' + + ' --sortOrder desc --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', + 'echo "

Action Scheduler

" >> contributors.md', + 'echo "Generating contributor list for Action Scheduler since <%= fromDate %>"', + './node_modules/.bin/githubcontrib --owner woocommerce --repo action-scheduler --fromDate <%= fromDate %>' + + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', + 'echo "

REST API

" >> contributors.md', + 'echo "Generating contributor list for REST API since <%= fromDate %>"', + './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-rest-api --fromDate <%= fromDate %>' + + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', + 'echo "

WooCommerce core

" >> contributors.md', + 'echo "Generating contributor list for WC core since <%= fromDate %>"', './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %>' + - ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format md --sortOrder desc' + - ' --showlogin true --sha <%= sha %> --filter renovate-bot > contributors.md' - ].join( '&&' ) + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md' + ].join('&&') } }, @@ -230,17 +251,12 @@ module.exports = function( grunt ) { { config: 'fromDate', type: 'input', - message: 'What date (YYYY-MM-DD) should we get contributions since?' - }, - { - config: 'sha', - type: 'input', - message: 'What branch should we get contributors from?' + message: 'What date (YYYY-MM-DD) should we get contributions since? (i.e. date of previous release)' }, { config: 'authToken', type: 'input', - message: '(optional) Provide a personal access token.' + + message: 'Provide a personal access token (you must).' + ' This will allow 5000 requests per hour rather than 60 - use if nothing is generated.' } ] From 626bf9a3b3533c878b64f592b8f94c94a7c4683b Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Thu, 7 May 2020 14:16:07 +0200 Subject: [PATCH 033/153] Renamed the file to produce correct filename. --- Gruntfile.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index f64f9a05845..dc30ea6fd2c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -215,31 +215,32 @@ module.exports = function( grunt ) { }, contributors: { command: [ - 'echo "

WooCommerce Admin

" > contributors.md', + 'echo "

WooCommerce Admin

" > contributors.html', 'echo "Generating contributor list for WC Admin since <%= fromDate %>"', './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-admin --fromDate <%= fromDate %>' + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', - 'echo "

WooCommerce Blocks

" >> contributors.md', + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', + 'echo "

WooCommerce Blocks

" >> contributors.html', 'echo "Generating contributor list for WC Blocks since <%= fromDate %>"', './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-gutenberg-products-block' + ' --fromDate <%= fromDate %> --authToken <%= authToken %> --cols 6 --sortBy contributions --format html' + - ' --sortOrder desc --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', - 'echo "

Action Scheduler

" >> contributors.md', + ' --sortOrder desc --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', + 'echo "

Action Scheduler

" >> contributors.html', 'echo "Generating contributor list for Action Scheduler since <%= fromDate %>"', './node_modules/.bin/githubcontrib --owner woocommerce --repo action-scheduler --fromDate <%= fromDate %>' + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', - 'echo "

REST API

" >> contributors.md', + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', + 'echo "

REST API

" >> contributors.html', 'echo "Generating contributor list for REST API since <%= fromDate %>"', './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-rest-api --fromDate <%= fromDate %>' + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md', - 'echo "

WooCommerce core

" >> contributors.md', + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', + 'echo "

WooCommerce core

" >> contributors.html', 'echo "Generating contributor list for WC core since <%= fromDate %>"', './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %>' + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.md' + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', + 'echo "Output generated to contributors.html."', ].join('&&') } }, From e64ab46a5261bedead671de4de526423b00a3044 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 11 May 2020 10:12:31 +0200 Subject: [PATCH 034/153] coding standards fix --- Gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index dc30ea6fd2c..19541404aa1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -241,7 +241,7 @@ module.exports = function( grunt ) { ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', 'echo "Output generated to contributors.html."', - ].join('&&') + ].join( '&&' ) } }, From c7a5cb200f06fea7711ef762e0b7edc16f894a23 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 11 May 2020 10:16:30 +0200 Subject: [PATCH 035/153] WC core first --- Gruntfile.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 19541404aa1..a812e5db4d9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -215,7 +215,13 @@ module.exports = function( grunt ) { }, contributors: { command: [ - 'echo "

WooCommerce Admin

" > contributors.html', + 'echo "

WooCommerce core

" > contributors.html', + 'echo "Generating contributor list for WC core since <%= fromDate %>"', + './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %>' + + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', + 'echo "Output generated to contributors.html."', + 'echo "

WooCommerce Admin

" >> contributors.html', 'echo "Generating contributor list for WC Admin since <%= fromDate %>"', './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-admin --fromDate <%= fromDate %>' + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + @@ -235,12 +241,6 @@ module.exports = function( grunt ) { './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-rest-api --fromDate <%= fromDate %>' + ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', - 'echo "

WooCommerce core

" >> contributors.html', - 'echo "Generating contributor list for WC core since <%= fromDate %>"', - './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %>' + - ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', - 'echo "Output generated to contributors.html."', ].join( '&&' ) } }, From 4480637015c573eda393fbc9fcd7ea0c51fade14 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 11 May 2020 10:20:14 +0200 Subject: [PATCH 036/153] Add the contributors.html to gitignore. Leaving the contributors.md there, as the contributors file was previously generated as .md and might still be around in some directories, etc. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9b99f73835d..8c055716d85 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ tests/cli/vendor # Composer /vendor/ contributors.md +contributors.html # Packages /packages/* From 80eb5ae931e9a04cc43bc91bd8066f875d7b4c03 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 11 May 2020 11:00:42 +0200 Subject: [PATCH 037/153] Moved the contributors script from Grunt to bash. --- Gruntfile.js | 56 --------------------------------------------- bin/contributors.sh | 32 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 56 deletions(-) create mode 100755 bin/contributors.sh diff --git a/Gruntfile.js b/Gruntfile.js index a812e5db4d9..141134fccc1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -213,56 +213,6 @@ module.exports = function( grunt ) { e2e_tests_grep: { command: 'npm run --silent test:grep "' + grunt.option( 'grep' ) + '"' }, - contributors: { - command: [ - 'echo "

WooCommerce core

" > contributors.html', - 'echo "Generating contributor list for WC core since <%= fromDate %>"', - './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce --fromDate <%= fromDate %>' + - ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', - 'echo "Output generated to contributors.html."', - 'echo "

WooCommerce Admin

" >> contributors.html', - 'echo "Generating contributor list for WC Admin since <%= fromDate %>"', - './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-admin --fromDate <%= fromDate %>' + - ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', - 'echo "

WooCommerce Blocks

" >> contributors.html', - 'echo "Generating contributor list for WC Blocks since <%= fromDate %>"', - './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-gutenberg-products-block' + - ' --fromDate <%= fromDate %> --authToken <%= authToken %> --cols 6 --sortBy contributions --format html' + - ' --sortOrder desc --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', - 'echo "

Action Scheduler

" >> contributors.html', - 'echo "Generating contributor list for Action Scheduler since <%= fromDate %>"', - './node_modules/.bin/githubcontrib --owner woocommerce --repo action-scheduler --fromDate <%= fromDate %>' + - ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', - 'echo "

REST API

" >> contributors.html', - 'echo "Generating contributor list for REST API since <%= fromDate %>"', - './node_modules/.bin/githubcontrib --owner woocommerce --repo woocommerce-rest-api --fromDate <%= fromDate %>' + - ' --authToken <%= authToken %> --cols 6 --sortBy contributions --format html --sortOrder desc' + - ' --showlogin true --filter "renovate-bot,apps/renovate,renovate,renovate[bot]" >> contributors.html', - ].join( '&&' ) - } - }, - - prompt: { - contributors: { - options: { - questions: [ - { - config: 'fromDate', - type: 'input', - message: 'What date (YYYY-MM-DD) should we get contributions since? (i.e. date of previous release)' - }, - { - config: 'authToken', - type: 'input', - message: 'Provide a personal access token (you must).' + - ' This will allow 5000 requests per hour rather than 60 - use if nothing is generated.' - } - ] - } - } }, // PHP Code Sniffer. @@ -312,7 +262,6 @@ module.exports = function( grunt ) { grunt.loadNpmTasks( 'grunt-contrib-copy' ); grunt.loadNpmTasks( 'grunt-contrib-watch' ); grunt.loadNpmTasks( 'grunt-contrib-clean' ); - grunt.loadNpmTasks( 'grunt-prompt' ); // Register tasks. grunt.registerTask( 'default', [ @@ -346,11 +295,6 @@ module.exports = function( grunt ) { 'css' ]); - grunt.registerTask( 'contributors', [ - 'prompt:contributors', - 'shell:contributors' - ]); - // Only an alias to 'default' task. grunt.registerTask( 'dev', [ 'default' diff --git a/bin/contributors.sh b/bin/contributors.sh new file mode 100755 index 00000000000..821fd834c90 --- /dev/null +++ b/bin/contributors.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +read -p 'What date (YYYY-MM-DD) should we get contributions since? (i.e. date of previous release): ' from_date +read -sp 'Provide a personal access token (you must): ' auth_token + +ignored_users="renovate-bot,apps/renovate,renovate,renovate[bot]" +output_file="contributors.html" +common_arguments="--owner woocommerce --fromDate $from_date --authToken $auth_token --cols 6 --sortBy contributions --format html --sortOrder desc --showlogin true --filter $ignored_users" + +echo "" + +echo "

WooCommerce core

" > $output_file +echo "Generating contributor list for WC core since $from_date" +./node_modules/.bin/githubcontrib --repo woocommerce $common_arguments >> $output_file + +echo "

WooCommerce Admin

" >> $output_file +echo "Generating contributor list for WC Admin since $from_date" +./node_modules/.bin/githubcontrib --repo woocommerce-admin $common_arguments >> $output_file + +echo "

WooCommerce Blocks

" >> $output_file +echo "Generating contributor list for WC Blocks since $from_date" +./node_modules/.bin/githubcontrib --repo woocommerce-gutenberg-products-block $common_arguments >> $output_file + +echo "

Action Scheduler

" >> $output_file +echo "Generating contributor list for Action Scheduler since $from_date" +./node_modules/.bin/githubcontrib --repo action-scheduler $common_arguments >> $output_file + +echo "

REST API

" >> $output_file +echo "Generating contributor list for REST API since $from_date" +./node_modules/.bin/githubcontrib --repo woocommerce-rest-api $common_arguments >> $output_file + +echo "Output generated to $output_file." From b7294df2d587d96deb90b316f247e3345494527e Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 11 May 2020 11:02:08 +0200 Subject: [PATCH 038/153] Removed the old way to run e2e tests. --- Gruntfile.js | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 141134fccc1..d831b5da2b2 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -198,23 +198,6 @@ module.exports = function( grunt ) { } }, - // Exec shell commands. - shell: { - options: { - stdout: true, - stderr: true - }, - e2e_test: { - command: 'npm run --silent test:single tests/e2e-tests/' + grunt.option( 'file' ) - }, - e2e_tests: { - command: 'npm run --silent test' - }, - e2e_tests_grep: { - command: 'npm run --silent test:grep "' + grunt.option( 'grep' ) + '"' - }, - }, - // PHP Code Sniffer. phpcs: { options: { @@ -250,7 +233,6 @@ module.exports = function( grunt ) { // Load NPM tasks to be used here. grunt.loadNpmTasks( 'grunt-sass' ); - grunt.loadNpmTasks( 'grunt-shell' ); grunt.loadNpmTasks( 'grunt-phpcs' ); grunt.loadNpmTasks( 'grunt-rtlcss' ); grunt.loadNpmTasks( 'grunt-postcss' ); @@ -299,16 +281,4 @@ module.exports = function( grunt ) { grunt.registerTask( 'dev', [ 'default' ]); - - grunt.registerTask( 'e2e-tests', [ - 'shell:e2e_tests' - ]); - - grunt.registerTask( 'e2e-tests-grep', [ - 'shell:e2e_tests_grep' - ]); - - grunt.registerTask( 'e2e-test', [ - 'shell:e2e_test' - ]); }; From 7ddd2aa3873a0d17b73baf66a1fe58f1959c6f83 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 11 May 2020 13:52:57 +0200 Subject: [PATCH 039/153] Removed grunt-prompt and grunt-shell packages. --- package-lock.json | 223 ---------------------------------------------- package.json | 2 - 2 files changed, 225 deletions(-) diff --git a/package-lock.json b/package-lock.json index 382e2bf58d0..71dc34b7ba4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8092,12 +8092,6 @@ "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, - "exit-hook": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", - "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", - "dev": true - }, "expand-brackets": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", @@ -9996,161 +9990,6 @@ } } }, - "grunt-prompt": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/grunt-prompt/-/grunt-prompt-1.3.3.tgz", - "integrity": "sha1-xbQ77DqimqaWKsZhGolnEvy6Z5E=", - "dev": true, - "requires": { - "inquirer": "^0.11.0", - "lodash": "^3.10.1" - }, - "dependencies": { - "ansi-escapes": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", - "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", - "dev": true - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "cli-cursor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", - "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", - "dev": true, - "requires": { - "restore-cursor": "^1.0.1" - } - }, - "cli-width": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-1.1.1.tgz", - "integrity": "sha1-pNKT72frt7iNSk1CwMzwDE0eNm0=", - "dev": true - }, - "figures": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", - "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5", - "object-assign": "^4.1.0" - } - }, - "inquirer": { - "version": "0.11.4", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.11.4.tgz", - "integrity": "sha1-geM3ToNhvq/y2XAWIG01nQsy+k0=", - "dev": true, - "requires": { - "ansi-escapes": "^1.1.0", - "ansi-regex": "^2.0.0", - "chalk": "^1.0.0", - "cli-cursor": "^1.0.1", - "cli-width": "^1.0.1", - "figures": "^1.3.5", - "lodash": "^3.3.1", - "readline2": "^1.0.1", - "run-async": "^0.1.0", - "rx-lite": "^3.1.2", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.0", - "through": "^2.3.6" - } - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", - "dev": true - }, - "onetime": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", - "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", - "dev": true - }, - "restore-cursor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", - "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", - "dev": true, - "requires": { - "exit-hook": "^1.0.0", - "onetime": "^1.0.0" - } - }, - "run-async": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", - "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", - "dev": true, - "requires": { - "once": "^1.3.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, "grunt-rtlcss": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/grunt-rtlcss/-/grunt-rtlcss-2.0.2.tgz", @@ -10209,34 +10048,6 @@ "integrity": "sha512-90s27H7FoCDcA8C8+R0GwC+ntYD3lG6S/jqcavWm3bn9RiJTmSfOvfbFa1PXx4NbBWuiGQMLfQTj/JvvqT5w6A==", "dev": true }, - "grunt-shell": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/grunt-shell/-/grunt-shell-3.0.1.tgz", - "integrity": "sha512-C8eR4frw/NmIFIwSvzSLS4wOQBUzC+z6QhrKPzwt/tlaIqlzH35i/O2MggVOBj2Sh1tbaAqpASWxGiGsi4JMIQ==", - "dev": true, - "requires": { - "chalk": "^2.4.1", - "npm-run-path": "^2.0.0", - "strip-ansi": "^5.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", - "dev": true - }, - "strip-ansi": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", - "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", - "dev": true, - "requires": { - "ansi-regex": "^4.1.0" - } - } - } - }, "grunt-stylelint": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/grunt-stylelint/-/grunt-stylelint-0.14.0.tgz", @@ -17452,34 +17263,6 @@ } } }, - "readline2": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", - "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "mute-stream": "0.0.5" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "mute-stream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", - "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", - "dev": true - } - } - }, "realpath-native": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/realpath-native/-/realpath-native-1.1.0.tgz", @@ -18017,12 +17800,6 @@ "integrity": "sha1-pfE/957zt0D+MKqAP7CfmIBdR4I=", "dev": true }, - "rx-lite": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", - "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", - "dev": true - }, "rxjs": { "version": "6.5.3", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.5.3.tgz", diff --git a/package.json b/package.json index d39aab8703b..26a29b49bbc 100644 --- a/package.json +++ b/package.json @@ -47,10 +47,8 @@ "grunt-contrib-watch": "1.1.0", "grunt-phpcs": "0.4.0", "grunt-postcss": "0.9.0", - "grunt-prompt": "1.3.3", "grunt-rtlcss": "2.0.2", "grunt-sass": "3.1.0", - "grunt-shell": "3.0.1", "grunt-stylelint": "0.14.0", "gruntify-eslint": "5.0.0", "husky": "4.2.5", From 1d99c343e7cd6efc2a02713ce8c6cef741e7e550 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Tue, 12 May 2020 15:36:25 -0300 Subject: [PATCH 040/153] Added unit tests --- tests/legacy/unit-tests/admin/settings.php | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/legacy/unit-tests/admin/settings.php diff --git a/tests/legacy/unit-tests/admin/settings.php b/tests/legacy/unit-tests/admin/settings.php new file mode 100644 index 00000000000..585d996e14e --- /dev/null +++ b/tests/legacy/unit-tests/admin/settings.php @@ -0,0 +1,35 @@ +assertEquals( 'deny from all', $file_content ); + + // Test with "redirect" downloads method. + update_option( 'woocommerce_file_download_method', 'redirect' ); + WC_Admin_Settings::check_download_folder_protection(); + $file_content = @file_get_contents( $file_path ); + $this->assertEquals( 'Options -Indexes', $file_content ); + + update_option( 'woocommerce_file_download_method', $default ); + } +} From 9d711a6afa3b1adf2824989bd1052bae1b85f370 Mon Sep 17 00:00:00 2001 From: Sergey Ratushnuy Date: Thu, 26 Dec 2019 12:02:47 +0200 Subject: [PATCH 041/153] Add filters for status_widget_stock_rows queries --- includes/admin/class-wc-admin-dashboard.php | 73 ++++++++++++++------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/includes/admin/class-wc-admin-dashboard.php b/includes/admin/class-wc-admin-dashboard.php index 33621090e1d..28fd096e164 100644 --- a/includes/admin/class-wc-admin-dashboard.php +++ b/includes/admin/class-wc-admin-dashboard.php @@ -214,36 +214,61 @@ if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) : $lowinstock_count = get_transient( $transient_name ); if ( false === $lowinstock_count ) { - $lowinstock_count = (int) $wpdb->get_var( - $wpdb->prepare( - "SELECT COUNT( product_id ) - FROM {$wpdb->wc_product_meta_lookup} AS lookup - INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID - WHERE stock_quantity <= %d - AND stock_quantity > %d - AND posts.post_status = 'publish'", - $stock, - $nostock - ) - ); - set_transient( $transient_name, $lowinstock_count, DAY_IN_SECONDS * 30 ); + /** + * Status widget low in stock count pre query. + * + * @since 5.3 + * @param null|string $low_in_stock_count Low in stock count, by default null. + * @param int $stock Low stock amount. + * @param int $nostock No stock amount + */ + $lowinstock_count = apply_filters( 'woocommerce_status_widget_low_in_stock_count_pre_query', null, $stock, $nostock ); + + if ( ! is_null( $lowinstock_count ) ) { + $lowinstock_count = $wpdb->get_var( + $wpdb->prepare( + "SELECT COUNT( product_id ) + FROM {$wpdb->wc_product_meta_lookup} AS lookup + INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID + WHERE stock_quantity <= %d + AND stock_quantity > %d + AND posts.post_status = 'publish'", + $stock, + $nostock + ) + ); + } + + set_transient( $transient_name, (int) $lowinstock_count, DAY_IN_SECONDS * 30 ); } $transient_name = 'wc_outofstock_count'; $outofstock_count = get_transient( $transient_name ); if ( false === $outofstock_count ) { - $outofstock_count = (int) $wpdb->get_var( - $wpdb->prepare( - "SELECT COUNT( product_id ) - FROM {$wpdb->wc_product_meta_lookup} AS lookup - INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID - WHERE stock_quantity <= %d - AND posts.post_status = 'publish'", - $nostock - ) - ); - set_transient( $transient_name, $outofstock_count, DAY_IN_SECONDS * 30 ); + /** + * Status widget out of stock count pre query. + * + * @since 5.3 + * @param null|string $outofstock_count Out of stock count, by default null. + * @param int $nostock No stock amount + */ + $outofstock_count = apply_filters( 'woocommerce_status_widget_out_of_stock_count_pre_query', null, $nostock ); + + if ( ! is_null( $outofstock_count ) ) { + $outofstock_count = (int) $wpdb->get_var( + $wpdb->prepare( + "SELECT COUNT( product_id ) + FROM {$wpdb->wc_product_meta_lookup} AS lookup + INNER JOIN {$wpdb->posts} as posts ON lookup.product_id = posts.ID + WHERE stock_quantity <= %d + AND posts.post_status = 'publish'", + $nostock + ) + ); + } + + set_transient( $transient_name, (int) $outofstock_count, DAY_IN_SECONDS * 30 ); } ?>
  • From 07087c79a7302bd4cb6b9e9d2849be4ee678e77a Mon Sep 17 00:00:00 2001 From: Joshua Flowers Date: Wed, 13 May 2020 16:49:54 +0300 Subject: [PATCH 042/153] Always show tracks function in footer --- includes/tracks/class-wc-site-tracking.php | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/includes/tracks/class-wc-site-tracking.php b/includes/tracks/class-wc-site-tracking.php index 82697a05791..781e78e9a12 100644 --- a/includes/tracks/class-wc-site-tracking.php +++ b/includes/tracks/class-wc-site-tracking.php @@ -82,29 +82,15 @@ class WC_Site_Tracking { - - Date: Wed, 13 May 2020 16:53:57 +0300 Subject: [PATCH 043/153] Add property to check if wcTracks is enabled --- includes/tracks/class-wc-site-tracking.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/tracks/class-wc-site-tracking.php b/includes/tracks/class-wc-site-tracking.php index 781e78e9a12..84c45a62aad 100644 --- a/includes/tracks/class-wc-site-tracking.php +++ b/includes/tracks/class-wc-site-tracking.php @@ -65,7 +65,12 @@ class WC_Site_Tracking { + Date: Thu, 14 May 2020 22:26:13 -0600 Subject: [PATCH 045/153] Give plugins an entry point into the VariationForm object --- assets/js/frontend/add-to-cart-variation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/frontend/add-to-cart-variation.js b/assets/js/frontend/add-to-cart-variation.js index 9c0a7b77e5e..49b9085e75f 100644 --- a/assets/js/frontend/add-to-cart-variation.js +++ b/assets/js/frontend/add-to-cart-variation.js @@ -43,7 +43,7 @@ // Init after gallery. setTimeout( function() { $form.trigger( 'check_variations' ); - $form.trigger( 'wc_variation_form' ); + $form.trigger( 'wc_variation_form', self ); self.loading = false; }, 100 ); }; From d1672ff42e776aa8df0777309faa1744688339a6 Mon Sep 17 00:00:00 2001 From: Kathy Daring Date: Thu, 14 May 2020 22:27:40 -0600 Subject: [PATCH 046/153] optionally accept a custom array of chosen attributes. This will make it easier for "Swatches" and "Radio" input plugins to interact with the variations script without replacing the entire thing. --- assets/js/frontend/add-to-cart-variation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/frontend/add-to-cart-variation.js b/assets/js/frontend/add-to-cart-variation.js index 49b9085e75f..e9541a1691b 100644 --- a/assets/js/frontend/add-to-cart-variation.js +++ b/assets/js/frontend/add-to-cart-variation.js @@ -160,9 +160,9 @@ /** * Looks for matching variations for current selected attributes. */ - VariationForm.prototype.onFindVariation = function( event ) { + VariationForm.prototype.onFindVariation = function( event, chosenAttributes ) { var form = event.data.variationForm, - attributes = form.getChosenAttributes(), + attributes = 'undefined' !== typeof chosenAttributes ? chosenAttributes : form.getChosenAttributes(), currentAttributes = attributes.data; if ( attributes.count === attributes.chosenCount ) { From cecfee4f57e757e01c395df70a44e95785ecc1d7 Mon Sep 17 00:00:00 2001 From: Kathy Daring Date: Thu, 14 May 2020 22:28:39 -0600 Subject: [PATCH 047/153] to account for + $comment_form['comment_field'] = '
  • ');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var o=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){o.$search.attr("aria-owns",n),o.$search.trigger("focus")}),i.on("close",function(){o.$search.val(""),o.$search.removeAttr("aria-activedescendant"),o.$search.removeAttr("aria-owns"),o.$search.trigger("focus")}),i.on("enable",function(){o.$search.prop("disabled",!1),o._transferTabIndex()}),i.on("disable",function(){o.$search.prop("disabled",!0)}),i.on("focus",function(e){o.$search.trigger("focus")}),i.on("results:focus",function(e){o.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){o.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){o._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===o.$search.val()){var t=o.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,o){var s=this;this.current(function(e){var t=null!=e?e.length:0;0=s.maximumSelectionLength?s.trigger("results:message",{message:"maximumSelected",args:{maximum:s.maximumSelectionLength}}):n.call(s,i,o)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(s,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=s('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,o=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){s(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",o),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var o=t[i];this.placeholder.id===o.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(o){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=o.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=o.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=o('
  • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,o=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),o||(o=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,o="resize.select2."+t.id,s="orientationchange.select2."+t.id,r=this.$container.parents().filter(a.hasScroll);r.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),r.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+o+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,o="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+o)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,o=this.$container.offset();o.bottom=o.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=o.top,s.bottom=o.top+s.height;var r=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ao.bottom+r,d={left:o.left,top:s.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=s.top-h.top-r),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function o(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("select2/compat/utils",["jquery"],function(r){return{syncCssClasses:function a(e,t,n){var i,o,s=[];(i=r.trim(e.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0===this.indexOf("select2-")&&s.push(this)}),(i=r.trim(t.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&null!=(o=n(this))&&s.push(o)}),e.attr("class",s.join(" "))}}}),e.define("select2/compat/containerCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("containerCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptContainerCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("containerCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/dropdownCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("dropdownCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptDropdownCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("dropdownCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/initSelection",["jquery"],function(i){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=n.get("initSelection"),this._isInitialized=!1,e.call(this,t,n)}return e.prototype.current=function(e,t){var n=this;this._isInitialized?e.call(this,t):this.initSelection.call(null,this.$element,function(e){n._isInitialized=!0,i.isArray(e)||(e=[e]),t(e)})},e}),e.define("select2/compat/inputData",["jquery"],function(r){function e(e,t,n){this._currentData=[],this._valueSeparator=n.get("valueSeparator")||",","hidden"===t.prop("type")&&n.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var o=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){o.$search.attr("aria-owns",n),o.$search.trigger("focus")}),i.on("close",function(){o.$search.val(""),o.$search.removeAttr("aria-activedescendant"),o.$search.removeAttr("aria-owns"),o.$search.trigger("focus")}),i.on("enable",function(){o.$search.prop("disabled",!1),o._transferTabIndex()}),i.on("disable",function(){o.$search.prop("disabled",!0)}),i.on("focus",function(e){o.$search.trigger("focus")}),i.on("results:focus",function(e){o.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){o.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){o._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===o.$search.val()){var t=o.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,o){var s=this;this.current(function(e){var t=null!=e?e.length:0;0=s.maximumSelectionLength?s.trigger("results:message",{message:"maximumSelected",args:{maximum:s.maximumSelectionLength}}):n.call(s,i,o)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(s,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=s('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,o=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){s(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",o),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var o=t[i];this.placeholder.id===o.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(o){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=o.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=o.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=o('
  • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,o=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),o||(o=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,o="resize.select2."+t.id,s="orientationchange.select2."+t.id,r=this.$container.parents().filter(a.hasScroll);r.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),r.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+o+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,o="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+o)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,o=this.$container.offset();o.bottom=o.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=o.top,s.bottom=o.top+s.height;var r=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ao.bottom+r,d={left:o.left,top:s.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=s.top-h.top-r),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function o(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("select2/compat/utils",["jquery"],function(r){return{syncCssClasses:function a(e,t,n){var i,o,s=[];(i=r.trim(e.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0===this.indexOf("select2-")&&s.push(this)}),(i=r.trim(t.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&null!=(o=n(this))&&s.push(o)}),e.attr("class",s.join(" "))}}}),e.define("select2/compat/containerCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("containerCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptContainerCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("containerCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/dropdownCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("dropdownCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptDropdownCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("dropdownCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/initSelection",["jquery"],function(i){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=n.get("initSelection"),this._isInitialized=!1,e.call(this,t,n)}return e.prototype.current=function(e,t){var n=this;this._isInitialized?e.call(this,t):this.initSelection.call(null,this.$element,function(e){n._isInitialized=!0,i.isArray(e)||(e=[e]),t(e)})},e}),e.define("select2/compat/inputData",["jquery"],function(r){function e(e,t,n){this._currentData=[],this._valueSeparator=n.get("valueSeparator")||",","hidden"===t.prop("type")&&n.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var r=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){r.$search.attr("aria-owns",n),r.$search.trigger("focus")}),i.on("close",function(){r.$search.val(""),r.$search.removeAttr("aria-activedescendant"),r.$search.removeAttr("aria-owns"),r.$search.trigger("focus")}),i.on("enable",function(){r.$search.prop("disabled",!1),r._transferTabIndex()}),i.on("disable",function(){r.$search.prop("disabled",!0)}),i.on("focus",function(e){r.$search.trigger("focus")}),i.on("results:focus",function(e){r.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){r.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){r._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===r.$search.val()){var t=r.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,r){var o=this;this.current(function(e){var t=null!=e?e.length:0;0=o.maximumSelectionLength?o.trigger("results:message",{message:"maximumSelected",args:{maximum:o.maximumSelectionLength}}):n.call(o,i,r)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(o,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=o('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,r=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){o(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",r),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var r=t[i];this.placeholder.id===r.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(r){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=r.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=r.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=r('
  • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,r=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),r||(r=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,r="resize.select2."+t.id,o="orientationchange.select2."+t.id,s=this.$container.parents().filter(a.hasScroll);s.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),s.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+r+" "+o,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,r="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+r)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,r=this.$container.offset();r.bottom=r.top+this.$container.outerHeight(!1);var o={height:this.$container.outerHeight(!1)};o.top=r.top,o.bottom=r.top+o.height;var s=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ar.bottom+s,d={left:r.left,top:o.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=o.top-h.top-s),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function r(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(r,e,o,t){if(null==r.fn.selectWoo){var s=["open","close","destroy"];r.fn.selectWoo=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=r.extend(!0,{},t);new o(r(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=r(this).data("select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,i)}),-1":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},e.entityDecode=function(e){var t=document.createElement("textarea");return t.innerHTML=e,t.value},e.appendMany=function(e,t){if("1.7"===o.fn.jquery.substr(0,3)){var n=o();o.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},e.isTouchscreen=function(){return"undefined"==typeof e._isTouchscreenCache&&(e._isTouchscreenCache="ontouchstart"in document.documentElement),e._isTouchscreenCache},e}),e.define("select2/results",["jquery","./utils"],function(h,e){function i(e,t,n){this.$element=e,this.data=n,this.options=t,i.__super__.constructor.call(this)}return e.Extend(i,e.Observable),i.prototype.render=function(){var e=h('
      ');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},i.prototype.clear=function(){this.$results.empty()},i.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=h(''),i=this.options.get("translations").get(e.message);n.append(t(i(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},i.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},i.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n",{"class":"select2-results__options select2-results__options--nested",role:"listbox"});p.append(l),o.attr("role","list"),o.append(s),o.append(p)}else this.template(e,t);return h.data(t,"data",e),t},i.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=e.data("data");"true"==e.attr("data-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[data-selected]"),n=t.index(e);if(0!==n){var i=n-1;0===e.length&&(i=0);var r=t.eq(i);r.trigger("mouseenter");var o=l.$results.offset().top,s=r.offset().top,a=l.$results.scrollTop()+(s-o);0===i?l.$results.scrollTop(0):s-o<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[data-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var i=t.eq(n);i.trigger("mouseenter");var r=l.$results.offset().top+l.$results.outerHeight(!1),o=i.offset().top+i.outerHeight(!1),s=l.$results.scrollTop()+o-r;0===n?l.$results.scrollTop(0):rthis.$results.outerHeight()||o<0)&&this.$results.scrollTop(r)}},i.prototype.template=function(e,t){var n=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),r=n(e,t);null==r?t.style.display="none":"string"==typeof r?t.innerHTML=i(r):h(t).append(r)},i}),e.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("select2/selection/base",["jquery","../utils","../keys"],function(i,e,r){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=i('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),this.$selection=e},n.prototype.bind=function(e,t){var n=this,i=(e.id,e.id+"-results");this.options.get("minimumResultsForSearch"),Infinity;this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===r.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",i),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),window.setTimeout(function(){n.$selection.focus()},1),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex)}),e.on("disable",function(){n.$selection.attr("tabindex","-1")})},n.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||i.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},n.prototype._attachCloseHandler=function(e){i(document.body).on("mousedown.select2."+e.id,function(e){var t=i(e.target),n=t.closest(".select2");i(".select2.select2-container--open").each(function(){var e=i(this);this!=n[0]&&(e.data("element").select2("close"),setTimeout(function(){e.find("*:focus").blur(),t.focus()},1))})})},n.prototype._detachCloseHandler=function(e){i(document.body).off("mousedown.select2."+e.id)},n.prototype.position=function(e,t){t.find(".selection").append(e)},n.prototype.destroy=function(){this._detachCloseHandler(this.container)},n.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},n}),e.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,r,n){function o(){o.__super__.constructor.apply(this,arguments)}return r.Extend(o,t),o.prototype.render=function(){var e=o.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html(''),e},o.prototype.bind=function(t,e){var n=this;o.__super__.bind.apply(this,arguments);var i=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",i).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",i),this.$selection.attr("role","combobox"),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.focus()}),t.on("selection:update",function(e){n.update(e.data)})},o.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},o.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},o.prototype.selectionContainer=function(){return e("")},o.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2-selection__rendered"),i=r.entityDecode(this.display(t,n));n.empty().text(i),n.prop("title",t.title||t.text)}else this.clear()},o}),e.define("select2/selection/multiple",["jquery","./base","../utils"],function(i,e,a){function r(e,t){r.__super__.constructor.apply(this,arguments)}return a.Extend(r,e),r.prototype.render=function(){var e=r.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('
        '),e},r.prototype.bind=function(t,e){var n=this;r.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){if(!n.options.get("disabled")){var t=i(this).parent().data("data");n.trigger("unselect",{originalEvent:e,data:t})}}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),t.on("focus",function(){n.focusOnSearch()})},r.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return i('
      • ')},r.prototype.focusOnSearch=function(){var e=this;"undefined"!=typeof e.$search&&setTimeout(function(){e._keyUpPrevented=!0,e.$search.focus()},1)},r.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n×');n.data("data",t),this.$selection.find(".select2-selection__rendered").prepend(n)}},e}),e.define("select2/selection/search",["jquery","../utils","../keys"],function(i,e,a){function t(e,t,n){e.call(this,t,n)}return t.prototype.render=function(e){var t=i('');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var r=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){r.$search.attr("aria-owns",n),r.$search.trigger("focus")}),i.on("close",function(){r.$search.val(""),r.$search.removeAttr("aria-activedescendant"),r.$search.removeAttr("aria-owns"),r.$search.trigger("focus")}),i.on("enable",function(){r.$search.prop("disabled",!1),r._transferTabIndex()}),i.on("disable",function(){r.$search.prop("disabled",!0)}),i.on("focus",function(e){r.$search.trigger("focus")}),i.on("results:focus",function(e){r.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){r.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){r._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===r.$search.val()){var t=r.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,r){var o=this;this.current(function(e){var t=null!=e?e.length:0;0=o.maximumSelectionLength?o.trigger("results:message",{message:"maximumSelected",args:{maximum:o.maximumSelectionLength}}):n.call(o,i,r)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(o,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=o('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,r=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){o(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",r),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var r=t[i];this.placeholder.id===r.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(r){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=r.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=r.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=r('
      • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,r=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),r||(r=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,r="resize.select2."+t.id,o="orientationchange.select2."+t.id,s=this.$container.parents().filter(a.hasScroll);s.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),s.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+r+" "+o,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,r="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+r)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,r=this.$container.offset();r.bottom=r.top+this.$container.outerHeight(!1);var o={height:this.$container.outerHeight(!1)};o.top=r.top,o.bottom=r.top+o.height;var s=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ar.bottom+s,d={left:r.left,top:o.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=o.top-h.top-s),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function r(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(r,e,o,t){if(null==r.fn.selectWoo){var s=["open","close","destroy"];r.fn.selectWoo=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=r.extend(!0,{},t);new o(r(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=r(this).data("select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,i)}),-1 get_description_html( $data ); // WPCS: XSS ok. ?> @@ -761,11 +761,11 @@ abstract class WC_Settings_API { $option_value_inner ) : ?> - + - + diff --git a/includes/admin/list-tables/class-wc-admin-list-table-products.php b/includes/admin/list-tables/class-wc-admin-list-table-products.php index f864efa4e4d..8ac403273d5 100644 --- a/includes/admin/list-tables/class-wc-admin-list-table-products.php +++ b/includes/admin/list-tables/class-wc-admin-list-table-products.php @@ -351,7 +351,7 @@ class WC_Admin_List_Table_Products extends WC_Admin_List_Table { */ protected function render_products_type_filter() { $current_product_type = isset( $_REQUEST['product_type'] ) ? wc_clean( wp_unslash( $_REQUEST['product_type'] ) ) : false; // WPCS: input var ok, sanitization ok. - $output = ''; foreach ( wc_get_product_types() as $value => $label ) { $output .= ''; $output .= ''; } } diff --git a/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php b/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php index 243e6d1411c..c8b92d10e2a 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php @@ -194,7 +194,7 @@ class WC_Meta_Box_Coupon_Data { foreach ( $product_ids as $product_id ) { $product = wc_get_product( $product_id ); if ( is_object( $product ) ) { - echo ''; + echo ''; } } ?> @@ -212,7 +212,7 @@ class WC_Meta_Box_Coupon_Data { foreach ( $product_ids as $product_id ) { $product = wc_get_product( $product_id ); if ( is_object( $product ) ) { - echo ''; + echo ''; } } ?> diff --git a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php index 62d929b2670..f5568ddb2d1 100644 --- a/includes/admin/meta-boxes/class-wc-meta-box-order-data.php +++ b/includes/admin/meta-boxes/class-wc-meta-box-order-data.php @@ -404,9 +404,9 @@ class WC_Meta_Box_Order_Data { } if ( ! $found_method && ! empty( $payment_method ) ) { - echo ''; + echo ''; } else { - echo ''; + echo ''; } ?> diff --git a/includes/admin/meta-boxes/views/html-product-attribute.php b/includes/admin/meta-boxes/views/html-product-attribute.php index d4a7910f2b1..2b987fce19d 100644 --- a/includes/admin/meta-boxes/views/html-product-attribute.php +++ b/includes/admin/meta-boxes/views/html-product-attribute.php @@ -49,7 +49,7 @@ if ( ! defined( 'ABSPATH' ) ) { foreach ( $all_terms as $term ) { $options = $attribute->get_options(); $options = ! empty( $options ) ? $options : array(); - echo ''; + echo ''; } } ?> diff --git a/includes/admin/meta-boxes/views/html-product-data-linked-products.php b/includes/admin/meta-boxes/views/html-product-data-linked-products.php index dfbdd2d17d2..2a7a0938db9 100644 --- a/includes/admin/meta-boxes/views/html-product-data-linked-products.php +++ b/includes/admin/meta-boxes/views/html-product-data-linked-products.php @@ -19,7 +19,7 @@ defined( 'ABSPATH' ) || exit; foreach ( $product_ids as $product_id ) { $product = wc_get_product( $product_id ); if ( is_object( $product ) ) { - echo ''; + echo ''; } } ?> @@ -37,7 +37,7 @@ defined( 'ABSPATH' ) || exit; foreach ( $product_ids as $product_id ) { $product = wc_get_product( $product_id ); if ( is_object( $product ) ) { - echo ''; + echo ''; } } ?> @@ -53,7 +53,7 @@ defined( 'ABSPATH' ) || exit; foreach ( $product_ids as $product_id ) { $product = wc_get_product( $product_id ); if ( is_object( $product ) ) { - echo ''; + echo ''; } } ?> diff --git a/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php b/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php index 4512a0adb41..8bc70e58312 100644 --- a/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php +++ b/includes/admin/settings/views/html-admin-page-shipping-zone-methods.php @@ -189,7 +189,7 @@ if ( ! defined( 'ABSPATH' ) ) { if ( ! $method->supports( 'shipping-zones' ) ) { continue; } - echo ''; + echo ''; } ?> @@ -54,7 +54,7 @@ if ( ! defined( 'ABSPATH' ) ) { '4' => __( 'Set to regular price decreased by (fixed amount or %):', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -78,7 +78,7 @@ if ( ! defined( 'ABSPATH' ) ) { 'none' => _x( 'None', 'Tax status', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -104,7 +104,7 @@ if ( ! defined( 'ABSPATH' ) ) { } foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -124,7 +124,7 @@ if ( ! defined( 'ABSPATH' ) ) { '1' => __( 'Change to:', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -148,7 +148,7 @@ if ( ! defined( 'ABSPATH' ) ) { '1' => __( 'Change to:', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -170,7 +170,7 @@ if ( ! defined( 'ABSPATH' ) ) { $value ) { - echo ''; + echo ''; } ?> @@ -190,7 +190,7 @@ if ( ! defined( 'ABSPATH' ) ) { 'hidden' => __( 'Hidden', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -207,7 +207,7 @@ if ( ! defined( 'ABSPATH' ) ) { 'no' => __( 'No', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -222,7 +222,7 @@ if ( ! defined( 'ABSPATH' ) ) { echo ''; foreach ( wc_get_product_stock_status_options() as $key => $value ) { - echo ''; + echo ''; } ?> @@ -241,7 +241,7 @@ if ( ! defined( 'ABSPATH' ) ) { 'no' => __( 'No', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -261,7 +261,7 @@ if ( ! defined( 'ABSPATH' ) ) { '3' => __( 'Decrease existing stock by:', 'woocommerce' ), ); foreach ( $options as $key => $value ) { - echo ''; + echo ''; } ?> @@ -280,7 +280,7 @@ if ( ! defined( 'ABSPATH' ) ) { echo ''; foreach ( wc_get_product_backorder_options() as $key => $value ) { - echo ''; + echo ''; } ?> diff --git a/includes/class-wc-countries.php b/includes/class-wc-countries.php index 405a0d26cc7..7c0bb934c7c 100644 --- a/includes/class-wc-countries.php +++ b/includes/class-wc-countries.php @@ -474,7 +474,7 @@ class WC_Countries { echo ' selected="selected"'; } - echo '>' . esc_html( $value ) . ' — ' . ( $escape ? esc_js( $state_value ) : $state_value ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo '>' . esc_html( $value ) . ' — ' . ( $escape ? esc_html( $state_value ) : $state_value ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } echo ''; @@ -483,7 +483,7 @@ class WC_Countries { if ( $selected_country === $key && '*' === $selected_state ) { echo ' selected="selected"'; } - echo ' value="' . esc_attr( $key ) . '">' . ( $escape ? esc_js( $value ) : $value ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + echo ' value="' . esc_attr( $key ) . '">' . ( $escape ? esc_html( $value ) : $value ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } diff --git a/includes/wc-cart-functions.php b/includes/wc-cart-functions.php index a6f2755d675..b9f05304c04 100644 --- a/includes/wc-cart-functions.php +++ b/includes/wc-cart-functions.php @@ -318,8 +318,13 @@ function wc_cart_totals_order_total_html() { $taxable_address = WC()->customer->get_taxable_address(); /* translators: %s: country name */ $estimated_text = WC()->customer->is_customer_outside_base() && ! WC()->customer->has_calculated_shipping() ? sprintf( ' ' . __( 'estimated for %s', 'woocommerce' ), WC()->countries->estimated_for_prefix( $taxable_address[0] ) . WC()->countries->countries[ $taxable_address[0] ] ) : ''; - /* translators: %s: tax information */ - $value .= '' . sprintf( __( '(includes %s)', 'woocommerce' ), implode( ', ', $tax_string_array ) . $estimated_text ) . ''; + $value .= '(' + /* translators: includes tax information */ + . esc_html__( 'includes', 'woocommerce' ) + . ' ' + . wp_kses_post( implode( ', ', $tax_string_array ) ) + . esc_html( $estimated_text ) + . ')'; } } diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 6238647ef8c..18f5947bd72 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -2706,7 +2706,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) { $field = ''; @@ -2733,7 +2733,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) { '; foreach ( $states as $ckey => $cvalue ) { - $field .= ''; + $field .= ''; } $field .= ''; @@ -2782,7 +2782,7 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) { } $custom_attributes[] = 'data-allow_clear="true"'; } - $options .= ''; + $options .= ''; } $field .= ''; - $field .= ''; + $field .= ''; } } From 40f7c2d474e242440b2fb9a886353f5a8772a210 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Tue, 16 Jun 2020 17:22:10 +0200 Subject: [PATCH 151/153] Update min files and selectWoo, coding standards. --- assets/js/selectWoo/selectWoo.full.js | 2 +- assets/js/selectWoo/selectWoo.full.min.js | 2 +- assets/js/selectWoo/selectWoo.js | 2 +- assets/js/selectWoo/selectWoo.min.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/js/selectWoo/selectWoo.full.js b/assets/js/selectWoo/selectWoo.full.js index 979d0db5d46..e29e8f9f90a 100644 --- a/assets/js/selectWoo/selectWoo.full.js +++ b/assets/js/selectWoo/selectWoo.full.js @@ -1792,7 +1792,7 @@ S2.define('select2/selection/placeholder',[ Placeholder.prototype.createPlaceholder = function (decorated, placeholder) { var $placeholder = this.selectionContainer(); - $placeholder.html(this.display(placeholder)); + $placeholder.text(Utils.entityDecode(this.display(placeholder))); $placeholder.addClass('select2-selection__placeholder') .removeClass('select2-selection__choice'); diff --git a/assets/js/selectWoo/selectWoo.full.min.js b/assets/js/selectWoo/selectWoo.full.min.js index 39ccc58cafe..80e0b925426 100644 --- a/assets/js/selectWoo/selectWoo.full.min.js +++ b/assets/js/selectWoo/selectWoo.full.min.js @@ -5,7 +5,7 @@ * Released under the MIT license * https://github.com/woocommerce/selectWoo/blob/master/LICENSE.md */ -!function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(e,t){return t===undefined&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),n(t),t}:n(jQuery)}(function(d){var e=function(){if(d&&d.fn&&d.fn.select2&&d.fn.select2.amd)var e=d.fn.select2.amd;var t,n,i,h,s,r,f,g,m,v,y,w,o,a,_,l;function b(e,t){return o.call(e,t)}function c(e,t){var n,i,o,s,r,a,l,c,u,d,p,h=t&&t.split("/"),f=y.map,g=f&&f["*"]||{};if(e){for(r=(e=e.split("/")).length-1,y.nodeIdCompat&&_.test(e[r])&&(e[r]=e[r].replace(_,"")),"."===e[0].charAt(0)&&h&&(e=h.slice(0,h.length-1).concat(e)),u=0;u":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},e.entityDecode=function(e){var t=document.createElement("textarea");return t.innerHTML=e,t.value},e.appendMany=function(e,t){if("1.7"===s.fn.jquery.substr(0,3)){var n=s();s.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},e.isTouchscreen=function(){return"undefined"==typeof e._isTouchscreenCache&&(e._isTouchscreenCache="ontouchstart"in document.documentElement),e._isTouchscreenCache},e}),e.define("select2/results",["jquery","./utils"],function(h,e){function i(e,t,n){this.$element=e,this.data=n,this.options=t,i.__super__.constructor.call(this)}return e.Extend(i,e.Observable),i.prototype.render=function(){var e=h('
          ');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},i.prototype.clear=function(){this.$results.empty()},i.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=h(''),i=this.options.get("translations").get(e.message);n.append(t(i(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},i.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},i.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n",{"class":"select2-results__options select2-results__options--nested",role:"listbox"});p.append(l),s.attr("role","list"),s.append(r),s.append(p)}else this.template(e,t);return h.data(t,"data",e),t},i.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=e.data("data");"true"==e.attr("data-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[data-selected]"),n=t.index(e);if(0!==n){var i=n-1;0===e.length&&(i=0);var o=t.eq(i);o.trigger("mouseenter");var s=l.$results.offset().top,r=o.offset().top,a=l.$results.scrollTop()+(r-s);0===i?l.$results.scrollTop(0):r-s<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[data-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var i=t.eq(n);i.trigger("mouseenter");var o=l.$results.offset().top+l.$results.outerHeight(!1),s=i.offset().top+i.outerHeight(!1),r=l.$results.scrollTop()+s-o;0===n?l.$results.scrollTop(0):othis.$results.outerHeight()||s<0)&&this.$results.scrollTop(o)}},i.prototype.template=function(e,t){var n=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),o=n(e,t);null==o?t.style.display="none":"string"==typeof o?t.innerHTML=i(o):h(t).append(o)},i}),e.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("select2/selection/base",["jquery","../utils","../keys"],function(i,e,o){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=i('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),this.$selection=e},n.prototype.bind=function(e,t){var n=this,i=(e.id,e.id+"-results");this.options.get("minimumResultsForSearch"),Infinity;this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===o.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",i),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),window.setTimeout(function(){n.$selection.focus()},1),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex)}),e.on("disable",function(){n.$selection.attr("tabindex","-1")})},n.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||i.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},n.prototype._attachCloseHandler=function(e){i(document.body).on("mousedown.select2."+e.id,function(e){var t=i(e.target),n=t.closest(".select2");i(".select2.select2-container--open").each(function(){var e=i(this);this!=n[0]&&(e.data("element").select2("close"),setTimeout(function(){e.find("*:focus").blur(),t.focus()},1))})})},n.prototype._detachCloseHandler=function(e){i(document.body).off("mousedown.select2."+e.id)},n.prototype.position=function(e,t){t.find(".selection").append(e)},n.prototype.destroy=function(){this._detachCloseHandler(this.container)},n.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},n}),e.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,o,n){function s(){s.__super__.constructor.apply(this,arguments)}return o.Extend(s,t),s.prototype.render=function(){var e=s.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html(''),e},s.prototype.bind=function(t,e){var n=this;s.__super__.bind.apply(this,arguments);var i=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",i).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",i),this.$selection.attr("role","combobox"),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.focus()}),t.on("selection:update",function(e){n.update(e.data)})},s.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},s.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},s.prototype.selectionContainer=function(){return e("")},s.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2-selection__rendered"),i=o.entityDecode(this.display(t,n));n.empty().text(i),n.prop("title",t.title||t.text)}else this.clear()},s}),e.define("select2/selection/multiple",["jquery","./base","../utils"],function(i,e,a){function o(e,t){o.__super__.constructor.apply(this,arguments)}return a.Extend(o,e),o.prototype.render=function(){var e=o.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('
            '),e},o.prototype.bind=function(t,e){var n=this;o.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){if(!n.options.get("disabled")){var t=i(this).parent().data("data");n.trigger("unselect",{originalEvent:e,data:t})}}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),t.on("focus",function(){n.focusOnSearch()})},o.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},o.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},o.prototype.selectionContainer=function(){return i('
          • ')},o.prototype.focusOnSearch=function(){var e=this;"undefined"!=typeof e.$search&&setTimeout(function(){e._keyUpPrevented=!0,e.$search.focus()},1)},o.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n×');n.data("data",t),this.$selection.find(".select2-selection__rendered").prepend(n)}},e}),e.define("select2/selection/search",["jquery","../utils","../keys"],function(i,e,a){function t(e,t,n){e.call(this,t,n)}return t.prototype.render=function(e){var t=i('');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var o=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){o.$search.attr("aria-owns",n),o.$search.trigger("focus")}),i.on("close",function(){o.$search.val(""),o.$search.removeAttr("aria-activedescendant"),o.$search.removeAttr("aria-owns"),o.$search.trigger("focus")}),i.on("enable",function(){o.$search.prop("disabled",!1),o._transferTabIndex()}),i.on("disable",function(){o.$search.prop("disabled",!0)}),i.on("focus",function(e){o.$search.trigger("focus")}),i.on("results:focus",function(e){o.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){o.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){o._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===o.$search.val()){var t=o.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,o){var s=this;this.current(function(e){var t=null!=e?e.length:0;0=s.maximumSelectionLength?s.trigger("results:message",{message:"maximumSelected",args:{maximum:s.maximumSelectionLength}}):n.call(s,i,o)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(s,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=s('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,o=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){s(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",o),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var o=t[i];this.placeholder.id===o.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(o){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=o.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=o.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=o('
          • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,o=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),o||(o=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,o="resize.select2."+t.id,s="orientationchange.select2."+t.id,r=this.$container.parents().filter(a.hasScroll);r.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),r.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+o+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,o="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+o)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,o=this.$container.offset();o.bottom=o.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=o.top,s.bottom=o.top+s.height;var r=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ao.bottom+r,d={left:o.left,top:s.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=s.top-h.top-r),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function o(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("select2/compat/utils",["jquery"],function(r){return{syncCssClasses:function a(e,t,n){var i,o,s=[];(i=r.trim(e.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0===this.indexOf("select2-")&&s.push(this)}),(i=r.trim(t.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&null!=(o=n(this))&&s.push(o)}),e.attr("class",s.join(" "))}}}),e.define("select2/compat/containerCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("containerCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptContainerCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("containerCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/dropdownCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("dropdownCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptDropdownCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("dropdownCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/initSelection",["jquery"],function(i){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=n.get("initSelection"),this._isInitialized=!1,e.call(this,t,n)}return e.prototype.current=function(e,t){var n=this;this._isInitialized?e.call(this,t):this.initSelection.call(null,this.$element,function(e){n._isInitialized=!0,i.isArray(e)||(e=[e]),t(e)})},e}),e.define("select2/compat/inputData",["jquery"],function(r){function e(e,t,n){this._currentData=[],this._valueSeparator=n.get("valueSeparator")||",","hidden"===t.prop("type")&&n.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var o=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){o.$search.attr("aria-owns",n),o.$search.trigger("focus")}),i.on("close",function(){o.$search.val(""),o.$search.removeAttr("aria-activedescendant"),o.$search.removeAttr("aria-owns"),o.$search.trigger("focus")}),i.on("enable",function(){o.$search.prop("disabled",!1),o._transferTabIndex()}),i.on("disable",function(){o.$search.prop("disabled",!0)}),i.on("focus",function(e){o.$search.trigger("focus")}),i.on("results:focus",function(e){o.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){o.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){o._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),o.trigger("keypress",e),o._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===o.$search.val()){var t=o.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,o){var s=this;this.current(function(e){var t=null!=e?e.length:0;0=s.maximumSelectionLength?s.trigger("results:message",{message:"maximumSelected",args:{maximum:s.maximumSelectionLength}}):n.call(s,i,o)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(s,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=s('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,o=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){s(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",o),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var o=t[i];this.placeholder.id===o.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(o){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=o.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=o.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=o('
          • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,o=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),o||(o=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,o="resize.select2."+t.id,s="orientationchange.select2."+t.id,r=this.$container.parents().filter(a.hasScroll);r.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),r.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+o+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,o="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+o)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,o=this.$container.offset();o.bottom=o.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=o.top,s.bottom=o.top+s.height;var r=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ao.bottom+r,d={left:o.left,top:s.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=s.top-h.top-r),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function o(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("select2/compat/utils",["jquery"],function(r){return{syncCssClasses:function a(e,t,n){var i,o,s=[];(i=r.trim(e.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0===this.indexOf("select2-")&&s.push(this)}),(i=r.trim(t.attr("class")))&&r((i=""+i).split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&null!=(o=n(this))&&s.push(o)}),e.attr("class",s.join(" "))}}}),e.define("select2/compat/containerCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("containerCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptContainerCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("containerCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/dropdownCss",["jquery","./utils"],function(r,a){function l(e){return null}function e(){}return e.prototype.render=function(e){var t=e.call(this),n=this.options.get("dropdownCssClass")||"";r.isFunction(n)&&(n=n(this.$element));var i=this.options.get("adaptDropdownCssClass");if(i=i||l,-1!==n.indexOf(":all:")){n=n.replace(":all:","");var o=i;i=function(e){var t=o(e);return null!=t?t+" "+e:e}}var s=this.options.get("dropdownCss")||{};return r.isFunction(s)&&(s=s(this.$element)),a.syncCssClasses(t,this.$element,i),t.css(s),t.addClass(n),t},e}),e.define("select2/compat/initSelection",["jquery"],function(i){function e(e,t,n){n.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=n.get("initSelection"),this._isInitialized=!1,e.call(this,t,n)}return e.prototype.current=function(e,t){var n=this;this._isInitialized?e.call(this,t):this.initSelection.call(null,this.$element,function(e){n._isInitialized=!0,i.isArray(e)||(e=[e]),t(e)})},e}),e.define("select2/compat/inputData",["jquery"],function(r){function e(e,t,n){this._currentData=[],this._valueSeparator=n.get("valueSeparator")||",","hidden"===t.prop("type")&&n.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var r=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){r.$search.attr("aria-owns",n),r.$search.trigger("focus")}),i.on("close",function(){r.$search.val(""),r.$search.removeAttr("aria-activedescendant"),r.$search.removeAttr("aria-owns"),r.$search.trigger("focus")}),i.on("enable",function(){r.$search.prop("disabled",!1),r._transferTabIndex()}),i.on("disable",function(){r.$search.prop("disabled",!0)}),i.on("focus",function(e){r.$search.trigger("focus")}),i.on("results:focus",function(e){r.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){r.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){r._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===r.$search.val()){var t=r.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,r){var o=this;this.current(function(e){var t=null!=e?e.length:0;0=o.maximumSelectionLength?o.trigger("results:message",{message:"maximumSelected",args:{maximum:o.maximumSelectionLength}}):n.call(o,i,r)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(o,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=o('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,r=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){o(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",r),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var r=t[i];this.placeholder.id===r.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(r){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=r.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=r.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=r('
          • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,r=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),r||(r=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,r="resize.select2."+t.id,o="orientationchange.select2."+t.id,s=this.$container.parents().filter(a.hasScroll);s.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),s.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+r+" "+o,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,r="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+r)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,r=this.$container.offset();r.bottom=r.top+this.$container.outerHeight(!1);var o={height:this.$container.outerHeight(!1)};o.top=r.top,o.bottom=r.top+o.height;var s=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ar.bottom+s,d={left:r.left,top:o.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=o.top-h.top-s),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function r(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(r,e,o,t){if(null==r.fn.selectWoo){var s=["open","close","destroy"];r.fn.selectWoo=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=r.extend(!0,{},t);new o(r(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=r(this).data("select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,i)}),-1":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},e.entityDecode=function(e){var t=document.createElement("textarea");return t.innerHTML=e,t.value},e.appendMany=function(e,t){if("1.7"===o.fn.jquery.substr(0,3)){var n=o();o.map(t,function(e){n=n.add(e)}),t=n}e.append(t)},e.isTouchscreen=function(){return"undefined"==typeof e._isTouchscreenCache&&(e._isTouchscreenCache="ontouchstart"in document.documentElement),e._isTouchscreenCache},e}),e.define("select2/results",["jquery","./utils"],function(h,e){function i(e,t,n){this.$element=e,this.data=n,this.options=t,i.__super__.constructor.call(this)}return e.Extend(i,e.Observable),i.prototype.render=function(){var e=h('
              ');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},i.prototype.clear=function(){this.$results.empty()},i.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=h(''),i=this.options.get("translations").get(e.message);n.append(t(i(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},i.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},i.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n",{"class":"select2-results__options select2-results__options--nested",role:"listbox"});p.append(l),o.attr("role","list"),o.append(s),o.append(p)}else this.template(e,t);return h.data(t,"data",e),t},i.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=e.data("data");"true"==e.attr("data-selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find("[data-selected]"),n=t.index(e);if(0!==n){var i=n-1;0===e.length&&(i=0);var r=t.eq(i);r.trigger("mouseenter");var o=l.$results.offset().top,s=r.offset().top,a=l.$results.scrollTop()+(s-o);0===i?l.$results.scrollTop(0):s-o<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find("[data-selected]"),n=t.index(e)+1;if(!(n>=t.length)){var i=t.eq(n);i.trigger("mouseenter");var r=l.$results.offset().top+l.$results.outerHeight(!1),o=i.offset().top+i.outerHeight(!1),s=l.$results.scrollTop()+o-r;0===n?l.$results.scrollTop(0):rthis.$results.outerHeight()||o<0)&&this.$results.scrollTop(r)}},i.prototype.template=function(e,t){var n=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),r=n(e,t);null==r?t.style.display="none":"string"==typeof r?t.innerHTML=i(r):h(t).append(r)},i}),e.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("select2/selection/base",["jquery","../utils","../keys"],function(i,e,r){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=i('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),this.$selection=e},n.prototype.bind=function(e,t){var n=this,i=(e.id,e.id+"-results");this.options.get("minimumResultsForSearch"),Infinity;this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===r.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",i),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),window.setTimeout(function(){n.$selection.focus()},1),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex)}),e.on("disable",function(){n.$selection.attr("tabindex","-1")})},n.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||i.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},n.prototype._attachCloseHandler=function(e){i(document.body).on("mousedown.select2."+e.id,function(e){var t=i(e.target),n=t.closest(".select2");i(".select2.select2-container--open").each(function(){var e=i(this);this!=n[0]&&(e.data("element").select2("close"),setTimeout(function(){e.find("*:focus").blur(),t.focus()},1))})})},n.prototype._detachCloseHandler=function(e){i(document.body).off("mousedown.select2."+e.id)},n.prototype.position=function(e,t){t.find(".selection").append(e)},n.prototype.destroy=function(){this._detachCloseHandler(this.container)},n.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},n}),e.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,r,n){function o(){o.__super__.constructor.apply(this,arguments)}return r.Extend(o,t),o.prototype.render=function(){var e=o.__super__.render.call(this);return e.addClass("select2-selection--single"),e.html(''),e},o.prototype.bind=function(t,e){var n=this;o.__super__.bind.apply(this,arguments);var i=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",i).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",i),this.$selection.attr("role","combobox"),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.focus()}),t.on("selection:update",function(e){n.update(e.data)})},o.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},o.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},o.prototype.selectionContainer=function(){return e("")},o.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2-selection__rendered"),i=r.entityDecode(this.display(t,n));n.empty().text(i),n.prop("title",t.title||t.text)}else this.clear()},o}),e.define("select2/selection/multiple",["jquery","./base","../utils"],function(i,e,a){function r(e,t){r.__super__.constructor.apply(this,arguments)}return a.Extend(r,e),r.prototype.render=function(){var e=r.__super__.render.call(this);return e.addClass("select2-selection--multiple"),e.html('
                '),e},r.prototype.bind=function(t,e){var n=this;r.__super__.bind.apply(this,arguments),this.$selection.on("click",function(e){n.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){if(!n.options.get("disabled")){var t=i(this).parent().data("data");n.trigger("unselect",{originalEvent:e,data:t})}}),this.$selection.on("keydown",function(e){!t.isOpen()&&48<=e.which&&e.which<=90&&t.open()}),t.on("focus",function(){n.focusOnSearch()})},r.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return i('
              • ')},r.prototype.focusOnSearch=function(){var e=this;"undefined"!=typeof e.$search&&setTimeout(function(){e._keyUpPrevented=!0,e.$search.focus()},1)},r.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=0;n×');n.data("data",t),this.$selection.find(".select2-selection__rendered").prepend(n)}},e}),e.define("select2/selection/search",["jquery","../utils","../keys"],function(i,e,a){function t(e,t,n){e.call(this,t,n)}return t.prototype.render=function(e){var t=i('');this.$searchContainer=t,this.$search=t.find("input");var n=e.call(this);return this._transferTabIndex(),n},t.prototype.bind=function(e,i,t){var r=this,n=i.id+"-results";e.call(this,i,t),i.on("open",function(){r.$search.attr("aria-owns",n),r.$search.trigger("focus")}),i.on("close",function(){r.$search.val(""),r.$search.removeAttr("aria-activedescendant"),r.$search.removeAttr("aria-owns"),r.$search.trigger("focus")}),i.on("enable",function(){r.$search.prop("disabled",!1),r._transferTabIndex()}),i.on("disable",function(){r.$search.prop("disabled",!0)}),i.on("focus",function(e){r.$search.trigger("focus")}),i.on("results:focus",function(e){r.$search.attr("aria-activedescendant",e.data._resultId)}),this.$selection.on("focusin",".select2-search--inline",function(e){r.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){r._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),r.trigger("keypress",e),r._keyUpPrevented=e.isDefaultPrevented(),e.which===a.BACKSPACE&&""===r.$search.val()){var t=r.$searchContainer.prev(".select2-selection__choice");if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.query=function(n,i,r){var o=this;this.current(function(e){var t=null!=e?e.length:0;0=o.maximumSelectionLength?o.trigger("results:message",{message:"maximumSelected",args:{maximum:o.maximumSelectionLength}}):n.call(o,i,r)})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery","../utils"],function(o,e){function t(){}return t.prototype.render=function(e){var t=e.call(this),n=o('');return this.$searchContainer=n,this.$search=n.find("input"),t.prepend(n),t},t.prototype.bind=function(e,t,n){var i=this,r=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){o(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-owns",r),i.$search.focus(),window.setTimeout(function(){i.$search.focus()},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-activedescendant"),i.$search.removeAttr("aria-owns"),i.$search.val("")}),t.on("focus",function(){t.isOpen()||i.$search.focus()}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer.removeClass("select2-search--hide"):i.$searchContainer.addClass("select2-search--hide"))}),t.on("results:focus",function(e){i.$search.attr("aria-activedescendant",e.data._resultId)})},t.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},t.prototype.showSearch=function(e,t){return!0},t}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var r=t[i];this.placeholder.id===r.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(r){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&this.$results.append(this.$loadingMore)},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",function(){var e=r.contains(document.documentElement,i.$loadingMore[0]);if(!i.loading&&e){var t=i.$results.offset().top+i.$results.outerHeight(!1);i.$loadingMore.offset().top+i.$loadingMore.outerHeight(!1)<=t+50&&i.loadMore()}})},e.prototype.loadMore=function(){this.loading=!0;var e=r.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=r('
              • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=n.get("dropdownParent")||f(document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this,r=!1;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),r||(r=!0,t.on("results:all",function(){i._positionDropdown(),i._resizeDropdown()}),t.on("results:append",function(){i._positionDropdown(),i._resizeDropdown()}))}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t.removeClass("select2"),t.addClass("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,r="resize.select2."+t.id,o="orientationchange.select2."+t.id,s=this.$container.parents().filter(a.hasScroll);s.each(function(){f(this).data("select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),s.on(i,function(e){var t=f(this).data("select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+r+" "+o,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,r="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+r)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown.hasClass("select2-dropdown--above"),n=this.$dropdown.hasClass("select2-dropdown--below"),i=null,r=this.$container.offset();r.bottom=r.top+this.$container.outerHeight(!1);var o={height:this.$container.outerHeight(!1)};o.top=r.top,o.bottom=r.top+o.height;var s=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ar.bottom+s,d={left:r.left,top:o.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h=p.offset();d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=o.top-h.top-s),null!=i&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+i),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=Infinity),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function r(e){for(var t=0,n=0;n');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container.addClass("select2-container--"+this.options.get("theme")),e.data("element",this.$element),e},u}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults"],function(r,e,o,t){if(null==r.fn.selectWoo){var s=["open","close","destroy"];r.fn.selectWoo=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=r.extend(!0,{},t);new o(r(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=r(this).data("select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,i)}),-1 Date: Wed, 17 Jun 2020 17:20:12 -0400 Subject: [PATCH 152/153] Adjust various conditions of the OBW e2e test to make it pass --- tests/e2e/env/config/default.json | 2 +- .../activate-and-setup/setup-wizard.test.js | 22 +++++-------------- tests/e2e/utils/components.js | 8 +++---- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/tests/e2e/env/config/default.json b/tests/e2e/env/config/default.json index 13c4c230c8c..19693eece88 100644 --- a/tests/e2e/env/config/default.json +++ b/tests/e2e/env/config/default.json @@ -27,7 +27,7 @@ "country": "United States (US)", "addressfirstline": "addr 1", "addresssecondline": "addr 2", - "countryandstate": "United States (US) -- California", + "countryandstate": "United States (US) — California", "city": "San Francisco", "state": "CA", "postcode": "94107" diff --git a/tests/e2e/specs/activate-and-setup/setup-wizard.test.js b/tests/e2e/specs/activate-and-setup/setup-wizard.test.js index c8770c7ba66..cb0a8205336 100644 --- a/tests/e2e/specs/activate-and-setup/setup-wizard.test.js +++ b/tests/e2e/specs/activate-and-setup/setup-wizard.test.js @@ -6,20 +6,17 @@ * Internal dependencies */ import { StoreOwnerFlow } from '../../utils/flows'; -import { completeOldSetupWizard, completeOnboardingWizard } from '../../utils/components'; +import { completeOnboardingWizard } from '../../utils/components'; import { permalinkSettingsPageSaveChanges, setCheckbox, settingsPageSaveChanges, verifyCheckboxIsSet, - verifyCheckboxIsUnset, verifyValueOfInputField + verifyValueOfInputField } from '../../utils'; -const config = require( 'config' ); - describe( 'Store owner can login and make sure WooCommerce is activated', () => { - - it( 'can login', async () => { + beforeAll( async () => { await StoreOwnerFlow.login(); } ); @@ -56,25 +53,16 @@ describe( 'Store owner can go through setup Task List', () => { it( 'can setup shipping', async () => { // Query for all tasks on the list const taskListItems = await page.$$( '.woocommerce-list__item-title' ); - expect( taskListItems ).toHaveLength( 5 ); + expect( taskListItems ).toHaveLength( 6 ); await Promise.all( [ // Click on "Set up shipping" task to move to the next step - taskListItems[2].click(), + taskListItems[3].click(), // Wait for shipping setup section to load page.waitForNavigation( { waitUntil: 'networkidle0' } ), ] ); - // Query for store location fields - const storeLocationFields = await page.$$( '.components-text-control__input' ); - expect( storeLocationFields ).toHaveLength( 4 ); - - // Wait for "Continue" button to become active - await page.waitForSelector( 'button.is-primary:not(:disabled)' ); - // Click on "Continue" button to move to the shipping cost section - await page.click( 'button.is-primary' ); - // Wait for "Proceed" button to become active await page.waitForSelector( 'button.is-primary:not(:disabled)' ); await page.waitFor( 3000 ); diff --git a/tests/e2e/utils/components.js b/tests/e2e/utils/components.js index 06a7d4a87f2..37b0e99e080 100644 --- a/tests/e2e/utils/components.js +++ b/tests/e2e/utils/components.js @@ -121,11 +121,11 @@ const completeOnboardingWizard = async () => { } // Wait for "Continue" button to become active - await page.waitForSelector( 'button.woocommerce-profile-wizard__continue:not(:disabled)' ); + await page.waitForSelector( 'button.is-primary:not(:disabled)' ); await Promise.all( [ // Click on "Continue" button to move to the next step - page.click( 'button.woocommerce-profile-wizard__continue' ), + page.click( 'button.is-primary' ), // Wait for "Tell us about your business" section to load page.waitForNavigation( { waitUntil: 'networkidle0' } ), @@ -186,9 +186,9 @@ const completeOnboardingWizard = async () => { await page.waitForSelector( '.woocommerce-profile-wizard__header-title' ); // Wait for "No thanks" button to become active - await page.waitForSelector( 'button.is-default:not(:disabled)' ); + await page.waitForSelector( 'button.is-secondary:not(:disabled)' ); // Click on "No thanks" button to move to the next step - await page.click( 'button.is-default' ); + await page.click( 'button.is-secondary' ); // End of onboarding wizard From bff2cab4c086a15975ebab35aadb64465c4b5ba7 Mon Sep 17 00:00:00 2001 From: IanDelMar <42134098+IanDelMar@users.noreply.github.com> Date: Sun, 21 Jun 2020 13:26:51 +0200 Subject: [PATCH 153/153] Fix typo --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index b1cf9ff03a9..4fbf8bcb07a 100644 --- a/composer.json +++ b/composer.json @@ -86,8 +86,8 @@ "test": "Run unit tests", "phpcs": "Analyze code against the WordPress coding standards with PHP_CodeSniffer", "phpcbf": "Fix coding standards warnings/errors automatically with PHP Code Beautifier", - "makepot-audit": "Generate i18n/langauges/woocommerce.pot file and run audit", - "makepot": "Generate i18n/langauges/woocommerce.pot file" + "makepot-audit": "Generate i18n/languages/woocommerce.pot file and run audit", + "makepot": "Generate i18n/languages/woocommerce.pot file" } } }