From 0d660c630ff6266cd269816dd6eea491929a0a2c Mon Sep 17 00:00:00 2001 From: Giovanni Cascione Date: Tue, 3 May 2022 11:44:44 +0200 Subject: [PATCH 1/4] WC: fix attribute edit page hidden fields --- modules/woo-commerce/qwc-admin.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/woo-commerce/qwc-admin.php b/modules/woo-commerce/qwc-admin.php index 22520943..a016f4d5 100644 --- a/modules/woo-commerce/qwc-admin.php +++ b/modules/woo-commerce/qwc-admin.php @@ -41,9 +41,11 @@ function qtranxf_wc_add_filters_admin() { foreach ( $email_common as $name => $priority ) { add_filter( $name, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage', $priority ); } - + add_filter( 'woocommerce_attribute_taxonomies' , 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage' ); add_filter( 'woocommerce_variation_option_name' , 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage' ); + //TODO: check upstream in QTX core if a cleaner approach can be adopted + add_action( 'woocommerce_after_edit_attribute_fields', function(){echo "";}); } qtranxf_wc_add_filters_admin(); From d3e7688769fd00ec839fd26e2f457f1cc4f4f122 Mon Sep 17 00:00:00 2001 From: Giovanni Cascione Date: Sat, 7 May 2022 20:47:40 +0200 Subject: [PATCH 2/4] revert previous commit and refine QTS hide field test --- modules/slugs/includes/qtranslate-slug-admin.php | 2 +- modules/woo-commerce/qwc-admin.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/slugs/includes/qtranslate-slug-admin.php b/modules/slugs/includes/qtranslate-slug-admin.php index ed580ca0..2c17bb91 100644 --- a/modules/slugs/includes/qtranslate-slug-admin.php +++ b/modules/slugs/includes/qtranslate-slug-admin.php @@ -433,7 +433,7 @@ function qts_hide_term_slug_box() { break; case 'edit.php': // Handle WooCommerce edit product attributes page. - if ( isset( $_GET['page'] ) && $_GET['page'] == 'product_attributes' ) { + if ( isset( $_GET['page'] ) && $_GET['page'] == 'product_attributes' && ! isset( $_GET['edit'] ) ) { $id = 'attribute_name'; // TODO: actual slug column to be added (javascript seems the only way currently). For the time being, possibly overridden slugs column is hidden. $additional_jquery = diff --git a/modules/woo-commerce/qwc-admin.php b/modules/woo-commerce/qwc-admin.php index a016f4d5..8f3c8a27 100644 --- a/modules/woo-commerce/qwc-admin.php +++ b/modules/woo-commerce/qwc-admin.php @@ -44,8 +44,6 @@ function qtranxf_wc_add_filters_admin() { add_filter( 'woocommerce_attribute_taxonomies' , 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage' ); add_filter( 'woocommerce_variation_option_name' , 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage' ); - //TODO: check upstream in QTX core if a cleaner approach can be adopted - add_action( 'woocommerce_after_edit_attribute_fields', function(){echo "";}); } qtranxf_wc_add_filters_admin(); From fd168ee156770038ef577318418f542a657d4a45 Mon Sep 17 00:00:00 2001 From: Giovanni Cascione Date: Sun, 8 May 2022 00:28:08 +0200 Subject: [PATCH 3/4] add support for multilang slugs in WC attribute edit page --- modules/slugs/includes/qtranslate-slug-admin.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/slugs/includes/qtranslate-slug-admin.php b/modules/slugs/includes/qtranslate-slug-admin.php index 2c17bb91..3c0bf83a 100644 --- a/modules/slugs/includes/qtranslate-slug-admin.php +++ b/modules/slugs/includes/qtranslate-slug-admin.php @@ -44,6 +44,7 @@ function qts_taxonomies_hooks() { if ( QTX_Module_Loader::is_module_active( 'woo-commerce' ) ) { add_action( 'woocommerce_after_add_attribute_fields', 'qts_show_add_term_fields' ); + add_action( 'woocommerce_after_edit_attribute_fields', 'qts_show_edit_term_fields' ); } } @@ -433,12 +434,17 @@ function qts_hide_term_slug_box() { break; case 'edit.php': // Handle WooCommerce edit product attributes page. - if ( isset( $_GET['page'] ) && $_GET['page'] == 'product_attributes' && ! isset( $_GET['edit'] ) ) { + if ( isset( $_GET['page'] ) && $_GET['page'] == 'product_attributes' ) { $id = 'attribute_name'; // TODO: actual slug column to be added (javascript seems the only way currently). For the time being, possibly overridden slugs column is hidden. - $additional_jquery = - "$('table tr th:nth-child(2)').hide()" . PHP_EOL . - "$('table tr td:nth-child(2)').hide()" . PHP_EOL; + if ( isset( $_GET['edit'] ) ) { + $additional_jquery = + "$(\"#" . $id . "\").parent().prev(\"th\").hide()" . PHP_EOL; + } else { + $additional_jquery = + "$('table tr th:nth-child(2)').hide()" . PHP_EOL . + "$('table tr td:nth-child(2)').hide()" . PHP_EOL; + } } break; default: From 8784912c8157d9d745f8b3641591f6521173eaa2 Mon Sep 17 00:00:00 2001 From: Herr Vigg Date: Sun, 8 May 2022 00:48:42 +0200 Subject: [PATCH 4/4] Add comments and cleanup obsolete script tags --- modules/slugs/includes/qtranslate-slug-admin.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/slugs/includes/qtranslate-slug-admin.php b/modules/slugs/includes/qtranslate-slug-admin.php index 3c0bf83a..9fd6a5f9 100644 --- a/modules/slugs/includes/qtranslate-slug-admin.php +++ b/modules/slugs/includes/qtranslate-slug-admin.php @@ -435,12 +435,15 @@ function qts_hide_term_slug_box() { case 'edit.php': // Handle WooCommerce edit product attributes page. if ( isset( $_GET['page'] ) && $_GET['page'] == 'product_attributes' ) { + // Hide the regular slug input field. $id = 'attribute_name'; - // TODO: actual slug column to be added (javascript seems the only way currently). For the time being, possibly overridden slugs column is hidden. if ( isset( $_GET['edit'] ) ) { + // Hide the slug header left of the input field. $additional_jquery = "$(\"#" . $id . "\").parent().prev(\"th\").hide()" . PHP_EOL; } else { + // Hide the slug column in the table. + // TODO: actual slug column to be added (javascript seems the only way currently). For the time being, possibly overridden slugs column is hidden. $additional_jquery = "$('table tr th:nth-child(2)').hide()" . PHP_EOL . "$('table tr td:nth-child(2)').hide()" . PHP_EOL; @@ -452,7 +455,7 @@ function qts_hide_term_slug_box() { endswitch; echo "" . PHP_EOL; - echo "