From f6685b88b98dca5d9a1f198698fa43344934399b Mon Sep 17 00:00:00 2001 From: Fernando Marichal Date: Mon, 17 Apr 2023 13:07:32 -0300 Subject: [PATCH] Rename default placeholder in attribute form (#37645) * Rename placeholder # Conflicts: # plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php * Fix input `onblur` * Add changelog --------- Co-authored-by: Fernando Marichal --- ..._rename_default_placeholder_in_attribute_form | 4 ++++ .../client/legacy/js/admin/meta-boxes-product.js | 16 +++++++++++----- .../includes/admin/class-wc-admin-assets.php | 1 + .../meta-boxes/views/html-product-attribute.php | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 plugins/woocommerce/changelog/dev-37158_rename_default_placeholder_in_attribute_form diff --git a/plugins/woocommerce/changelog/dev-37158_rename_default_placeholder_in_attribute_form b/plugins/woocommerce/changelog/dev-37158_rename_default_placeholder_in_attribute_form new file mode 100644 index 00000000000..c500c005a40 --- /dev/null +++ b/plugins/woocommerce/changelog/dev-37158_rename_default_placeholder_in_attribute_form @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Rename the default placeholder in the new attribute form header to New attribute diff --git a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js index 5871dbb05d2..e1f94d45885 100644 --- a/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js +++ b/plugins/woocommerce/client/legacy/js/admin/meta-boxes-product.js @@ -555,13 +555,19 @@ jQuery( function ( $ ) { } ); $( '.product_attributes' ).on( 'blur', 'input.attribute_name', function () { - var text = $( this ).val(); - var attributeName = $( this ) + var $inputElement = $( this ); + var text = $inputElement.val(); + var $attribute = $inputElement .closest( '.woocommerce_attribute' ) .find( 'strong.attribute_name' ); - var isPlaceholder = attributeName.hasClass( 'placeholder' ); - if ( ( isPlaceholder && text ) || ! isPlaceholder ) { - attributeName.removeClass( 'placeholder' ).text( text ); + if ( text === '' ) { + $attribute + .addClass( 'placeholder' ) + .text( + woocommerce_admin_meta_boxes.i18n_attribute_name_placeholder + ); + } else { + $attribute.removeClass( 'placeholder' ).text( text ); } } ); diff --git a/plugins/woocommerce/includes/admin/class-wc-admin-assets.php b/plugins/woocommerce/includes/admin/class-wc-admin-assets.php index 1407dac5a2e..54b6c0f1624 100644 --- a/plugins/woocommerce/includes/admin/class-wc-admin-assets.php +++ b/plugins/woocommerce/includes/admin/class-wc-admin-assets.php @@ -422,6 +422,7 @@ if ( ! class_exists( 'WC_Admin_Assets', false ) ) : 'i18n_delete_note' => __( 'Are you sure you wish to delete this note? This action cannot be undone.', 'woocommerce' ), 'i18n_apply_coupon' => __( 'Enter a coupon code to apply. Discounts are applied to line totals, before taxes.', 'woocommerce' ), 'i18n_add_fee' => __( 'Enter a fixed amount or percentage to apply as a fee.', 'woocommerce' ), + 'i18n_attribute_name_placeholder' => __( 'New attribute', 'woocommerce' ), 'i18n_product_simple_tip' => __( 'Simple – covers the vast majority of any products you may sell. Simple products are shipped and have no options. For example, a book.', 'woocommerce' ), 'i18n_product_grouped_tip' => __( 'Grouped – a collection of related products that can be purchased individually and only consist of simple products. For example, a set of six drinking glasses.', 'woocommerce' ), 'i18n_product_external_tip' => __( 'External or Affiliate – one that you list and describe on your website but is sold elsewhere.', 'woocommerce' ), diff --git a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php index 80587895b71..8fb230e3ce2 100644 --- a/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php +++ b/plugins/woocommerce/includes/admin/meta-boxes/views/html-product-attribute.php @@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
- get_name() !== '' ? wc_attribute_label( $attribute->get_name() ) : __( 'Custom attribute', 'woocommerce' ) ); ?> + get_name() !== '' ? wc_attribute_label( $attribute->get_name() ) : __( 'New attribute', 'woocommerce' ) ); ?>