TFA Interactive Polls
WordPress plugin for interactive polls with REST API voting and cookie-based tracking
by Texas Football Analytics · github.com/brandonfricke/tfa-polls · website
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/brandonfricke/tfa-polls/archive/refs/heads/main.zipA WordPress plugin providing interactive polling functionality with REST API voting, cookie-based vote tracking, and rate limiting.
Features
- Custom Post Type for polls
[tfa_poll]shortcode for embedding polls- REST API endpoints for voting
- Cookie-based vote tracking (30-day expiration)
- Rate limiting (5 votes per minute per IP)
- Open/Closed poll status
- Accessible ARIA markup
- Dark mode support
- Mobile-responsive design
Requirements
- WordPress 6.0+
- PHP 7.4+
Installation
- Download the plugin
- Upload to
/wp-content/plugins/tfa-polls/ - Activate the plugin in WordPress Admin > Plugins
- Configure settings in Settings > TFA Polls
Usage
Creating a Poll
- Go to Polls > Add New in WordPress Admin
- Enter your poll question as the title
- Add poll options (minimum 2 required)
- Set poll status (Open or Closed)
- Publish the poll
Embedding a Poll
Use the shortcode in any post or page:
[tfa_poll id="123"]
Replace 123 with your poll ID (shown in the Poll settings sidebar).
REST API Endpoints
Submit Vote
POST /wp-json/tfa/v1/polls/{id}/vote
Body:
{
"option": 0
}
Response:
{
"success": true,
"voted": 0,
"results": [
{"text": "Option A", "votes": 10, "percentage": 50},
{"text": "Option B", "votes": 10, "percentage": 50}
],
"total_votes": 20
}
Get Results
GET /wp-json/tfa/v1/polls/{id}/results
Response:
{
"id": 123,
"question": "Poll Question",
"status": "open",
"results": [...],
"total_votes": 20
}
Configuration
Proxy Headers
If your site is behind a proxy (Cloudflare, Nginx, etc.), add this to wp-config.php for accurate IP-based rate limiting:
define( 'TFA_TRUST_PROXY_HEADERS', true );
Styling
The plugin includes CSS with CSS custom properties that integrate with themes using the following tokens:
--color-surface- Background color--color-border- Border color--color-text- Text color--color-primary- Primary accent color (default: #bf5700)--radius-md- Border radius--space-*- Spacing scale
Dark mode is supported via the .tfa-dark-mode body class.
Changelog
1.0.0
- Initial release
- Extracted from Texas Football Analytics theme v1.10.0
License
GPL-2.0+