I’m writing a game in html5 and using wordpress for the rest of the site. I want users to be able to save their progress, but I’m not clear on how the architecture looks.
I would just do an ajax call to a php page that access the database, but I feel like using the existing wordpress database and API is the correct thing to do. Not only that, but using the wordpress api will give me access to things like nonce.
That said, do I write a wordpress plugin to do this? How do I properly execute the save request from the javascript that runs my game?
In your js file, do your ajax request like this:
add this to your theme’s functions.php: