Shortcode code to ajax back back to php question
-
Hi,
I’m developing a small wheel of fortune like game with WordPress.
So far things are going well as I have created a shortcode to show the js wheel and its spins when clicked and calls the php code that determines the RNG (as you don’t want the client to be able to edit their js to come up with that number)
Now I got the random number from the php function called by the ajax, but to give out a reward, I’d like to know what the multiplier or reward value that was set by the shortcode like
[wheel-game bet=100 win=1000]So I’d like to know both what the bet and win attributes were from the shortcode of the other function.
I’ve saw some stack exchange post with similar issues suggesting static variables or having the shortcode write itself to SQL and then the AJAX php ask SQL, but I feel like that will be resource intensive and open to more security issues.
I also thought maybe the shortcode function could just to see if ajax is post, but I feel like that version of the function being called by AJAX may not have knowledge of what the shortcode attributes were on that page.
And to complicate things further I suspect this game may have more than one on a page or multiple pages.
Any general practices with shortcodes and php called by ajax?
Thanks!
The topic ‘Shortcode code to ajax back back to php question’ is closed to new replies.