Skip to content
hmbasharPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

17 Commits

Folders and files

Repository files navigation

NotifyBar WordPress Plugin

A production-ready, dismissible sticky footer notification bar for WordPress announcements, alerts, and campaigns.

Version PHP WordPress License

πŸ“Œ Overview

NotifyBar is a lightweight, highly customizable WordPress plugin that displays a beautiful sticky notification bar at the bottom of your website. Perfect for announcements, donation campaigns, alerts, or any important message.

Features:

  • βœ… Fully customizable colors and content
  • βœ… Cookie-based dismissal persistence
  • βœ… Responsive design (desktop, tablet, mobile)
  • βœ… Smooth slide-in animations
  • βœ… No jQuery dependency (vanilla JS)
  • βœ… Accessible (WCAG compliant)
  • βœ… Modern OOP architecture with PSR-4
  • βœ… WordPress Coding Standards compliant

🎯 Use Cases

  • Announcements
  • Donation drives & giving day campaigns
  • Flash sales & promotions
  • Event notifications
  • Cookie notices
  • Emergency alerts
  • Special campaigns

πŸ“¦ Installation

Via Composer

composer install --no-dev --optimize-autoloader

Manual Installation

  1. Clone or download this repository
  2. Place the notifybar folder in /wp-content/plugins/
  3. Run composer install --no-dev --optimize-autoloader
  4. Activate the plugin in WordPress admin

πŸš€ Quick Start

  1. Activate the plugin
  2. Navigate to Settings β†’ NotifyBar
  3. Enable the notification bar
  4. Customize content, colors, and cookie settings
  5. Save and visit your site!

βš™οΈ Configuration

Content Settings

  • Enable/Disable - Turn the notification bar on/off
  • Badge Text - Short label (e.g., "GIVING DAY")
  • Title - Main heading text
  • Description - Detailed message

Color Settings

All colors are fully customizable via WordPress color picker:

  • Background color
  • Badge background color
  • Title text color
  • Description text color
  • Close button color

Cookie Settings

  • Allow Dismissal - Enable/disable the close button
  • Cookie Duration - How long the bar stays hidden after dismissal
    • Options: 1, 7, 14, 30, 60, 365 days

πŸ—οΈ Architecture

Project Structure

notifybar/
β”œβ”€β”€ composer.json               # Composer configuration
β”œβ”€β”€ notifybar.php              # Main plugin file (FINAL class)
β”œβ”€β”€ src/                       # Source code (PSR-4)
β”‚   β”œβ”€β”€ Plugin.php            # Core plugin orchestrator
β”‚   β”œβ”€β”€ Admin/
β”‚   β”‚   └── Settings.php      # Admin settings page
β”‚   β”œβ”€β”€ Frontend/
β”‚   β”‚   └── Bar.php           # Frontend bar rendering
β”‚   └── Assets/
β”‚       └── Enqueue.php       # Asset management
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ css/
β”‚   β”‚   └── notifybar.css     # Frontend styles
β”‚   └── js/
β”‚       └── notifybar.js      # Frontend JavaScript
β”œβ”€β”€ vendor/                    # Composer autoloader
└── readme.txt                # WordPress.org readme

Design Patterns

  • Singleton Pattern - Main plugin class
  • Dependency Injection - Component initialization
  • Separation of Concerns - Admin, Frontend, Assets
  • PSR-4 Autoloading - Modern PHP namespace structure

Code Standards

  • PHP 8+ with strict typing where appropriate
  • WordPress Coding Standards
  • Object-Oriented Programming (OOP)
  • Secure escaping and sanitization
  • No global variables or functions (except entry point)

πŸ”§ Technical Details

Main Plugin File (notifybar.php)

Features a FINAL class that:

  • Prevents inheritance/extension
  • Implements singleton pattern
  • Loads Composer autoloader
  • Bootstraps the plugin
  • Defines constants
final class NotifyBar {
    // Singleton instance
    private static ?NotifyBar $instance = null;
    
    public static function instance(): NotifyBar {
        if (null === self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
    }
}

Cookie Management

  • Cookie Name: notifybar_dismissed
  • Value: 1 (dismissed) or not set
  • Duration: Admin-configurable (1-365 days)
  • Scope: Site-wide, SameSite=Lax
  • Purpose: Remember dismissal state

Frontend JavaScript API

// Manually dismiss the bar
window.NotifyBar.dismiss();

// Check if dismissed
const isDismissed = window.NotifyBar.isDismissed();

// Listen to custom events
document.getElementById('notifybar').addEventListener('notifybar:dismissed', (e) => {
    console.log('Bar was dismissed!');
});

🎨 Customization

Filters & Hooks

Developers can extend the plugin using WordPress filters and actions:

// Example: Modify settings programmatically
add_filter('option_notifybar_settings', function($settings) {
    $settings['title'] = 'Custom Title';
    return $settings;
});

Custom Styling

Override styles in your theme:

.notifybar {
    /* Your custom styles */
}

πŸ§ͺ Testing

The plugin is designed to work with:

  • WordPress 6.0+
  • PHP 8.0+
  • Modern browsers (Chrome, Firefox, Safari, Edge)

Browser Support

  • Chrome (latest 2 versions)
  • Firefox (latest 2 versions)
  • Safari (latest 2 versions)
  • Edge (latest 2 versions)
  • Mobile browsers

πŸ”’ Security

  • All user input is sanitized using WordPress functions
  • Output is escaped properly (esc_html, esc_attr, etc.)
  • Nonces used for form submissions (via Settings API)
  • No SQL queries (uses WordPress Options API)
  • Cookie data is non-sensitive (only stores dismiss flag)

β™Ώ Accessibility

  • ARIA labels for screen readers
  • Keyboard navigation support
  • High contrast mode support
  • Reduced motion preference support
  • Semantic HTML structure
  • Focus indicators on interactive elements

πŸ“± Responsive Design

Breakpoints:

  • Desktop: > 768px (full layout)
  • Tablet: 481px - 768px (compact layout)
  • Mobile: ≀ 480px (stacked layout, repositioned close button)

πŸ› Debugging

Enable WordPress debug mode to see plugin errors:

// wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

πŸ“„ License

GPL v2 or later - https://www.gnu.org/licenses/gpl-2.0.html

πŸ‘¨β€πŸ’» Author

Md Abul Bashar

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch
  3. Follow WordPress Coding Standards
  4. Test your changes thoroughly
  5. Submit a pull request

πŸ“ Changelog

Version 1.0.0 (2026-01-24)

  • Initial release
  • Core notification bar functionality
  • Full color customization options
  • Cookie-based dismissal persistence
  • Responsive design for all devices
  • Accessibility features
  • Clean OOP architecture with PSR-4 autoloading

πŸ†˜ Support

For issues, questions, or feature requests:


Made with ❀️ for the WordPress community

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages