Open hirasso opened 1 year ago
I was able to fix it using js code.
Consider that your option page urls should start with acf-
functions.php
function qtx_option_fix( $hook ) {
if ( str_contains($hook ,'acf-') ) {
wp_enqueue_script( 'qtx-option-fix', get_stylesheet_directory_uri() . '/js/qtx-option-fix.js', array(), '1.0' );
}
}
add_action( 'admin_enqueue_scripts', 'qtx_option_fix' );
qtx-option-fix.js
$(document).ready(function () {
//set timeout to wait for qTranslate to load
setTimeout(function () {
//get qTranslateX config
var qtx = qTranslateConfig.js.get_qtx();
qtx.addDisplayHookAttrs(document.getElementById('post'), qtx);
qtx.setupLanguageSwitch();
}, 1000);
});
I understand that this is only a temporary solution, but it works for me now.
Because if I add the LSB via qtranslate-config.json, then when saving the repeater type field - I get a fatal error that refers to qtranxf_isMultilingual (Argument #1 ($str) must be of type ?string, array given
)
The initialization sequence became very tricky since jQuery3, see https://github.com/qtranslate/qtranslate-xt/blob/ba0b8797f4a32aed93c6d9047138417edd1cc50b/js/core/index.js#L18C1-L20
// With jQuery3 ready handlers fire asynchronously and may be fired after load.
// See: https://github.com/jquery/jquery/issues/3194
QTX will not create the LSB if there are no display or content hooks defined when the initialize()
function is called. With the ACF options pages I see two situations:
Are you in case 1 or 2?
Are you in case 1 or 2?
Personally, I have the second case.
I'm also in case 2. I have several translatable fields.
Then it's a bug, though I don't manage to reproduce it. But this can depend on the event sequence as mentioned above or coming from recent updates in ACF 6 Pro. What type of fields is it about? The repeater field is broken, see #882.
Because if I add the LSB via qtranslate-config.json, then when saving the repeater type field - I get a fatal error that refers to qtranxf_isMultilingual (Argument #1 ($str) must be of type ?string, array given)
The QTX built-in configuration for ACF is supposed to handle the option page without requiring any change from your side. What did you mean by adding the LSB to the json file?
To help understand the bug - for both of you:
https://<your-site>/wp-admin/admin.php?page=acf-options
JSON.stringify(qTranslateConfig.page_config)
(nothing confidential)Could try again on master
? I pushed another fix for #1342 commit https://github.com/qtranslate/qtranslate-xt/commit/7af9a31050de528112b4439754047aae8285e607. That is setting the LSB at the end from the script for ACF. If it solves the problem I still would like to understand better what is going on so the questions above are valid in any case.
I'm AFK this week, can check it out next week. Thank you so much for looking into it, @herrvigg 🙏
It works with the current master! 🎉
Describe the bug
On ACF options pages, the language switching buttons do not appear
To Reproduce Steps to reproduce the behavior:
Expected behavior The language switching buttons should show up as they do for normal post edit screens
Possibly related
798
Debug info Go to
<YOUR_SITE>/wp-admin/options-general.php?page=qtranslate-xt#troubleshooting
. PressCollect information
button and copy/paste the output below.