Skip Navigation

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

Problem:
You are using WordPress with the Twenty Twenty-One theme, WPML, and ACF Pro. After translating a page from German to English using the WPML Translation Editor, the 'Navigation' ACF field group remains visible in the editor, regardless of changing its location rule from 'All' to any specific menu location.
Solution:

We recommend modifying a specific file within the ACFML plugin to address this issue. Please follow these steps:

go to: wp-content/plugins/acfml/classes/class-wpml-acf-location-rules.php
In the method: \WPML_ACF_Location_Rules::rule_match_post
Change from:

$match = $this->match_against_operator(
                in_array( (int) $rule['value'], self::get_translation_ids( $options['post_id'] ), true ),
                $rule['operator']
            );
        }

to:

$match = $this->match_against_operator(
                in_array( (int) $rule['value'], array_filter(self::get_translation_ids($options['post_id']), fn($value) => $value !== 0), true ),
                $rule['operator']
            );
        }

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 Shekhar Bhandari 4 months, 2 weeks ago.

Assisted by: Shekhar Bhandari.

Author Posts
August 14, 2024 at 9:54 am

MG

Background of the issue:
I am using a fresh WordPress Installation with the theme Twenty Twenty-One. Plugins: WPML and ACF Pro. I have an ACF field group 'Navigation' with the location rule 'Menu Item' => 'is equal to' => 'All'. I create a new page with a title and click on the plus at English to translate with the WPML Translation Editor from German to English. I leave the translation editor with 'Back' at the top left and return to the German editor.

Symptoms:
The field group 'Navigation' appears below the editor. In ACF, when I change the value item from 'All' to any Menu Location (Primary menu or Secondary menu), the field is still visible. Only if I change it to a specific menu like my 'Mainmenu', the field group disappears in the editor. But back to 'All' or any Menu Location, it is back again.

Questions:
Why is the 'Navigation' field group visible in the editor after using the WPML Translation Editor?

August 14, 2024 at 10:33 am
August 23, 2024 at 2:42 pm #16098898

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

I was able to see the issue while reporting, but strangely the issue is not reproduced anymore, so can you please use this test site and see if the issue exists here:
hidden link

Look forward to your reply.

Thanks

August 26, 2024 at 9:19 am #16103485

MG

Dear Shekhar,

thank you for your patience. I was on vacation the last week.

I can reproduce it on your test site!

The problem only occours, when you choose a page title, which is initially *not* in your translation memory. So create a page with a unique title, save as draft, go to translation manager, go back. The fields are now visible, like in my page "Title – not translated via Memory".

August 26, 2024 at 9:26 am #16103503

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

I have forwarded your request to our 2nd tier team.

August 28, 2024 at 10:02 am #16113938

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello there,

Our 2nd tier checked the issue and suggested the following workarround:

Workaround:
go to: wp-content/plugins/acfml/classes/class-wpml-acf-location-rules.php
In the method: \WPML_ACF_Location_Rules::rule_match_post
Change from:

$match = $this->match_against_operator(
				in_array( (int) $rule['value'], self::get_translation_ids( $options['post_id'] ), true ),
				$rule['operator']
			);
		}

to:

$match = $this->match_against_operator(
				in_array( (int) $rule['value'], array_filter(self::get_translation_ids($options['post_id']), fn($value) => $value !== 0), true ),
				$rule['operator']
			);
		}

and see if it helps.

Thanks

August 28, 2024 at 10:20 am #16114092

MG

Thank you for the suggested workaround. It works!

Can we expect this in the next ACFML release?

August 28, 2024 at 10:34 am #16114199

Shekhar Bhandari
Supporter

Languages: English (English )

Timezone: Asia/Kathmandu (GMT+05:45)

Hello,

The issue is escalated to developers and they will take a look at this soon. I can't exactly tell when the fix will be released as this depends upon various things.

Thanks