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 8 replies, has 2 voices.
Last updated by Jean-François 3 years, 10 months ago.
Assisted by: Dražen.
Author | Posts |
---|---|
September 23, 2021 at 2:01 pm #9646903 | |
Jean-François |
I have a site with FR as main language and EN as second language (there's also ES but it's inactive). We created two ACF options pages with each language's code as ID ("fr" and "en"). With ACFML 1.9.x installed, the options field values are null in EN. I can't get any options values from either language, but it all work in FR. I have to rollback to 1.8.x to get it working again. |
September 23, 2021 at 2:20 pm #9647053 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+02:00) |
Hello, as mentioned in the chat, please follow suggestions and try to replicate the issue with some dummy example on the sandbox website. - hidden link Let me know how it goes and the steps you take. I will then quickly escalate it to our developer's team for a fix. Thank you and regards, |
September 23, 2021 at 2:41 pm #9647187 | |
Jean-François |
Hi Drazen, Here's what I did to replicate my issue: 1. Activated ACFML 1.9.1 Result: value OK in French, NULL in English. |
September 24, 2021 at 6:12 am #9651671 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+02:00) |
Hello, thank you very much for your time and help with replicating the issue. I've now escalated this issue to our developers team. They are taking a look at the issue and I will update you here as soon as I have some news. Thanks and kind regards, |
September 24, 2021 at 11:16 am #9654029 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+02:00) |
Hello, our developers checked the issue, and find a workaround fix for your case that you can use for now: - go to wp-content/plugins/acfml/classes/class-wpml-acf-options-page.php add condition: && $post_id !== $cl so that the code becomes: public function append_language_code_for_option_pages( $post_id ) { $cl = acf_get_setting('current_language'); if ( is_string( $post_id ) && $post_id != $cl //add this here!!! && ! $this->id_starts_with_options( $post_id ) && ! $this->id_ends_with_language_code( $post_id, $cl ) && ! $this->is_term_id( $post_id ) && ! $this->is_taxonomy_name( $post_id ) && ! $this->is_block_id( $post_id ) && ! $this->id_starts_with_user( $post_id ) ) { $dl = acf_get_setting('default_language'); Since you are using a bit different usage case for ACF options and for showing field value, that is not excepted by default by ACF, it could be a custom code case that we cant support or charactirize as a bug from our side. Our developers are still checking on this. I will let you know when I have more info on this. Let me know if this fix works for you. Thanks, |
September 28, 2021 at 1:13 pm #9677947 | |
Jean-François |
Hi Drazen, Thanks for the code. However, could you explain what you mean by "using a bit different usage case for ACF options and for showing field value, that is not excepted by default by ACF"? From my understanding, I'm only using the language code to separate different language-specific option fields. The ID could be anything it just so happens to be the language code. Further, this was a bug that was introduced by an update on your part that didn't consider that the ID could be the language code... I understand that you don't want to support every edge case there is, but considering the simplicity of the fix, couldn't that be used in the production version? If not, I've found this filter that also fixes my problem and that can be added to my theme without the need to block ACFML updates: add_filter( 'acf/settings/current_language', '__return_false' ); Can you see any problem using this solution that would break something? Thanks! |
September 28, 2021 at 2:09 pm #9678511 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+02:00) |
Hello Jean-François, thanks for getting back. 1) I am sharing our developers explanation, if you have any other doubts or questions let me know and I will check it out with them: Before 1.9 it was possible to translate option pages (by switching language on top menu bar) but only if the options page was registered with standard id 'options' (or without id, then ACF automatically added 'options' id). but if any user wanted to use custom options page id, say 'layout_options' it was not translatable. I assume the user wanted to make it working on his own and this is why he registered options pages this way. With 1.9 we've added support for the last case. Now the user doesn't have to register separate option pages for each language: he should register only one with any page id (but not equal to language code*) and translate by switch the top menu bar. In the code we are checking the last two letters of the page id are equal to the language code and I think here is the conflict: in the case of the options page with id 'en' the last two letters are 'en'. The client could change this to: 'post_id' => $lang["language_code"] . '_foo_or_something', to not have post id ending with language code. For now, we won't be adding any changes from our side or support this user case-reported issues. I hope you will understand and this will be helpful for you. 2) Thanks for sharing your solution, I am sure it would be helpful for other users if they encounter the same problem. Let me check on this with our developers and I will get back to you with an update. Thanks, |
September 29, 2021 at 7:54 am #9683855 | |
Dražen Supporter
Languages: English (English ) Timezone: Europe/Zagreb (GMT+02:00) |
Hello, regarding your question, please find our developers reply: In this version of ACFML it will not break anything, but we can't promise it will not break anything in the future. Although, we don't have plans, for now, to use the current_language set in the ACF plugin (in other words: there is no planned change that would break usage of this filter). Hope it is helpful. Kind regards, |
September 30, 2021 at 12:54 pm #9695869 | |
Jean-François |
Okay, that makes sense. We'll use the filter on our existing site with the language code as options pages ID and add a prefix in the future. Thanks for the detailed answers! |