Sports Predictions
This plugin implements to integration the membership plugin and discord channel for thevaluedStats.com
by Valued Stats · github.com/srcore9179/wp_sports_predictions
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/srcore9179/wp_sports_predictions/archive/refs/heads/main.zipSports Predictions Plugin - Implementation Guide
Installation
-
Create a folder called
sports-predictionsin your WordPresswp-content/plugins/directory -
Create the following folder structure:
sports-predictions/ ├── assets/ │ ├── css/ │ └── js/ └── includes/ -
Add the following files with their respective contents:
sports-predictions.php(Main plugin file)includes/api.php(API handling)includes/helpers.php(Helper functions)includes/shortcodes.php(Shortcode implementation)assets/css/sports-predictions.css(Styling)assets/js/sports-predictions.js(JavaScript)
-
Activate the plugin from your WordPress admin panel
Using the Shortcode
Add the shortcode to any page or post:
[sports_predictions sport="NBA"]
Basic Examples
NBA Predictions with Auto-Refresh:
[sports_predictions]
NFL Predictions:
[sports_predictions sport="NFL"]
NHL Predictions with Custom Refresh Rate:
[sports_predictions sport="NHL" refresh_interval="120"]
MLB Predictions without Auto-Refresh:
[sports_predictions sport="MLB" auto_refresh="no"]
Features
- Auto-Refresh: Predictions update automatically at specified intervals
- Real-time Data: Fetches data directly from your API
- Responsive Design: Looks great on all devices
- Team Logos: Displays team logos from your taxonomy
- Access Control: Integrates with your membership system
- Error Handling: Falls back to cached data if API is unavailable
Technical Implementation
The plugin makes API requests in this order:
- First tries a GET request to the API
- If that fails, falls back to a POST request
- If both fail, uses cached data if available
- Caches successful responses for 5 minutes
- Also keeps a 24-hour "emergency cache" for API outages
Customization
Changing API Endpoint
To change the API URL, modify the SP_API_URL constant in sports-predictions.php.
Changing Cache Duration
To adjust how long predictions are cached, modify the value in the set_transient() calls in api.php.
Styling Changes
The plugin includes comprehensive styling. To customize:
- Add custom CSS to your theme
- Or edit
sports-predictions.cssdirectly
Troubleshooting
Predictions Not Updating
- Check browser console for JavaScript errors
- Verify API endpoint is accessible
- Check WordPress error logs
Logos Not Showing
- Verify team taxonomy has correct team names
- Check that team terms have logo images attached