Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/nadimtuhin/wp-stickybar/archive/refs/heads/main.zipWP StickyBar Plugin
A professional WordPress plugin for displaying important announcements, emergency alerts, holiday messages, and events with comprehensive analytics tracking and extensive hooks for developers.
Author: Nadim Tuhin
Email: nadimtuhin@gmail.com
GitHub: https://github.com/nadimtuhin/wp-stickybar
Version: 1.0.0
Features
- 7 Professional Preset Types: Emergency, Important, Holiday/Event, Information, Success, Warning, Generic
- Real-time Analytics: Track views and clicks with detailed dashboard and metrics
- Advanced Scheduling: Set start/end dates with automatic activation/deactivation
- Responsive Design: Mobile-friendly with customizable dismiss functionality
- Extensive Hooks: 40+ action and filter hooks for maximum extensibility
- WordPress AJAX: Proper implementation using wp_ajax hooks with nonce verification
- Security First: Comprehensive data validation, sanitization, and rate limiting
- Developer Friendly: Extensive documentation and clean, extensible code
Preset Design Types
1. Emergency 🚨
- Red background (#dc3545)
- Non-dismissible
- Pulse animation
- Top position priority
2. Important ⚡
- Orange background (#fd7e14)
- Session dismissible
- Bounce animation
3. Holiday/Event 🎉
- Purple background (#6f42c1)
- Dismissible
- Seasonal icons
4. Information ℹ️
- Cyan background (#0dcaf0)
- Bottom position
- Clean design
5. Success ✅
- Green background (#198754)
- Slide down animation
6. Warning ⚠️
- Yellow background (#ffc107)
- High visibility
7. Generic 📢
- Gray background (#6c757d)
- Fully configurable
Database Schema
stickybars table
- id (primary key)
- title (varchar 255)
- message (text)
- link_url (varchar 500)
- link_text (varchar 100)
- preset_type (varchar 20)
- custom_styles (text)
- start_date (datetime)
- end_date (datetime)
- is_active (boolean)
- position (enum: top, bottom)
- is_dismissible (boolean)
- created_at (timestamp)
- updated_at (timestamp)
stickybar_analytics table
- id (primary key)
- stickybar_id (foreign key)
- event_type (enum: view, click)
- user_ip (varchar 45)
- page_url (varchar 500)
- user_agent (text)
- timestamp (datetime)
File Structure
wp-stickybar/
├── wp-stickybar.php (main plugin file)
├── README.md (this file)
├── includes/
│ ├── class-database.php (database operations)
│ ├── class-stickybar.php (core functionality)
│ ├── class-admin.php (admin interface)
│ ├── class-analytics.php (tracking system)
│ └── class-presets.php (design presets)
├── admin/
│ ├── admin-page.php (main admin page)
│ ├── analytics-page.php (analytics dashboard)
│ └── settings-page.php (plugin settings)
├── assets/
│ ├── css/
│ │ ├── frontend.css (frontend styles)
│ │ └── admin.css (admin styles)
│ └── js/
│ ├── frontend.js (frontend functionality)
│ └── admin.js (admin functionality)
└── uninstall.php (cleanup on uninstall)
Installation
- Upload the plugin files to
/wp-content/plugins/wp-stickybar/ - Activate the plugin through the 'Plugins' menu in WordPress
- Go to 'StickyBar' in the admin menu to create your first announcement
Usage
- Create Announcement: Go to StickyBar > Add New
- Choose Preset: Select from 7 predefined styles or customize
- Set Schedule: Optional start/end dates
- Configure Options: Position, dismissible settings
- View Analytics: Track performance in Analytics tab
Security Features
- Nonce verification for all forms
- Data sanitization and validation
- Capability checks for admin access
- SQL injection prevention
- XSS protection
Developer Extensibility
Extensive Hook System
WP StickyBar provides 40+ action and filter hooks for maximum extensibility. All hooks follow WordPress standards with proper nonce verification and capability checks.
Key Action Hooks
wp_stickybar_init- Plugin initializationwp_stickybar_before_display/wp_stickybar_after_display- Display lifecyclewp_stickybar_before_save/wp_stickybar_after_save- Data operationswp_stickybar_before_track/wp_stickybar_after_track- Analytics eventswp_stickybar_activated/wp_stickybar_deactivated- Plugin lifecycle
Key Filter Hooks
wp_stickybar_message- Modify message contentwp_stickybar_displayable_bars- Filter which bars to displaywp_stickybar_should_display- Custom display conditionswp_stickybar_classes- Add custom CSS classeswp_stickybar_script_data- Modify frontend script data
WordPress AJAX Implementation
All AJAX functionality uses proper WordPress standards:
wp_ajax_andwp_ajax_nopriv_hooks- Nonce verification for security
- Capability checks for permissions
- Rate limiting to prevent abuse
- Comprehensive error handling
Full Documentation
Complete hooks documentation available in HOOKS.md with:
- Detailed parameter descriptions
- Usage examples for each hook
- Security considerations
- AJAX endpoint documentation
Example Extensions
Add Custom CSS Class to Emergency Bars
add_filter('wp_stickybar_classes', 'add_emergency_class', 10, 2);
function add_emergency_class($classes, $stickybar) {
if ($stickybar->preset_type === 'emergency') {
$classes[] = 'my-custom-emergency';
}
return $classes;
}
Custom Analytics Integration
add_action('wp_stickybar_after_track', 'send_to_analytics', 10, 3);
function send_to_analytics($stickybar_id, $event_type, $data) {
// Send to your analytics service
}
Modify Display Conditions
add_filter('wp_stickybar_should_display', 'custom_display_rules', 10, 2);
function custom_display_rules($should_display, $stickybar) {
// Your custom logic
return $should_display;
}
Requirements
- WordPress 5.0+
- PHP 7.4+
- MySQL 5.6+
Installation & Testing
The plugin includes a built-in test suite available in debug mode:
- Set
WP_DEBUGtotrueinwp-config.php - Navigate to StickyBar → Tests in admin
- Run comprehensive plugin tests
Support & Contributing
- GitHub Repository: https://github.com/nadimtuhin/wp-stickybar
- Author: Nadim Tuhin
- Email: nadimtuhin@gmail.com
- Issues: Report bugs and feature requests on GitHub
License
GPL v2 or later
Built with ❤️ for the WordPress community by Nadim Tuhin