Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acf_form: qTranslateConfig is not defined #759

Closed
hirasso opened this issue Nov 19, 2019 · 7 comments
Closed

acf_form: qTranslateConfig is not defined #759

hirasso opened this issue Nov 19, 2019 · 7 comments
Labels
bug Something isn't working, reproducible module: ACF Integration with ACF

Comments

@hirasso
Copy link

hirasso commented Nov 19, 2019

Hi there! I just noticed a small bug: If I use the function acf_form() in my frontend with qtranslate-xt activated, I get this error:

qTranslateConfig is not defined

This is a hotfix, until it's fixed in qtranslate-xt itself:

add_action( 'wp_footer', function() {
  global $q_config;
  ob_start();?>
  <script>
    var qTranslateConfig = <?= json_encode( $q_config ) ?>;
  </script>
  <?php echo ob_get_clean();
}, 999 );
@herrvigg
Copy link
Collaborator

Probably a problem of order in the script loading sequence. You should not use qTranslateConfig until qtranslate is initialized. You need a "on-ready" callback and be sure your script comes after qtranslate.

@herrvigg herrvigg added the plugin: others Concerns integration with other plugins label Nov 23, 2019
@herrvigg
Copy link
Collaborator

herrvigg commented Dec 1, 2019

This looks the same as #764. But i can't reproduce it with ACF free. Are you also using ACF Pro?

@hirasso
Copy link
Author

hirasso commented Dec 6, 2019

Yes, I'm also using ACF Pro. Please note, that this only happens in the frontend for me, when using acf_form() or acf_form_head()
https://www.advancedcustomfields.com/resources/acf_form/
https://www.advancedcustomfields.com/resources/acf_form_head/

@herrvigg
Copy link
Collaborator

I can reproduce with ACF 5.8.7 (Free). It's due to acf_form_head that enables the loading of the client scripts, but there's something wrong with the order and the dependencies.

@herrvigg herrvigg added the bug Something isn't working, reproducible label Feb 18, 2020
herrvigg added a commit that referenced this issue Feb 19, 2020
This ensures the scripts are loaded in the right order, especially when
using acf_form_head() which can lead to a different loading sequence.
@herrvigg
Copy link
Collaborator

@hirasso @cyberfly999 i think i found a solution, i sent a patch on master so you are much welcome to test it. Let me know how it works :)

@herrvigg
Copy link
Collaborator

@hirasso can you check if this solves the problem? I'd like to release the last fixes but i'll wait until you confirm it's fine.

@hirasso
Copy link
Author

hirasso commented Feb 21, 2020

Looks good to me! Thanks a lot!! 👍

@hirasso hirasso closed this as completed Feb 21, 2020
@herrvigg herrvigg added module: ACF Integration with ACF and removed plugin: others Concerns integration with other plugins labels Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working, reproducible module: ACF Integration with ACF
Projects
None yet
Development

No branches or pull requests

2 participants