Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WC: fix attribute edit page hidden fields #1161

Merged
merged 4 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions modules/slugs/includes/qtranslate-slug-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}

Expand Down Expand Up @@ -434,19 +435,27 @@ 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.
$additional_jquery =
"$('table tr th:nth-child(2)').hide()" . PHP_EOL .
"$('table tr td:nth-child(2)').hide()" . PHP_EOL;
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;
}
}
break;
default:
return;
endswitch;

echo "<!-- QTS remove slug box -->" . PHP_EOL;
echo "<script type=\"text/javascript\" charset=\"utf-8\">" . PHP_EOL;
echo "<script>" . PHP_EOL;
echo " jQuery(document).ready(function($){" . PHP_EOL;
echo " $(\"#" . $id . "\").parent().hide();" . PHP_EOL;
echo " $(\".form-field td #slug\").parent().parent().hide();" . PHP_EOL;
Expand Down Expand Up @@ -569,4 +578,4 @@ function qts_ma_module_updated() {
qts_deactivate();

}
}
}
2 changes: 1 addition & 1 deletion modules/woo-commerce/qwc-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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' );
}
Expand Down