Skip Navigation

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

Problem:
If you're checking the translation for the Post "Mand" and notice that the link field is missing in a custom Gutenberg block inside a custom field, this might be due to the way links are handled.
Solution:
We recommend you first make a full backup of your website. Then, you need to modify the PHP code that registers the strings for ACF blocks. Specifically, edit the file

acfml\classes\class-wpml-acf-blocks.php

at line 191. Replace the existing

get_text_type

function with the following code:

private function get_text_type( $text ) {<br />    $type = 'LINE';<br />    if ( is_array( $text ) ) {<br />        $type = 'array';<br />    } elseif ( strip_tags( $text ) !== $text ) {<br />        $type = 'VISUAL';<br />    } elseif ( strpos( $text, "\n" ) !== false ) {<br />        $type = 'AREA';<br />    } else if (preg_match('/^(?:https?):\/\/\S+/i', $text)) {<br />        $type = 'LINK';<br />    }<br />    return $type;<br />}

Additionally, ensure that you mark the link with the "Translate" option as outlined in our documentation: Setting the translation preferences for ACF fields created using PHP code.

If this solution does not apply to your case, or if it seems outdated, 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. Should you need further assistance, please do not hesitate to open a new support ticket at WPML support forum.

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.

Tagged: 

This topic contains 13 replies, has 2 voices.

Last updated by Lucas Vidal de Andrade 3 months, 4 weeks ago.

Assisted by: Lucas Vidal de Andrade.

Author Posts
June 7, 2024 at 2:36 pm

basK-12

Check the translation for the Post "Mand". The link field will be missing for translation. The link is inside a custom gutenberg block, inside a custom field.

June 7, 2024 at 3:26 pm
June 7, 2024 at 5:31 pm #15717583

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

I sent your ticket to our development team, to get a second opinion. As soon as I have feedback from them, I'll let you know.

Thank you,
Lucas Vidal

June 12, 2024 at 9:40 am #15730488

basK-12

Hi,

Is there any progress on the ticket?

June 12, 2024 at 7:43 pm #15733425

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

Thank you for your patience. I just received feedback. It seems that in the following part of the code, the '3' value should be changed to '2', in ''wpml_cf_preferences' => 3':

array(
'key' => 'field_link_obj_chef_card_block',
'label' => 'Button',
'name' => 'block_link_obj',
'type' => 'link',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'return_format' => 'array',
'wpml_cf_preferences' => 3
),
),
),

That's because it's now set as "Copy once". Please make a full website backup before proceeding. Let me know if that solves the issue for you.

June 13, 2024 at 7:02 am #15734337

basK-12

Hi,

Yes we tried to set the value on 2 and 3 but both are not working.
So this seems not to be the problem.

June 13, 2024 at 4:30 pm #15737298

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

It's necessary, after updating the code, that you make a small change in the original content, so the translation update gets triggered. Can you confirm you also have done that after setting the value to '2'?

June 17, 2024 at 7:07 am #15743489

basK-12

Yes we did this, did not work.

June 17, 2024 at 3:03 pm #15746195

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Thank you for sharing. I'm still in touch with our developers, I'll get back to you as soon as I have feedback from them.

June 20, 2024 at 9:10 am #15762345

basK-12

Is there any progress on the ticket?

June 21, 2024 at 2:35 pm #15776177

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thank you for your patience. I got feedback from our developers, but after testing the results, it still misses the functionality you want. I apologize, but we still need more time. We are tweaking the settings to see how it impacts the behavior of the element.

Do you have more details on how the element should work exactly? Will it only be used for internal links or for external as well?

Thanks in advance,
Lucas Vidal

July 1, 2024 at 1:13 pm #15868818

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey,

Thank you for your patience. Our devs still weren't able to get to a solution. Can you please upgrade ACF PRO to the latest version and let me know?

July 10, 2024 at 2:27 pm #15928609

basK-12

Hi, I updated my ACF Pro plugin to the latest version. Make's no difference yet.

July 12, 2024 at 7:06 pm #15944095

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there, there are still some details we are testing internally. I found a similar issue and will test it on a copy of your website. I'll get back to you as soon as I have the results.

July 15, 2024 at 12:37 pm #15954401

Lucas Vidal de Andrade
Supporter

Languages: English (English ) Spanish (Español ) German (Deutsch ) Portuguese (Brazil) (Português )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

I checked further, I found we do not use XML rules for ACF blocks but register the strings using PHP. Please make a full website backup and:

Edit \acfml\classes\class-wpml-acf-blocks.php line 191 and replace

	private function get_text_type( $text ) {
		$type = 'LINE';
		if ( is_array( $text ) ) {
			$type = 'array';
		} elseif ( strip_tags( $text ) !== $text ) {
			$type = 'VISUAL';
		} elseif ( strpos( $text, "\n" ) !== false ) {
			$type = 'AREA';
		}
		return $type;
	}

with:

	private function get_text_type( $text ) {
		$type = 'LINE';
		if ( is_array( $text ) ) {
			$type = 'array';
		} elseif ( strip_tags( $text ) !== $text ) {
			$type = 'VISUAL';
		} elseif ( strpos( $text, "\n" ) !== false ) {
			$type = 'AREA';
		} else if (preg_match('/^(?:https?):\/\/\S+/i', $text)) {
			$type = 'LINK';
		}
		return $type;
	}

Please, also make sure to mark the link with "Translate". Option 2:
https://wpml.org/documentation/related-projects/translate-sites-built-with-acf/setting-the-translation-preferences-for-acf-fields-created-using-php-code/

Let me know.