Web Game Integration Guide v1.0.0
A two-phase web game for santasfunnight.com that drives engagement and offers rewards:
Players who reach Round 10 can enter their email to receive a $5 discount code.
Contains: candy-cane-web-v1.0.0.html + backend-example.php
Upload candy-cane-web-v1.0.0.html to your media library or theme folder, then embed:
<iframe
src="/wp-content/uploads/candy-cane-web-v1.0.0.html"
width="100%"
height="700"
frameborder="0"
style="max-width: 540px; margin: 0 auto; display: block;">
</iframe>
Add to your theme's functions.php:
function candy_cane_game_shortcode() {
return '<iframe
src="' . get_template_directory_uri() . '/games/candy-cane-web-v1.0.0.html"
width="100%"
height="700"
frameborder="0"
style="max-width: 540px; margin: 0 auto; display: block;">
</iframe>';
}
add_shortcode('candy_cane_game', 'candy_cane_game_shortcode');
Then use [candy_cane_game] in any post or page.
Copy the contents of the HTML file into a Custom HTML block.
The game needs a REST endpoint to validate gameplay and send discount codes.
| Function | Description |
|---|---|
| Validate gameplay | Checks timing to prevent cheating (can't reach round 10 in <15 seconds) |
| Prevent duplicates | One reward per email address |
| Generate codes | Creates unique coupon codes (SANTA-XXXXXXXX format) |
| Send email | Delivers discount code via wp_mail() |
functions.php or create a custom plugin (see backend-example.php in the ZIP)wp_mail(). Consider an SMTP plugin for reliable delivery./wp-json/santasfunnight/v1/claim-rewardCONFIG.API_ENDPOINT in the game's JavaScript.
See backend-example.php in the ZIP file for complete, documented code including:
A leaderboard would show top scores, encouraging competition and repeat plays.
Required changes:
GET /leaderboard and POST /submit-scoreDecision points:
Social sharing could make this game go viral with people everywhere playing and telling others about it.
Current state: Players can download a certificate PNG and manually share it.
What "proper" social sharing would require:
| Platform | Requirements |
|---|---|
| Open Graph meta tags, Facebook App ID, share dialog integration | |
| Twitter/X | Twitter Cards meta tags, intent URL with pre-filled text |
| No direct sharing API - users download and post manually |
The bigger picture:
We could create a mini arcade with simplified versions of various games - a "preview" of the event that builds anticipation. But there's a balance: we don't want to give away all our magic before people come.
| File | Purpose |
|---|---|
candy-cane-web-v1.0.0.html |
Production game - embed this one |
candy-cane-web-dev.html |
Development version with cheat modes for testing (not in ZIP) |
backend-example.php |
WordPress REST API endpoint example |
README.md |
Technical documentation |
INTEGRATION-GUIDE.html |
This file |
Contact Zach or Brett - we can quickly clarify any integration questions.
If Brett gives Zach WordPress access, he can implement the backend himself - would take about an hour.