From db4f768d7105ec238993a6f09dba9b3167def26e Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Tue, 12 Nov 2024 16:17:01 +0200 Subject: [PATCH 1/8] refactor: improve translation handling --- backend/options.php | 2 +- backend/templates/admin-settings.php | 16 +++++++- classes/admin.class.php | 17 +++++--- classes/fields.class.php | 24 +++++++---- classes/form.class.php | 6 ++- classes/frontend-scripts.class.php | 12 +++--- classes/inputs/input.audio.php | 2 +- classes/inputs/input.checkbox.php | 2 +- classes/inputs/input.color.php | 2 +- classes/inputs/input.cropper.php | 2 +- classes/inputs/input.date.php | 19 +++++---- classes/inputs/input.daterange.php | 8 ++-- classes/inputs/input.divider.php | 2 +- classes/inputs/input.email.php | 2 +- classes/inputs/input.file.php | 2 +- classes/inputs/input.hidden.php | 2 +- classes/inputs/input.image.php | 2 +- classes/inputs/input.measure.php | 2 +- classes/inputs/input.number.php | 2 +- classes/inputs/input.palettes.php | 2 +- classes/inputs/input.pricematrix.php | 2 +- classes/inputs/input.quantities.php | 2 +- classes/inputs/input.radio.php | 2 +- classes/inputs/input.section.php | 2 +- classes/inputs/input.select.php | 2 +- classes/inputs/input.text.php | 4 +- classes/inputs/input.textarea.php | 2 +- classes/inputs/input.timezone.php | 2 +- classes/plugin.class.php | 38 +++++++++++++++--- inc/admin.php | 26 ++++++++---- inc/arrays.php | 38 +++++++++++------- inc/files.php | 23 +++++++---- inc/functions.php | 16 +++++--- inc/nmInput.class.php | 40 +++++++++---------- inc/prices.php | 7 ++-- inc/rest.class.php | 15 ++++--- inc/woocommerce.php | 28 +++++++++---- templates/admin/changelog.php | 10 ++++- templates/admin/ppom-fields.php | 13 +++++- templates/frontend/component/form-data.php | 2 +- .../component/quantities/grid-layout.php | 8 +++- .../quantities/horizontal-layout.php | 8 +++- .../component/quantities/vertical-layout.php | 8 +++- templates/frontend/inputs/cropper.php | 4 +- templates/frontend/inputs/divider.php | 10 ++--- templates/frontend/inputs/file.php | 8 +++- templates/frontend/inputs/quantities.php | 12 ++++-- templates/frontend/inputs/text.php | 8 +++- templates/frontend/inputs/timezone.php | 2 +- templates/input/quantities.php | 6 +-- templates/render-fields.php | 5 ++- 51 files changed, 318 insertions(+), 163 deletions(-) diff --git a/backend/options.php b/backend/options.php index f9878f92..38e1e21c 100644 --- a/backend/options.php +++ b/backend/options.php @@ -487,7 +487,7 @@ function ppom_load_pro_options() { 'ppom-enf-btn-class' => array( 'type' => 'text', 'title' => __( 'Button Class', 'woocommerce-product-addon' ), - 'desc' => __( ' Add custom CSS classes to the enquiry form button, separated by commas.', 'woocommerce-product-addon' ), + 'desc' => __( 'Add custom CSS classes to the enquiry form button, separated by commas.', 'woocommerce-product-addon' ), ), 'ppom-enf-btn-text-color' => array( 'type' => 'color', diff --git a/backend/templates/admin-settings.php b/backend/templates/admin-settings.php index 7c15c818..1fcf6e2b 100644 --- a/backend/templates/admin-settings.php +++ b/backend/templates/admin-settings.php @@ -99,7 +99,13 @@ class="nmsf-label ">

- ', esc_url( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), '' ); ?> + ', esc_url( tsdk_translate_link( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ) ), + '' + ); ?>

@@ -142,7 +148,13 @@ class=""

- ', esc_url( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ), '' ); ?> + ', esc_url( tsdk_translate_link( tsdk_utmify( PPOM_UPGRADE_URL, $id ) ) ) ), + '' + ); ?>

diff --git a/classes/admin.class.php b/classes/admin.class.php index c8e99934..aa92c0e3 100644 --- a/classes/admin.class.php +++ b/classes/admin.class.php @@ -150,7 +150,7 @@ function add_menu_pages() { $menu = add_submenu_page( $page ['parent_slug'], - __( $page ['page_title'], 'woocommerce-product-addon' ), + $page ['page_title'], __( 'PPOM Fields', 'woocommerce-product-addon' ), $cap, $page ['slug'], @@ -165,7 +165,7 @@ function add_menu_pages() { $cap = 'ppom_options_page'; // Menu page for roles set by PPOM Permission Settings $menu = add_menu_page( - __( $page ['page_title'], 'woocommerce-product-addon' ), + $page ['page_title'], __( 'PPOM Fields', 'woocommerce-product-addon' ), $cap, $page ['slug'], @@ -270,7 +270,14 @@ function get_products() { $ppom_id = intval( $_GET['ppom_id'] ); $license_status = apply_filters( 'product_ppom_license_status', '' ); $current_saved_value = $this->get_db_field( $ppom_id ); - $pro_multiple_fields = ! ppom_pro_is_installed() || 'valid' !== $license_status ? '
' . sprintf( __( 'Your current plan supports adding one group of fields per product. To add multiple groups to the same product, please %supgrade%s your plan!', 'woocommerce-product-addon' ), '', '' ) . '' : ''; + $pro_multiple_fields = ! ppom_pro_is_installed() || 'valid' !== $license_status + ? '
' . sprintf( + // translators: %1$s: the opening tag for upsell link, %2$s: the closing tag for upsell link. + __( 'Your current plan supports adding one group of fields per product. To add multiple groups to the same product, please %1$supgrade%2$s your plan!', 'woocommerce-product-addon' ), + '', + '' + ) . '' + : ''; $select_products_id_component = ( new \PPOM\Attach\SelectComponent() ) ->set_id( 'attach-to-products' ) ->set_title( __( 'Display on Specific Products', 'woocommerce-product-addon' ) ) @@ -680,10 +687,8 @@ function validate_plugin() { echo '
'; echo '

' . __( 'Provide API key below:', 'woocommerce-product-addon' ) . '

'; - echo '

' . __( 'If you don\'t know your API key, please login into your: Member area', 'woocommerce-product-addon' ) . '

'; - echo '
'; - echo '


'; + echo '


'; wp_nonce_field(); echo '

'; echo '

'; diff --git a/classes/fields.class.php b/classes/fields.class.php index 434b6bf4..00567572 100644 --- a/classes/fields.class.php +++ b/classes/fields.class.php @@ -210,7 +210,7 @@ function render_field_settings() { // new model $html .= '
'; $html .= '
'; - $html .= '

' . sprintf( __( '%s', 'woocommerce-product-addon' ), $field_title ) . '

'; + $html .= '

' . esc_html( $field_title ) . '

'; $html .= '
'; $html .= '
'; @@ -298,11 +298,11 @@ function render_field_meta( $field_meta, $fields_type, $field_index = '', $save_ $html .= '
'; $html .= '
'; - $html .= '