Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
If you're experiencing issues with translating 'options' using the WPBakery widget STM Classic Filter in the Motors theme, particularly with PHP 8 or higher, we have identified a solution.
Solution:
1. Navigate to

wp-content/themes/motors/listings/loop/classified/list/options.php

.
2. Around line 36, modify the existing code from:

foreach ( $middle_infos as $middle_info_key => $middle_info ) :
// WPML Workaround for compsupp-7432
if ( is_array( $middle_info ) && isset( $middle_info['single_name'] ) ) {
    if ( class_exists('Sitepress') ) {
        $textdomain = 'motors';
        $data_single_name = 'Motors - WPML String: ' . $middle_info['single_name'];
          
        if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
            do_action( 'wpml_register_single_string', $textdomain, $data_single_name, $middle_info['single_name'] );
        }   
        // Apply the translation to the string
        $middle_info['single_name'] = apply_filters('wpml_translate_single_string', $middle_info['single_name'] , $textdomain, $data_single_name);
    }
}

3. Visit the page with the issue in the original language to register the string.
4. Go to WPML > String Translation page and translate the new string under the 'motors' textdomain.
IMPORTANT: Please backup your database and website before proceeding.

If this solution resolves your issue, we recommend reporting it to the theme's author so they can potentially include this fix in the theme's source code.

Please note that this solution might be irrelevant if it's outdated or not applicable to your specific case. We highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 6 replies, has 2 voices.

Last updated by sergiyY 4 months ago.

Assisted by: Long Nguyen.

Author Posts
September 13, 2024 at 2:31 am #16173820

sergiyY

Hey Long

Unfortunately, there is still one more issue with 'options' translation on the website. So I need your help with it. I have a clean test version with the latest version of WP + theme + WPML (I just installed it yesterday), so, if needed, I can share you access to demonstrate this issue. Or I can install it once again on your side.

Thank you.

September 13, 2024 at 2:33 am #16173822

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Here is the new ticket. Can you please replicate the issue on a sandbox site? You can access the admin area with this link
hidden link

Then let me know how to replicate the issue and where I can see that.

Looking forward to your reply.
Thanks

September 13, 2024 at 10:19 am #16175043

sergiyY

Thank you.

So I've created a test website. There are 5 options for the item: 3 of them are translated, 2 are not (please see the screenshot attached). Here's the URL: hidden link

Inventory – Sandbox (1).png
September 16, 2024 at 1:38 am #16181086

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

There is a workaround to translate the option item (listing category) when using the WPBakery widget STM Classic Filter, it is similar to the workaround in the previous ticket:

1. Edit the file wp-content/themes/motors/listings/loop/classified/list/options.php
2. Around line 36, replace the code

foreach ( $middle_infos as $middle_info_key => $middle_info ) :

with this one

foreach ( $middle_infos as $middle_info_key => $middle_info ) :
// WPML Workaround for compsupp-7432
if ( class_exists('Sitepress') ) {
    $textdomain = 'motors';
    $data_single_name = 'Motors - WPML String: ' . $middle_info['single_name'];
     
    if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
        do_action( 'wpml_register_single_string', $textdomain, $data_single_name, $middle_info['single_name'] );
    }   
    // Apply the translation to the string
    $middle_info['single_name'] = apply_filters('wpml_translate_single_string', $middle_info['single_name'] , $textdomain, $data_single_name);
}

3. Visit the page with the issue in the original language, this will register the string.
4. Go to WPML > String Translation page and translate the new string (under motors textdomain).
❌ IMPORTANT: Please backup your database and website before proceeding ❌

If it works on your site, please help us report this issue to the theme Motors author so they can include the fix on the theme source code.

Thanks.

September 16, 2024 at 7:19 am #16181587

sergiyY

Hello Long,

Thanks for your reply.

I tried to implement the solution on my test website. Translation on the inventory list was fixed, however, the filters were broken. Please find 2 screenshots: with your workaround and without it.

With workaround.png
Without workaround.png
September 16, 2024 at 8:14 am #16182009

Long Nguyen
Supporter

Languages: English (English )

Timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Hi,

Thank you for your feedback. It happens with PHP 8+, please replace the code in the workaround above with this one

foreach ( $middle_infos as $middle_info_key => $middle_info ) :
// WPML Workaround for compsupp-7432
if ( is_array( $middle_info ) && isset( $middle_info['single_name'] ) ) {
	if ( class_exists('Sitepress') ) {
	    $textdomain = 'motors';
	    $data_single_name = 'Motors - WPML String: ' . $middle_info['single_name'];
	     
	    if ( apply_filters('wpml_default_language', NULL ) == apply_filters( 'wpml_current_language', NULL )) {
	        do_action( 'wpml_register_single_string', $textdomain, $data_single_name, $middle_info['single_name'] );
	    }   
	    // Apply the translation to the string
	    $middle_info['single_name'] = apply_filters('wpml_translate_single_string', $middle_info['single_name'] , $textdomain, $data_single_name);
	}
}

and recheck the issue on the sandbox site also. Thanks.

September 16, 2024 at 12:33 pm #16183893

sergiyY

Thank you, it works now.