Hi, I installed your plugin today and it doesn’t seem any…
Hi, I installed your plugin today and it doesn’t seem anything happens after I click finish on the quiz. I get this error in the console: hdq_script.js:2 Uncaught ReferenceError: hdq_local_vars is not defined
. Is there any way I can retrieve the variables? Also, is there any way I can access the database that is holding the data from the questions/quiz? Thanks!
This thread has been imported from harmonicdesign.ca/hd-quiz/
Hi Henry,
this indicates that there is a larger issue going on with your site.
HD Quiz uses a native WordPress function called localize_script
that prints the variables to the footer of your site. The fact that you are getting this error means that something is stopping these variables from either printing or being read.
The most common reason is usually that your theme is missing the wp_footer
call, but since your site is correctly enqueuing the css and js for HD Quiz, the issue must be something else. My best guess is that you have some page cache or asset minification plugin that is errantly stripping the varaible from the page, so that’s the best place to start looking.
I have disabled my WP-Rocket plugin and have checked to make sure that my footer is running wp_footer(). Are there any other areas that may be blocking the variables from being loaded?
Can you send a link? I’ll take a look and see if I can see anything
Thanks for sending.
What I can say with 100% certainty is that the issue is that your site is not printing anything from WordPress’ localize_script
function – so what we need to do is figure out why. In fact, I’m not seeing the HD Quiz JavaScript functions on the site either.
Please reconfirm that your footer has wp_footer();
somewhere in it. The best guess that I have is that there is an issue with your asset combination/minification system.
Can you please disable wp-rocket and any other plugin you have that’s meant to combine or speed up files on your site for that page?
Hey Dylan,
I have confirmed the aforementioned. WP-Rocket has been disabled and wp_footer() is placed before the ending body tag. Please let me know the next course of action.
OK, I can see the files now 🙂
But this is still super weird. Not only am I not seeing the HD Quiz localized vars, but I’m not seeing any localized vars at all on your site.
I have an idea on how to “cheat it” though.
Try adding the following to your theme’s functions.php
file. This will print the vars directly to the page instead of relying on the localize_script
function.
*note: Haven’t tested to confirm this will work, but pretty sure it will
If you are enjoying HD Quiz please leave a review here on the official WordPress.org page. HD Quiz is developed by me, just some dude, and is supported and available for free. It may seem dumb, but truly nothing makes me happier than knowing that people are using and loving HD Quiz and my hard work.
This thread has either been marked as complete or has been automatically closed due to inactivity.