I have been creating a WordPress plugin which basically creates step by step tours on how to change any settings in WordPress. I was able to get most of the other things done, but the most complicated logic is how to check if the tour is running and if it is, get the current step and process it ..
I have been considering options like:
- Setting
global
variables - Using
history.pushState();
- Using
wp_options
Please give your expert opinions on how should I get this done ..
If this is a javascript based tour there’s really no reason to bother with retaining the state in WordPress. See Spooky Action at a Distance for why relying a global variable is a bad idea in general.
Your problem can be more easily solved by just retaining the state of the tour in a cookie using javascript. Libs like intro.js offer pretty convenient APIs for managing all of this easily in javascript.