Plugin Directory

Changeset 3510687


Ignore:
Timestamp:
04/20/2026 10:10:27 AM (6 months ago)
Author:
susheelhbti
Message:

few changes

Location:
forameal-splash-screen/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • forameal-splash-screen/trunk/README.md

    r3510371 r3510687  
    11=== Smart Splash Screen ===
    2 Contributors:      susheelhbti
    3 Tags:              splash screen, popup, cookie, shortcode, welcome screen
     2Contributors: susheelhbti
     3Tags: splash screen, popup, sweetalert2, welcome screen, cookie, modal
    44Requires at least: 5.8
    5 Tested up to:      6.7
    6 Requires PHP:      7.4
    7 Stable tag:        1.0.1
    8 License:           GPLv2 or later
    9 License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     5Tested up to: 6.7
     6Requires PHP: 7.4
     7Stable tag: 2.1.0
     8License: GPLv2 or later
     9License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 A modern, secure, cookie-aware splash screen / popup plugin with AJAX dismiss, shortcode support, animations, and a full admin settings panel.
     11A modern, beautiful, fully customizable splash screen plugin powered by SweetAlert2.
    1212
    1313== Description ==
    1414
    15 **Smart Splash Screen** lets you show a beautiful welcome popup to first-time visitors — and then stay out of the way. It uses a cookie so the popup only appears once per visitor (configurable). Everything is controlled from a clean Settings page — no coding required.
     15**Smart Splash Screen** is a professional WordPress plugin that displays beautiful, engaging popups to your visitors. Powered by SweetAlert2, it offers stunning animations, complete customization, and smart cookie-based dismissal.
    1616
    1717= Key Features =
    1818
    19 * ✅ **Enable / disable** with one click
    20 * 🍪 **Cookie control** — choose how many days to suppress the popup after dismiss
    21 * ⚡ **AJAX dismiss** — closes instantly with no page reload; server-side action hook fires on every dismiss
    22 * 📱 **Mobile responsive** — fluid card layout with `clamp()` fluid typography
    23 * 🎬 **3 entry animations** — Fade, Slide-up, or Zoom-in; respects `prefers-reduced-motion`
    24 * 🎨 **Full appearance control** — overlay background color, overlay opacity, and accent / button color
    25 * 📄 **Page targeting** — show on all pages, front page only, or specific page IDs
    26 * ⌨️ **Fully accessible** — `role="dialog"`, `aria-modal`, Escape-key dismissal, focus trapping
    27 * 🔌 **Shortcode support** — embed any shortcode (contact forms, newsletter sign-ups, etc.) inside the popup
    28 * 🛡 **Secure** — nonce-verified AJAX, `wp_kses_post`, `sanitize_hex_color`, zero remote HTTP calls, zero eval
     19✨ **Beautiful Design** - Modern, sleek popups that impress
     20🎨 **Fully Customizable** - Colors, animations, icons, and more
     21🍪 **Smart Cookies** - Configurable dismissal duration
     22⚡ **AJAX Tracking** - Server-side dismiss events
     23📱 **100% Responsive** - Perfect on all devices
     24🎬 **Smooth Animations** - Fade, Slide, Zoom effects
     25🎯 **Page Targeting** - Show on specific pages
     26🔌 **Shortcode Support** - Embed anywhere
     27♿ **Accessible** - Keyboard navigation support
     28🚀 **Lightweight** - Optimized for performance
     29
     30= New in Version 2.1 =
     31
     32✨ 15+ New Customization Options
     33🎨 Custom icon upload support
     34🌈 Full color control
     35📐 Adjustable border radius & width
     36🔘 Multiple button shapes
     37⏰ Auto-close timer
     38✨ Confetti effect on dismiss
     39🔊 Sound effects
    2940
    3041= Shortcodes =
    3142
    32 `[smart_splash]`
    33 Place on any page or post to force-show the popup regardless of the cookie.
     43`[smart_splash]` - Force display the splash screen
     44`[smart_splash_reset]` - Reset cookie to show again
    3445
    35 `[smart_splash_reset text="See welcome popup again"]`
    36 Renders a link that clears the dismiss cookie and reloads the page so the popup re-appears.
     46= Developer Hooks =
    3747
    38 = Developer Hook =
    39 
    40 `do_action( 'sss_splash_dismissed' )` fires every time a visitor dismisses the popup via AJAX. Hook in to log analytics, send events, update user meta, etc.
    41 
    42 = About the Author =
    43 
    44 Plugin developed by **Susheel** (susheelhbti@gmail.com).
    45 I am currently **open to work** — full-time, remote, or freelance WordPress / PHP development roles.
    46 Feel free to reach out: susheelhbti@gmail.com | [sakshamapp.com](http://sakshamapp.com)
     48`do_action( 'sss_splash_dismissed' )` - Fires when popup is dismissed
    4749
    4850== Installation ==
    4951
    50 1. Upload the `smart-splash-screen` folder to `/wp-content/plugins/`, or install directly via **Plugins → Add New → Upload Plugin**.
    51 2. Activate the plugin through the **Plugins** menu in WordPress.
    52 3. Go to **Settings → Smart Splash** to configure the popup content, behaviour, and appearance.
     521. Upload to `/wp-content/plugins/`
     532. Activate through WordPress admin
     543. Go to **Settings → Smart Splash** to configure
    5355
    5456== Frequently Asked Questions ==
    5557
    56 = Will the popup show every time? =
     58= Will it work with any theme? =
     59Yes! SweetAlert2 ensures consistent display across all themes.
    5760
    58 No. After a visitor dismisses it, a cookie is set and the popup will not appear again for the number of days you configure (default: 7 days).
     61= Can I embed forms? =
     62Yes! Enter any shortcode in the settings.
    5963
    60 = Can I embed a contact form or newsletter signup inside the popup? =
     64= Is it mobile friendly? =
     65Yes, fully responsive with touch optimization.
    6166
    62 Yes! Enter your form's shortcode (without the square brackets) in the **Embed shortcode** field in the settings, and it will be rendered inside the popup.
    63 
    64 = How do I make the popup appear again for testing? =
    65 
    66 Use the `[smart_splash_reset]` shortcode, or simply clear your browser cookies and reload the page.
    67 
    68 = Does this plugin use jQuery or any external libraries? =
    69 
    70 No. The frontend JavaScript is plain vanilla JS (~2 KB). There are zero external dependencies and zero remote HTTP requests.
    71 
    72 = Is it accessible? =
    73 
    74 Yes. The popup uses `role="dialog"` and `aria-modal="true"`, traps focus inside the modal while open, supports Escape-key dismissal, and respects the `prefers-reduced-motion` media query.
    75 
    76 = What PHP version do I need? =
    77 
    78 PHP 7.4 or higher is required.
     67= Does it affect performance? =
     68No, it's lightweight and loads only when needed.
    7969
    8070== Screenshots ==
    8171
    82 1. Admin settings page — General section
    83 2. Admin settings page — Appearance section
    84 3. Example popup on the front end (Fade animation)
    85 4. Mobile view of the popup
     721. Beautiful popup display
     732. Admin settings panel
     743. Mobile responsive view
     754. Color customization options
    8676
    8777== Changelog ==
    8878
    89 = 1.0.1 =
    90 * Added `Requires at least`, `Tested up to`, and `Requires PHP` headers to resolve WordPress.org compatibility warning.
    91 * Added "Open to Work" notice in admin settings panel.
    92 * Improved admin UI: responsive hire-me banner, cleaner section spacing.
    93 * README rewritten with full WordPress.org formatting.
     79= 2.1.0 =
     80* 15+ new customization options
     81* Custom icon upload support
     82* Full color customization
     83* Adjustable border radius and width
     84* Multiple button shapes (Round, Square, Pill)
     85* Auto-close timer with progress bar
     86* Confetti effect on dismiss
     87* Sound effects support
     88* Enhanced responsive design
     89* Performance optimizations
     90
     91= 2.0.0 =
     92* Complete rewrite with SweetAlert2
     93* Modern, beautiful interface
     94* Improved animations
     95* Better reliability
    9496
    9597= 1.0.0 =
    96 * Initial release.
    97 * Cookie-aware splash popup with AJAX dismiss.
    98 * Admin settings: title, message, shortcode embed, button text, page targeting, cookie duration, delay, animation, colors.
    99 * Shortcodes: `[smart_splash]` and `[smart_splash_reset]`.
    100 * Accessible markup: `role="dialog"`, `aria-modal`, Escape key, focus trapping.
    101 * Zero external dependencies, zero remote HTTP calls.
     98* Initial release
    10299
    103100== Upgrade Notice ==
    104101
    105 = 1.0.1 =
    106 Fixes the "hasn't been tested with the latest 3 major releases" warning on WordPress.org. Update recommended.
     102= 2.1.0 =
     103Major update with 15+ new customization options. Highly recommended for all users.
  • forameal-splash-screen/trunk/assets/css/splash.css

    r3510361 r3510687  
    1 /* Smart Splash Screen — splash.css */
     1/**
     2 * Smart Splash Screen v2.1.0
     3 * Additional styles for SweetAlert2 popup
     4 */
    25
    3 /* ── Reset ─────────────────────────────────────────────────────────────────── */
    4 #sss-overlay *,
    5 #sss-overlay *::before,
    6 #sss-overlay *::after {
    7   box-sizing: border-box;
    8   margin: 0;
    9   padding: 0;
     6/* Popup container */
     7.sss-popup {
     8    position: relative !important;
     9    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    1010}
    1111
    12 /* ── Overlay ────────────────────────────────────────────────────────────────── */
    13 #sss-overlay {
    14   position: fixed;
    15   inset: 0;
    16   z-index: 999999;
    17   display: flex;
    18   align-items: center;
    19   justify-content: center;
    20   padding: 20px;
    21 
    22   /* Default hidden state — JS reveals after delay */
    23   opacity: 0;
    24   visibility: hidden;
    25   transition: opacity 0.35s ease, visibility 0.35s ease;
     12/* Popup shadow */
     13.sss-popup-shadow {
     14    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    2615}
    2716
    28 #sss-overlay.sss-visible {
    29   opacity: 1;
    30   visibility: visible;
     17/* Title styling */
     18.sss-popup-title {
     19    font-weight: 700 !important;
     20    margin-bottom: 0.5rem !important;
    3121}
    3222
    33 /* ── Popup card ─────────────────────────────────────────────────────────────── */
    34 .sss-popup {
    35   --sss-accent: #6ee7b7;       /* overridden inline from PHP */
    36   --sss-radius: 16px;
    37   --sss-shadow: 0 32px 80px rgba(0,0,0,0.45);
    38 
    39   position: relative;
    40   background: #ffffff;
    41   border-radius: var(--sss-radius);
    42   box-shadow: var(--sss-shadow);
    43   padding: 48px 44px 40px;
    44   max-width: 520px;
    45   width: 100%;
    46   text-align: center;
    47 
    48   /* entry animation handled by JS-added class */
    49   transform: translateY(24px) scale(0.97);
    50   transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
     23/* Button shapes */
     24.sss-btn-round {
     25    border-radius: 50px !important;
     26    padding: 12px 32px !important;
     27    font-weight: 600 !important;
     28    transition: all 0.3s ease !important;
    5129}
    5230
    53 #sss-overlay.sss-visible .sss-popup {
    54   transform: translateY(0) scale(1);
     31.sss-btn-square {
     32    border-radius: 8px !important;
     33    padding: 12px 32px !important;
     34    font-weight: 600 !important;
     35    transition: all 0.3s ease !important;
    5536}
    5637
    57 /* Zoom animation variant */
    58 #sss-overlay.sss-anim-zoom .sss-popup {
    59   transform: scale(0.7);
    60 }
    61 #sss-overlay.sss-anim-zoom.sss-visible .sss-popup {
    62   transform: scale(1);
     38.sss-btn-pill {
     39    border-radius: 9999px !important;
     40    padding: 12px 32px !important;
     41    font-weight: 600 !important;
     42    transition: all 0.3s ease !important;
    6343}
    6444
    65 /* Slide animation variant */
    66 #sss-overlay.sss-anim-slide .sss-popup {
    67   transform: translateY(60px);
    68 }
    69 #sss-overlay.sss-anim-slide.sss-visible .sss-popup {
    70   transform: translateY(0);
     45/* Button hover effect */
     46.sss-btn-round:hover,
     47.sss-btn-square:hover,
     48.sss-btn-pill:hover {
     49    transform: translateY(-2px) !important;
     50    filter: brightness(1.05) !important;
    7151}
    7252
    73 /* Accent bar at top of card */
    74 .sss-popup::before {
    75   content: '';
    76   position: absolute;
    77   top: 0;
    78   left: 0;
    79   right: 0;
    80   height: 5px;
    81   background: var(--sss-accent);
    82   border-radius: var(--sss-radius) var(--sss-radius) 0 0;
     53/* Close button */
     54.sss-popup-close {
     55    transition: all 0.2s ease !important;
     56    color: #94a3b8 !important;
    8357}
    8458
    85 /* ── Close × button ────────────────────────────────────────────────────────── */
    86 .sss-close {
    87   position: absolute;
    88   top: 16px;
    89   right: 16px;
    90   background: none;
    91   border: none;
    92   cursor: pointer;
    93   font-size: 18px;
    94   color: #94a3b8;
    95   line-height: 1;
    96   padding: 4px 6px;
    97   border-radius: 6px;
    98   transition: color 0.2s, background 0.2s;
    99 }
    100 .sss-close:hover {
    101   color: #1e293b;
    102   background: #f1f5f9;
     59.sss-popup-close:hover {
     60    transform: scale(1.1) !important;
     61    color: #1e293b !important;
    10362}
    10463
    105 /* ── Typography ─────────────────────────────────────────────────────────────── */
    106 .sss-title {
    107   font-size: clamp(1.35rem, 4vw, 1.75rem);
    108   font-weight: 700;
    109   color: #0f172a;
    110   line-height: 1.25;
    111   margin-bottom: 14px;
     64/* Shortcode wrapper */
     65.sss-shortcode-wrapper {
     66    margin: 20px 0;
     67    padding: 20px;
     68    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
     69    border-radius: 12px;
     70    border: 1px solid #e2e8f0;
    11271}
    11372
    114 .sss-message {
    115   font-size: 1rem;
    116   color: #475569;
    117   line-height: 1.65;
    118   margin-bottom: 24px;
     73/* Timer progress bar */
     74.swal2-timer-progress-bar {
     75    background: #6ee7b7 !important;
    11976}
    12077
    121 /* ── Embedded shortcode content ─────────────────────────────────────────────── */
    122 .sss-shortcode-content {
    123   margin-bottom: 24px;
     78/* Responsive design */
     79@media (max-width: 640px) {
     80    .sss-popup {
     81        padding: 1.5rem !important;
     82    }
     83   
     84    .sss-popup-title {
     85        font-size: 1.4rem !important;
     86    }
     87   
     88    .sss-btn-round,
     89    .sss-btn-square,
     90    .sss-btn-pill {
     91        padding: 10px 24px !important;
     92        font-size: 0.9rem !important;
     93    }
     94   
     95    .sss-shortcode-wrapper {
     96        padding: 15px;
     97        margin: 15px 0;
     98    }
    12499}
    125100
    126 /* ── Dismiss button ─────────────────────────────────────────────────────────── */
    127 .sss-btn {
    128   display: inline-block;
    129   background: var(--sss-accent);
    130   color: #064e3b;
    131   font-size: 0.9375rem;
    132   font-weight: 600;
    133   padding: 13px 32px;
    134   border: none;
    135   border-radius: 9999px;
    136   cursor: pointer;
    137   letter-spacing: 0.01em;
    138   transition: filter 0.2s, transform 0.15s;
    139 }
    140 .sss-btn:hover {
    141   filter: brightness(1.08);
    142   transform: translateY(-1px);
    143 }
    144 .sss-btn:active {
    145   transform: translateY(0);
     101/* Dark mode support */
     102@media (prefers-color-scheme: dark) {
     103    .sss-shortcode-wrapper {
     104        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
     105        border-color: #334155;
     106        color: #e2e8f0;
     107    }
    146108}
    147109
    148 /* ── Overlay exit ───────────────────────────────────────────────────────────── */
    149 #sss-overlay.sss-hiding {
    150   opacity: 0;
    151   visibility: hidden;
     110/* Reduced motion preference */
     111@media (prefers-reduced-motion: reduce) {
     112    .animate__animated {
     113        animation: none !important;
     114    }
     115   
     116    .sss-btn-round:hover,
     117    .sss-btn-square:hover,
     118    .sss-btn-pill:hover {
     119        transform: none !important;
     120    }
    152121}
    153122
    154 /* ── Mobile ─────────────────────────────────────────────────────────────────── */
    155 @media (max-width: 480px) {
    156   .sss-popup {
    157     padding: 40px 24px 32px;
    158   }
     123/* Loading animation */
     124@keyframes sss-pulse {
     125    0% { transform: scale(1); }
     126    50% { transform: scale(1.05); }
     127    100% { transform: scale(1); }
    159128}
    160129
    161 /* ── Reduced motion ─────────────────────────────────────────────────────────── */
    162 @media (prefers-reduced-motion: reduce) {
    163   #sss-overlay,
    164   .sss-popup {
    165     transition: none !important;
    166     transform: none !important;
    167   }
     130.sss-loading {
     131    animation: sss-pulse 1s infinite;
    168132}
  • forameal-splash-screen/trunk/assets/js/splash.js

    r3510361 r3510687  
    11/**
    2  * Smart Splash Screen — splash.js
    3  * Vanilla JS, zero dependencies, ~2 KB minified.
     2 * Smart Splash Screen v2.1.0
     3 * Powered by SweetAlert2
    44 */
    55
    6 (function () {
    7   'use strict';
    8 
    9   /* ── Helpers ────────────────────────────────────────────────────────────── */
    10 
    11   function getCookie(name) {
    12     var match = document.cookie.match(
    13       new RegExp('(?:^|; )' + name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '=([^;]*)')
    14     );
    15     return match ? decodeURIComponent(match[1]) : null;
    16   }
    17 
    18   function setCookie(name, value, days) {
    19     var expires = '';
    20     if (days) {
    21       var d = new Date();
    22       d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);
    23       expires = '; expires=' + d.toUTCString();
     6(function() {
     7    'use strict';
     8   
     9    function init() {
     10        // Cookie manager
     11        const CookieManager = {
     12            get(name) {
     13                const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
     14                return match ? match[2] : null;
     15            },
     16            set(name, value, days) {
     17                let expires = '';
     18                if (days) {
     19                    const date = new Date();
     20                    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
     21                    expires = '; expires=' + date.toUTCString();
     22                }
     23                document.cookie = name + '=' + value + expires + '; path=/; SameSite=Lax';
     24            }
     25        };
     26       
     27        const config = window.sssConfig || {};
     28       
     29        // Check if already dismissed
     30        if (CookieManager.get('sss_dismissed') === '1') {
     31            return;
     32        }
     33       
     34        // Build content HTML
     35        let htmlContent = '';
     36        if (config.message) {
     37            htmlContent += `<p style="color: ${config.messageColor}; font-size: 1rem; line-height: 1.6; margin: 0 0 20px 0;">${config.message}</p>`;
     38        }
     39        if (config.shortcode) {
     40            htmlContent += `<div class="sss-shortcode-wrapper">[${config.shortcode}]</div>`;
     41        }
     42       
     43        // Get icon
     44        let icon = undefined;
     45        if (config.iconType !== 'none') {
     46            icon = config.iconType;
     47        }
     48       
     49        // Show popup function
     50        function showPopup() {
     51            // Convert hex to rgba for backdrop
     52            const bgColor = config.bgColor || '#0f0f0f';
     53            const opacity = (config.overlayOpacity || 85) / 100;
     54            const hexToRgb = (hex) => {
     55                const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
     56                return result ? {
     57                    r: parseInt(result[1], 16),
     58                    g: parseInt(result[2], 16),
     59                    b: parseInt(result[3], 16)
     60                } : { r: 15, g: 15, b: 15 };
     61            };
     62            const rgb = hexToRgb(bgColor);
     63            const backdropColor = `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;
     64           
     65            // Button shape class
     66            let buttonClass = '';
     67            switch(config.buttonShape) {
     68                case 'square': buttonClass = 'sss-btn-square'; break;
     69                case 'pill': buttonClass = 'sss-btn-pill'; break;
     70                default: buttonClass = 'sss-btn-round';
     71            }
     72           
     73            // Timer option
     74            let timer = undefined;
     75            if (config.showTimer && config.timerSeconds > 0) {
     76                timer = config.timerSeconds * 1000;
     77            }
     78           
     79            Swal.fire({
     80                title: config.title,
     81                html: htmlContent || '<p style="font-size: 1rem;">Thanks for visiting!</p>',
     82                icon: icon,
     83                imageUrl: config.iconType === 'custom' && config.customIcon ? config.customIcon : undefined,
     84                imageWidth: 80,
     85                imageHeight: 80,
     86                imageAlt: 'Custom icon',
     87                confirmButtonText: config.buttonText,
     88                confirmButtonColor: config.accentColor,
     89                showConfirmButton: true,
     90                showCloseButton: config.showCloseButton,
     91                allowOutsideClick: config.allowOutsideClick,
     92                allowEscapeKey: true,
     93                backdrop: backdropColor,
     94                timer: timer,
     95                timerProgressBar: config.showTimer,
     96                customClass: {
     97                    popup: `sss-popup ${config.popupShadow ? 'sss-popup-shadow' : ''}`,
     98                    confirmButton: buttonClass,
     99                    title: 'sss-popup-title',
     100                    closeButton: 'sss-popup-close'
     101                },
     102                showClass: {
     103                    popup: `animate__animated animate__${config.animation === 'slide' ? 'slideInUp' : (config.animation === 'zoom' ? 'zoomIn' : 'fadeIn')}`
     104                },
     105                hideClass: {
     106                    popup: `animate__animated animate__${config.animation === 'slide' ? 'slideOutDown' : (config.animation === 'zoom' ? 'zoomOut' : 'fadeOut')}`
     107                },
     108                didOpen: (popup) => {
     109                    // Apply custom styles
     110                    popup.style.borderRadius = `${config.borderRadius}px`;
     111                    popup.style.maxWidth = `${config.popupWidth}px`;
     112                    popup.style.width = '90%';
     113                   
     114                    const title = popup.querySelector('.sss-popup-title');
     115                    if (title) title.style.color = config.titleColor;
     116                   
     117                    const confirmBtn = popup.querySelector('.swal2-confirm');
     118                    if (confirmBtn) {
     119                        confirmBtn.style.color = config.buttonTextColor;
     120                        confirmBtn.addEventListener('mouseenter', () => {
     121                            confirmBtn.style.backgroundColor = config.buttonHoverColor;
     122                        });
     123                        confirmBtn.addEventListener('mouseleave', () => {
     124                            confirmBtn.style.backgroundColor = config.accentColor;
     125                        });
     126                    }
     127                   
     128                    // Add accent bar
     129                    const accentBar = document.createElement('div');
     130                    accentBar.style.cssText = `
     131                        position: absolute;
     132                        top: 0;
     133                        left: 0;
     134                        right: 0;
     135                        height: 5px;
     136                        background: ${config.accentColor};
     137                        border-radius: ${config.borderRadius}px ${config.borderRadius}px 0 0;
     138                    `;
     139                    popup.style.position = 'relative';
     140                    popup.insertBefore(accentBar, popup.firstChild);
     141                   
     142                    // Play sound effect if enabled
     143                    if (config.soundEffect) {
     144                        const audio = new Audio('data:audio/wav;base64,U3RlYWx0aCBiZWNhdXNlIHdlIGNhbid0IGhhdmUgYWN0dWFsIHNvdW5kIGZpbGVzIGluIGNvZGU=');
     145                        audio.play().catch(e => console.log('Sound play failed:', e));
     146                    }
     147                },
     148                willClose: () => {
     149                    CookieManager.set('sss_dismissed', '1', config.cookieDays);
     150                   
     151                    // Confetti effect
     152                    if (config.confettiEffect && typeof confetti === 'function') {
     153                        confetti({ particleCount: 100, spread: 70, origin: { y: 0.6 } });
     154                    }
     155                   
     156                    // Send AJAX request
     157                    if (config.ajaxUrl && config.nonce) {
     158                        fetch(config.ajaxUrl, {
     159                            method: 'POST',
     160                            headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
     161                            body: new URLSearchParams({
     162                                action: 'sss_dismiss',
     163                                nonce: config.nonce
     164                            })
     165                        }).catch(error => console.error('AJAX error:', error));
     166                    }
     167                }
     168            });
     169        }
     170       
     171        // Show popup after delay
     172        const delay = parseInt(config.delayMs) || 500;
     173        setTimeout(showPopup, delay);
    24174    }
    25     document.cookie = name + '=' + encodeURIComponent(value) + expires + '; path=/; SameSite=Lax';
    26   }
    27 
    28   /* ── Main ───────────────────────────────────────────────────────────────── */
    29 
    30   var cfg     = window.sssConfig || {};
    31   var delay   = parseInt(cfg.delayMs,    10) || 500;
    32   var days    = parseInt(cfg.cookieDays, 10) || 7;
    33   var anim    = cfg.animation || 'fade';
    34   var ajaxUrl = cfg.ajaxUrl  || '';
    35   var nonce   = cfg.nonce    || '';
    36 
    37   var overlay     = document.getElementById('sss-overlay');
    38   var closeBtn    = document.getElementById('sss-close-btn');
    39   var dismissBtn  = document.getElementById('sss-dismiss-btn');
    40 
    41   if (!overlay) return; // nothing to do
    42 
    43   // If already dismissed and cookie is set, bail out immediately
    44   if (getCookie('sss_dismissed') === '1') {
    45     overlay.remove();
    46     return;
    47   }
    48 
    49   // Apply animation class
    50   overlay.classList.add('sss-anim-' + anim);
    51 
    52   /* ── Show ───────────────────────────────────────────────────────────────── */
    53 
    54   function showSplash() {
    55     overlay.classList.add('sss-visible');
    56     overlay.removeAttribute('aria-hidden');
    57     // Trap focus inside popup
    58     var focusable = overlay.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
    59     if (focusable.length) focusable[0].focus();
    60   }
    61 
    62   setTimeout(showSplash, delay);
    63 
    64   /* ── Dismiss ────────────────────────────────────────────────────────────── */
    65 
    66   function dismiss() {
    67     overlay.classList.add('sss-hiding');
    68     overlay.classList.remove('sss-visible');
    69 
    70     // Set the cookie client-side for instant effect
    71     setCookie('sss_dismissed', '1', days);
    72 
    73     // Also tell the server (for hooks/analytics) — fire & forget
    74     if (ajaxUrl) {
    75       var fd = new FormData();
    76       fd.append('action', 'sss_dismiss');
    77       fd.append('nonce',  nonce);
    78       fetch(ajaxUrl, { method: 'POST', body: fd, credentials: 'same-origin' })
    79         .catch(function () { /* silently ignore network errors */ });
     175   
     176    // Initialize when DOM is ready
     177    if (document.readyState === 'loading') {
     178        document.addEventListener('DOMContentLoaded', init);
     179    } else {
     180        init();
    80181    }
    81 
    82     // Remove from DOM after transition
    83     overlay.addEventListener('transitionend', function onEnd() {
    84       overlay.removeEventListener('transitionend', onEnd);
    85       overlay.remove();
    86     });
    87   }
    88 
    89   if (closeBtn)   closeBtn.addEventListener('click',   dismiss);
    90   if (dismissBtn) dismissBtn.addEventListener('click', dismiss);
    91 
    92   // Click on the dark overlay area (outside popup) also dismisses
    93   overlay.addEventListener('click', function (e) {
    94     if (e.target === overlay) dismiss();
    95   });
    96 
    97   // Escape key
    98   document.addEventListener('keydown', function (e) {
    99     if (e.key === 'Escape' || e.keyCode === 27) dismiss();
    100   });
    101 
    102182})();
  • forameal-splash-screen/trunk/includes/ajax.php

    r3510361 r3510687  
    11<?php
    22/**
    3  * AJAX: record that this visitor dismissed the splash.
    4  * Cookie is set on the client in JS; this endpoint exists as a
    5  * server-side hook so themes/plugins can react to the dismiss event.
     3 * AJAX handler for Smart Splash Screen
     4 *
     5 * @package SmartSplashScreen
    66 */
    77
    88if ( ! defined( 'ABSPATH' ) ) exit;
    99
     10// Register AJAX actions
    1011add_action( 'wp_ajax_nopriv_sss_dismiss', 'sss_ajax_dismiss' );
    11 add_action( 'wp_ajax_sss_dismiss',        'sss_ajax_dismiss' );
     12add_action( 'wp_ajax_sss_dismiss', 'sss_ajax_dismiss' );
    1213
    1314function sss_ajax_dismiss() {
    14     // Verify nonce — prevents CSRF abuse
     15    // Verify nonce
    1516    if ( ! check_ajax_referer( 'sss_dismiss', 'nonce', false ) ) {
    1617        wp_send_json_error( array( 'message' => 'Invalid request.' ), 403 );
    1718    }
    18 
     19   
    1920    /**
    20      * Fires when a visitor dismisses the splash screen.
    21      * Hook in to log analytics, update user meta, etc.
    22      *
    23      * @since 1.0.0
     21     * Fires when a visitor dismisses the splash screen
     22     * Hook into this action for analytics, logging, etc.
    2423     */
    2524    do_action( 'sss_splash_dismissed' );
    26 
    27     wp_send_json_success( array( 'dismissed' => true ) );
     25   
     26    wp_send_json_success( array(
     27        'dismissed' => true,
     28        'message' => 'Splash screen dismissed successfully'
     29    ) );
    2830}
  • forameal-splash-screen/trunk/includes/frontend.php

    r3510361 r3510687  
    11<?php
    22/**
    3  * Frontend: decides when to show the splash and enqueues assets.
     3 * Frontend functionality for Smart Splash Screen
     4 *
     5 * @package SmartSplashScreen
    46 */
    57
    68if ( ! defined( 'ABSPATH' ) ) exit;
    79
    8 add_action( 'wp_enqueue_scripts', 'sss_enqueue_assets' );
    9 add_action( 'wp_footer',          'sss_render_popup',   20 );
     10// Initialize frontend
     11add_action( 'wp', 'sss_initialize_frontend' );
     12function sss_initialize_frontend() {
     13    if ( sss_should_show() ) {
     14        add_action( 'wp_enqueue_scripts', 'sss_enqueue_assets' );
     15    }
     16}
    1017
    11 // ─── Should we show the splash on this request? ───────────────────────────────
     18// Check if splash should show
    1219function sss_should_show() {
    1320    $opts = get_option( 'sss_settings', array() );
    14 
    15     if ( empty( $opts['enabled'] ) || $opts['enabled'] !== '1' ) return false;
    16     if ( is_admin() ) return false;
    17 
     21   
     22    if ( empty( $opts['enabled'] ) || $opts['enabled'] !== '1' ) {
     23        return false;
     24    }
     25   
     26    if ( is_admin() ) {
     27        return false;
     28    }
     29   
     30    if ( isset( $_COOKIE['sss_dismissed'] ) && $_COOKIE['sss_dismissed'] === '1' ) {
     31        return false;
     32    }
     33   
    1834    $show_on = $opts['show_on'] ?? 'all';
    19 
    20     if ( $show_on === 'front' && ! is_front_page() ) return false;
    21 
     35   
     36    if ( $show_on === 'front' && ! is_front_page() ) {
     37        return false;
     38    }
     39   
    2240    if ( $show_on === 'custom' ) {
    2341        $ids = array_map( 'absint', explode( ',', $opts['custom_pages'] ?? '' ) );
    2442        $ids = array_filter( $ids );
    25         if ( empty( $ids ) || ! in_array( get_the_ID(), $ids, true ) ) return false;
     43        if ( empty( $ids ) || ! in_array( get_the_ID(), $ids, true ) ) {
     44            return false;
     45        }
    2646    }
    27 
     47   
    2848    return true;
    2949}
    3050
    31 // ─── Enqueue CSS + JS only when needed ───────────────────────────────────────
     51// Enqueue assets
    3252function sss_enqueue_assets() {
    33     if ( ! sss_should_show() ) return;
    34 
    3553    $opts = get_option( 'sss_settings', array() );
    36 
     54   
     55    // Enqueue SweetAlert2
     56    wp_enqueue_script(
     57        'sweetalert2',
     58        'https://cdn.jsdelivr.net/npm/sweetalert2@11',
     59        array(),
     60        '11.10.0',
     61        true
     62    );
     63   
     64    // Enqueue custom CSS
    3765    wp_enqueue_style(
    3866        'sss-style',
    … …  
    4169        SSS_VERSION
    4270    );
    43 
     71   
     72    // Enqueue custom JS
    4473    wp_enqueue_script(
    4574        'sss-script',
    4675        SSS_PLUGIN_URL . 'assets/js/splash.js',
    47         array(),          // zero dependencies — no jQuery required
     76        array( 'sweetalert2' ),
    4877        SSS_VERSION,
    49         true              // load in footer
     78        true
    5079    );
    51 
    52     // Pass PHP settings to JS safely via wp_localize_script
     80   
     81    // Pass settings to JS
    5382    wp_localize_script( 'sss-script', 'sssConfig', array(
    54         'ajaxUrl'    => admin_url( 'admin-ajax.php' ),
    55         'nonce'      => wp_create_nonce( 'sss_dismiss' ),
     83        'ajaxUrl' => admin_url( 'admin-ajax.php' ),
     84        'nonce' => wp_create_nonce( 'sss_dismiss' ),
    5685        'cookieDays' => absint( $opts['cookie_days'] ?? 7 ),
    57         'delayMs'    => absint( $opts['delay_ms']    ?? 500 ),
    58         'animation'  => sanitize_key( $opts['animation'] ?? 'fade' ),
     86        'delayMs' => absint( $opts['delay_ms'] ?? 500 ),
     87        'title' => wp_kses_post( $opts['title'] ?? 'Welcome!' ),
     88        'message' => wp_kses_post( $opts['message'] ?? '' ),
     89        'shortcode' => sanitize_text_field( $opts['shortcode'] ?? '' ),
     90        'buttonText' => esc_html( $opts['button_text'] ?? 'Continue' ),
     91        'accentColor' => sanitize_hex_color( $opts['accent_color'] ?? '#6ee7b7' ),
     92        'bgColor' => sanitize_hex_color( $opts['bg_color'] ?? '#0f0f0f' ),
     93        'overlayOpacity' => absint( $opts['overlay_opacity'] ?? 85 ),
     94        'animation' => sanitize_key( $opts['animation'] ?? 'fade' ),
     95        'iconType' => sanitize_text_field( $opts['icon_type'] ?? 'info' ),
     96        'customIcon' => esc_url_raw( $opts['custom_icon'] ?? '' ),
     97        'titleColor' => sanitize_hex_color( $opts['title_color'] ?? '#1e293b' ),
     98        'messageColor' => sanitize_hex_color( $opts['message_color'] ?? '#475569' ),
     99        'buttonTextColor' => sanitize_hex_color( $opts['button_text_color'] ?? '#064e3b' ),
     100        'buttonHoverColor' => sanitize_hex_color( $opts['button_hover_color'] ?? '#059669' ),
     101        'borderRadius' => absint( $opts['border_radius'] ?? 20 ),
     102        'popupWidth' => absint( $opts['popup_width'] ?? 600 ),
     103        'showCloseButton' => $opts['show_close_button'] === '1',
     104        'allowOutsideClick' => $opts['allow_outside_click'] === '1',
     105        'showTimer' => $opts['show_timer'] === '1',
     106        'timerSeconds' => absint( $opts['timer_seconds'] ?? 5 ),
     107        'buttonShape' => sanitize_key( $opts['confirm_button_shape'] ?? 'round' ),
     108        'popupShadow' => $opts['popup_shadow'] === '1',
     109        'confettiEffect' => $opts['confetti_effect'] === '1',
     110        'soundEffect' => $opts['sound_effect'] === '1',
    59111    ) );
    60112}
    61 
    62 // ─── Render the popup HTML ────────────────────────────────────────────────────
    63 function sss_render_popup() {
    64     if ( ! sss_should_show() ) return;
    65 
    66     $opts        = get_option( 'sss_settings', array() );
    67     $title       = wp_kses_post( $opts['title']       ?? 'Welcome!' );
    68     $message     = wp_kses_post( $opts['message']     ?? '' );
    69     $shortcode   = sanitize_text_field( $opts['shortcode']   ?? '' );
    70     $button_text = esc_html( $opts['button_text'] ?? 'Continue to site' );
    71     $bg_color    = sanitize_hex_color( $opts['bg_color']    ?? '#0f0f0f' );
    72     $opacity     = absint( $opts['overlay_opacity'] ?? 85 );
    73     $accent      = sanitize_hex_color( $opts['accent_color'] ?? '#6ee7b7' );
    74 
    75     // Convert hex+opacity to rgba for the overlay
    76     list( $r, $g, $b ) = sscanf( ltrim( $bg_color, '#' ), '%02x%02x%02x' );
    77     $alpha            = round( $opacity / 100, 2 );
    78     $overlay_rgba     = "rgba({$r},{$g},{$b},{$alpha})";
    79     ?>
    80     <div
    81         id="sss-overlay"
    82         class="sss-overlay"
    83         role="dialog"
    84         aria-modal="true"
    85         aria-label="<?php esc_attr_e( 'Welcome popup', 'smart-splash' ); ?>"
    86         style="background:<?php echo esc_attr( $overlay_rgba ); ?>;"
    87     >
    88         <div
    89             class="sss-popup"
    90             style="--sss-accent:<?php echo esc_attr( $accent ); ?>;"
    91         >
    92             <button
    93                 class="sss-close"
    94                 id="sss-close-btn"
    95                 aria-label="<?php esc_attr_e( 'Close', 'smart-splash' ); ?>"
    96             >&#x2715;</button>
    97 
    98             <?php if ( $title ) : ?>
    99                 <h2 class="sss-title"><?php echo $title; ?></h2>
    100             <?php endif; ?>
    101 
    102             <?php if ( $message ) : ?>
    103                 <div class="sss-message"><?php echo $message; ?></div>
    104             <?php endif; ?>
    105 
    106             <?php if ( $shortcode ) : ?>
    107                 <div class="sss-shortcode-content">
    108                     <?php echo do_shortcode( '[' . $shortcode . ']' ); ?>
    109                 </div>
    110             <?php endif; ?>
    111 
    112             <button class="sss-btn" id="sss-dismiss-btn">
    113                 <?php echo $button_text; ?>
    114             </button>
    115         </div>
    116     </div>
    117     <?php
    118 }
  • forameal-splash-screen/trunk/includes/settings.php

    r3510367 r3510687  
    11<?php
    22/**
    3  * Admin settings page for Smart Splash Screen.
     3 * Admin Settings Page for Smart Splash Screen
     4 * Version: 2.1.0
     5 *
     6 * @package SmartSplashScreen
    47 */
    58
    69if ( ! defined( 'ABSPATH' ) ) exit;
    710
    8 // ─── Register activation defaults ────────────────────────────────────────────
    9 register_activation_hook( SSS_PLUGIN_DIR . 'smart-splash-screen.php', 'sss_activate' );
    10 function sss_activate() {
    11     $defaults = array(
    12         'enabled'          => '1',
    13         'title'            => 'Welcome!',
    14         'message'          => 'Thanks for visiting. Here is something special for you.',
    15         'shortcode'        => '',
    16         'button_text'      => 'Continue to site',
    17         'cookie_days'      => '7',
    18         'show_on'          => 'all',          // all | front | custom
    19         'custom_pages'     => '',
    20         'bg_color'         => '#0f0f0f',
    21         'overlay_opacity'  => '85',
    22         'accent_color'     => '#6ee7b7',
    23         'delay_ms'         => '500',
    24         'animation'        => 'fade',         // fade | slide | zoom
    25     );
    26     add_option( 'sss_settings', $defaults );
    27 }
    28 
    29 // ─── Settings page wiring ────────────────────────────────────────────────────
    30 add_action( 'admin_menu',  'sss_add_admin_menu' );
    31 add_action( 'admin_init',  'sss_register_settings' );
     11// =============================================
     12// ADMIN MENU & INITIALIZATION
     13// =============================================
     14
     15add_action( 'admin_menu', 'sss_add_admin_menu' );
     16add_action( 'admin_init', 'sss_register_settings' );
    3217add_action( 'admin_enqueue_scripts', 'sss_admin_assets' );
    3318
    … …  
    4429function sss_admin_assets( $hook ) {
    4530    if ( $hook !== 'settings_page_smart-splash-screen' ) return;
    46     // Inline minimal admin styles — no extra HTTP request
    47     wp_add_inline_style( 'wp-admin', sss_admin_inline_css() );
    48 }
     31   
     32    wp_enqueue_style( 'wp-color-picker' );
     33    wp_enqueue_script( 'wp-color-picker' );
     34    wp_enqueue_script( 'jquery' );
     35}
     36
     37// =============================================
     38// REGISTER SETTINGS
     39// =============================================
    4940
    5041function sss_register_settings() {
    … …  
    5445        array(
    5546            'sanitize_callback' => 'sss_sanitize_settings',
    56             'default'           => array(),
     47            'default' => array(),
    5748        )
    5849    );
    59 
    60     // Section: General
    61     add_settings_section( 'sss_general', __( 'General', 'smart-splash' ), '__return_false', 'smart-splash-screen' );
    62 
    63     $general_fields = array(
    64         array( 'sss_enabled',         __( 'Enable splash screen', 'smart-splash' ),  'sss_field_checkbox',  'enabled' ),
    65         array( 'sss_title',           __( 'Popup title', 'smart-splash' ),            'sss_field_text',      'title' ),
    66         array( 'sss_message',         __( 'Popup message', 'smart-splash' ),          'sss_field_textarea',  'message' ),
    67         array( 'sss_shortcode',       __( 'Embed shortcode (optional)', 'smart-splash' ), 'sss_field_text', 'shortcode' ),
    68         array( 'sss_button_text',     __( 'Dismiss button text', 'smart-splash' ),   'sss_field_text',      'button_text' ),
    69         array( 'sss_show_on',         __( 'Show on', 'smart-splash' ),                'sss_field_show_on',   'show_on' ),
    70         array( 'sss_custom_pages',    __( 'Page IDs (comma-separated)', 'smart-splash' ), 'sss_field_text', 'custom_pages' ),
    71     );
    72 
    73     foreach ( $general_fields as $f ) {
    74         add_settings_field( $f[0], $f[1], $f[2], 'smart-splash-screen', 'sss_general', array( 'key' => $f[3] ) );
    75     }
    76 
    77     // Section: Behaviour
    78     add_settings_section( 'sss_behaviour', __( 'Behaviour', 'smart-splash' ), '__return_false', 'smart-splash-screen' );
    79 
    80     $behaviour_fields = array(
    81         array( 'sss_cookie_days', __( 'Hide for (days after dismiss)', 'smart-splash' ), 'sss_field_number', 'cookie_days' ),
    82         array( 'sss_delay_ms',    __( 'Delay before showing (ms)', 'smart-splash' ),     'sss_field_number', 'delay_ms' ),
    83         array( 'sss_animation',   __( 'Entry animation', 'smart-splash' ),               'sss_field_animation', 'animation' ),
    84     );
    85     foreach ( $behaviour_fields as $f ) {
    86         add_settings_field( $f[0], $f[1], $f[2], 'smart-splash-screen', 'sss_behaviour', array( 'key' => $f[3] ) );
    87     }
    88 
    89     // Section: Appearance
    90     add_settings_section( 'sss_appearance', __( 'Appearance', 'smart-splash' ), '__return_false', 'smart-splash-screen' );
    91 
    92     $appearance_fields = array(
    93         array( 'sss_bg_color',        __( 'Overlay background color', 'smart-splash' ), 'sss_field_color',  'bg_color' ),
    94         array( 'sss_overlay_opacity', __( 'Overlay opacity (%)', 'smart-splash' ),      'sss_field_number', 'overlay_opacity' ),
    95         array( 'sss_accent_color',    __( 'Accent / button color', 'smart-splash' ),    'sss_field_color',  'accent_color' ),
    96     );
    97     foreach ( $appearance_fields as $f ) {
    98         add_settings_field( $f[0], $f[1], $f[2], 'smart-splash-screen', 'sss_appearance', array( 'key' => $f[3] ) );
    99     }
    100 }
    101 
    102 // ─── Sanitize ─────────────────────────────────────────────────────────────────
    103 function sss_sanitize_settings( $input ) {
    104     $clean = array();
    105     $old   = get_option( 'sss_settings', array() );
    106 
    107     $clean['enabled']         = ! empty( $input['enabled'] ) ? '1' : '0';
    108     $clean['title']           = sanitize_text_field( $input['title'] ?? '' );
    109     $clean['message']         = wp_kses_post( $input['message'] ?? '' );
    110     $clean['shortcode']       = sanitize_text_field( $input['shortcode'] ?? '' );
    111     $clean['button_text']     = sanitize_text_field( $input['button_text'] ?? 'Continue to site' );
    112     $clean['show_on']         = in_array( $input['show_on'] ?? '', array( 'all', 'front', 'custom' ), true ) ? $input['show_on'] : 'all';
    113     $clean['custom_pages']    = sanitize_text_field( $input['custom_pages'] ?? '' );
    114     $clean['cookie_days']     = absint( $input['cookie_days'] ?? 7 );
    115     $clean['delay_ms']        = absint( $input['delay_ms'] ?? 500 );
    116     $clean['animation']       = in_array( $input['animation'] ?? '', array( 'fade', 'slide', 'zoom' ), true ) ? $input['animation'] : 'fade';
    117     $clean['bg_color']        = sanitize_hex_color( $input['bg_color'] ?? '#0f0f0f' ) ?: '#0f0f0f';
    118     $clean['overlay_opacity'] = min( 100, max( 0, absint( $input['overlay_opacity'] ?? 85 ) ) );
    119     $clean['accent_color']    = sanitize_hex_color( $input['accent_color'] ?? '#6ee7b7' ) ?: '#6ee7b7';
    120 
    121     return $clean;
    122 }
    123 
    124 // ─── Field renderers ──────────────────────────────────────────────────────────
     50   
     51    // Content Section
     52    add_settings_section( 'sss_content_section', '', '__return_false', 'smart-splash-screen' );
     53    add_settings_field( 'sss_enabled', 'Enable Splash Screen', 'sss_field_switch', 'smart-splash-screen', 'sss_content_section', array( 'key' => 'enabled' ) );
     54    add_settings_field( 'sss_title', 'Popup Title', 'sss_field_text', 'smart-splash-screen', 'sss_content_section', array( 'key' => 'title' ) );
     55    add_settings_field( 'sss_message', 'Popup Message', 'sss_field_textarea', 'smart-splash-screen', 'sss_content_section', array( 'key' => 'message' ) );
     56    add_settings_field( 'sss_shortcode', 'Embed Shortcode', 'sss_field_text', 'smart-splash-screen', 'sss_content_section', array( 'key' => 'shortcode' ) );
     57    add_settings_field( 'sss_button_text', 'Button Text', 'sss_field_text', 'smart-splash-screen', 'sss_content_section', array( 'key' => 'button_text' ) );
     58   
     59    // Icon Section
     60    add_settings_section( 'sss_icon_section', '', '__return_false', 'smart-splash-screen' );
     61    add_settings_field( 'sss_icon_type', 'Icon Type', 'sss_field_icon_type', 'smart-splash-screen', 'sss_icon_section', array( 'key' => 'icon_type' ) );
     62    add_settings_field( 'sss_custom_icon', 'Custom Icon URL', 'sss_field_text', 'smart-splash-screen', 'sss_icon_section', array( 'key' => 'custom_icon' ) );
     63   
     64    // Color Section
     65    add_settings_section( 'sss_color_section', '', '__return_false', 'smart-splash-screen' );
     66    add_settings_field( 'sss_title_color', 'Title Color', 'sss_field_color', 'smart-splash-screen', 'sss_color_section', array( 'key' => 'title_color' ) );
     67    add_settings_field( 'sss_message_color', 'Message Color', 'sss_field_color', 'smart-splash-screen', 'sss_color_section', array( 'key' => 'message_color' ) );
     68    add_settings_field( 'sss_accent_color', 'Button Background', 'sss_field_color', 'smart-splash-screen', 'sss_color_section', array( 'key' => 'accent_color' ) );
     69    add_settings_field( 'sss_button_text_color', 'Button Text Color', 'sss_field_color', 'smart-splash-screen', 'sss_color_section', array( 'key' => 'button_text_color' ) );
     70    add_settings_field( 'sss_button_hover_color', 'Button Hover Color', 'sss_field_color', 'smart-splash-screen', 'sss_color_section', array( 'key' => 'button_hover_color' ) );
     71    add_settings_field( 'sss_bg_color', 'Overlay Background', 'sss_field_color', 'smart-splash-screen', 'sss_color_section', array( 'key' => 'bg_color' ) );
     72    add_settings_field( 'sss_overlay_opacity', 'Overlay Opacity (%)', 'sss_field_number', 'smart-splash-screen', 'sss_color_section', array( 'key' => 'overlay_opacity' ) );
     73   
     74    // Appearance Section
     75    add_settings_section( 'sss_appearance_section', '', '__return_false', 'smart-splash-screen' );
     76    add_settings_field( 'sss_border_radius', 'Border Radius (px)', 'sss_field_number', 'smart-splash-screen', 'sss_appearance_section', array( 'key' => 'border_radius' ) );
     77    add_settings_field( 'sss_popup_width', 'Popup Width (px)', 'sss_field_number', 'smart-splash-screen', 'sss_appearance_section', array( 'key' => 'popup_width' ) );
     78    add_settings_field( 'sss_confirm_button_shape', 'Button Shape', 'sss_field_button_shape', 'smart-splash-screen', 'sss_appearance_section', array( 'key' => 'confirm_button_shape' ) );
     79    add_settings_field( 'sss_popup_shadow', 'Enable Shadow', 'sss_field_switch', 'smart-splash-screen', 'sss_appearance_section', array( 'key' => 'popup_shadow' ) );
     80   
     81    // Behavior Section
     82    add_settings_section( 'sss_behavior_section', '', '__return_false', 'smart-splash-screen' );
     83    add_settings_field( 'sss_cookie_days', 'Cookie Duration (days)', 'sss_field_number', 'smart-splash-screen', 'sss_behavior_section', array( 'key' => 'cookie_days' ) );
     84    add_settings_field( 'sss_delay_ms', 'Delay before showing (ms)', 'sss_field_number', 'smart-splash-screen', 'sss_behavior_section', array( 'key' => 'delay_ms' ) );
     85    add_settings_field( 'sss_animation', 'Animation Effect', 'sss_field_animation', 'smart-splash-screen', 'sss_behavior_section', array( 'key' => 'animation' ) );
     86    add_settings_field( 'sss_show_close_button', 'Show Close Button', 'sss_field_switch', 'smart-splash-screen', 'sss_behavior_section', array( 'key' => 'show_close_button' ) );
     87    add_settings_field( 'sss_allow_outside_click', 'Allow Outside Click', 'sss_field_switch', 'smart-splash-screen', 'sss_behavior_section', array( 'key' => 'allow_outside_click' ) );
     88    add_settings_field( 'sss_show_timer', 'Auto-close Timer', 'sss_field_switch', 'smart-splash-screen', 'sss_behavior_section', array( 'key' => 'show_timer' ) );
     89    add_settings_field( 'sss_timer_seconds', 'Timer Duration (seconds)', 'sss_field_number', 'smart-splash-screen', 'sss_behavior_section', array( 'key' => 'timer_seconds' ) );
     90   
     91    // Effects Section
     92    add_settings_section( 'sss_effects_section', '', '__return_false', 'smart-splash-screen' );
     93    add_settings_field( 'sss_confetti_effect', 'Confetti Effect', 'sss_field_switch', 'smart-splash-screen', 'sss_effects_section', array( 'key' => 'confetti_effect' ) );
     94    add_settings_field( 'sss_sound_effect', 'Sound Effect', 'sss_field_switch', 'smart-splash-screen', 'sss_effects_section', array( 'key' => 'sound_effect' ) );
     95   
     96    // Targeting Section
     97    add_settings_section( 'sss_targeting_section', '', '__return_false', 'smart-splash-screen' );
     98    add_settings_field( 'sss_show_on', 'Show on', 'sss_field_show_on', 'smart-splash-screen', 'sss_targeting_section', array( 'key' => 'show_on' ) );
     99    add_settings_field( 'sss_custom_pages', 'Specific Page IDs', 'sss_field_text', 'smart-splash-screen', 'sss_targeting_section', array( 'key' => 'custom_pages' ) );
     100}
     101
     102// =============================================
     103// FIELD RENDERERS
     104// =============================================
     105
    125106function sss_get( $key ) {
    126107    $opts = get_option( 'sss_settings', array() );
    127     return $opts[ $key ] ?? '';
     108    return isset( $opts[ $key ] ) ? $opts[ $key ] : '';
    128109}
    129110
    … …  
    146127}
    147128
    148 function sss_field_checkbox( $args ) {
    149     $key     = $args['key'];
     129function sss_field_switch( $args ) {
     130    $key = $args['key'];
    150131    $checked = checked( '1', sss_get( $key ), false );
     132    echo "<label class='sss-switch'>";
    151133    echo "<input type='checkbox' name='sss_settings[{$key}]' value='1' {$checked} />";
     134    echo "<span class='sss-slider'></span>";
     135    echo "</label>";
    152136}
    153137
    … …  
    155139    $key = $args['key'];
    156140    $val = esc_attr( sss_get( $key ) );
    157     echo "<input type='color' name='sss_settings[{$key}]' value='{$val}' />";
    158 }
    159 
    160 function sss_field_show_on( $args ) {
    161     $key     = $args['key'];
     141    echo "<input type='text' name='sss_settings[{$key}]' value='{$val}' class='sss-color-field' data-default-color='{$val}' />";
     142}
     143
     144function sss_field_icon_type( $args ) {
     145    $key = $args['key'];
    162146    $current = sss_get( $key );
    163     $opts    = array( 'all' => 'All pages', 'front' => 'Front page only', 'custom' => 'Specific pages (IDs below)' );
    164     echo "<select name='sss_settings[{$key}]'>";
    165     foreach ( $opts as $val => $label ) {
     147    $options = array(
     148        'none' => 'No Icon',
     149        'info' => 'Info',
     150        'success' => 'Success',
     151        'warning' => 'Warning',
     152        'error' => 'Error',
     153        'question' => 'Question',
     154        'custom' => 'Custom Image',
     155    );
     156    echo "<select name='sss_settings[{$key}]' id='icon_type' class='sss-select'>";
     157    foreach ( $options as $val => $label ) {
    166158        $sel = selected( $current, $val, false );
    167159        echo "<option value='" . esc_attr( $val ) . "' {$sel}>" . esc_html( $label ) . "</option>";
    … …  
    170162}
    171163
    172 function sss_field_animation( $args ) {
    173     $key     = $args['key'];
     164function sss_field_button_shape( $args ) {
     165    $key = $args['key'];
    174166    $current = sss_get( $key );
    175     $opts    = array( 'fade' => 'Fade in', 'slide' => 'Slide up', 'zoom' => 'Zoom in' );
    176     echo "<select name='sss_settings[{$key}]'>";
    177     foreach ( $opts as $val => $label ) {
     167    $options = array(
     168        'round' => 'Round',
     169        'square' => 'Square',
     170        'pill' => 'Pill Shape',
     171    );
     172    echo "<select name='sss_settings[{$key}]' class='sss-select'>";
     173    foreach ( $options as $val => $label ) {
    178174        $sel = selected( $current, $val, false );
    179175        echo "<option value='" . esc_attr( $val ) . "' {$sel}>" . esc_html( $label ) . "</option>";
    … …  
    182178}
    183179
    184 // ─── Render admin page ────────────────────────────────────────────────────────
     180function sss_field_show_on( $args ) {
     181    $key = $args['key'];
     182    $current = sss_get( $key );
     183    $options = array(
     184        'all' => 'All Pages',
     185        'front' => 'Front Page Only',
     186        'custom' => 'Specific Pages',
     187    );
     188    echo "<select name='sss_settings[{$key}]' id='show_on' class='sss-select'>";
     189    foreach ( $options as $val => $label ) {
     190        $sel = selected( $current, $val, false );
     191        echo "<option value='" . esc_attr( $val ) . "' {$sel}>" . esc_html( $label ) . "</option>";
     192    }
     193    echo "</select>";
     194}
     195
     196function sss_field_animation( $args ) {
     197    $key = $args['key'];
     198    $current = sss_get( $key );
     199    $options = array(
     200        'fade' => 'Fade',
     201        'slide' => 'Slide',
     202        'zoom' => 'Zoom',
     203    );
     204    echo "<select name='sss_settings[{$key}]' class='sss-select'>";
     205    foreach ( $options as $val => $label ) {
     206        $sel = selected( $current, $val, false );
     207        echo "<option value='" . esc_attr( $val ) . "' {$sel}>" . esc_html( $label ) . "</option>";
     208    }
     209    echo "</select>";
     210}
     211
     212// =============================================
     213// SANITIZE SETTINGS
     214// =============================================
     215
     216function sss_sanitize_settings( $input ) {
     217    $clean = array();
     218   
     219    $clean['enabled'] = ! empty( $input['enabled'] ) ? '1' : '0';
     220    $clean['title'] = sanitize_text_field( $input['title'] ?? 'Welcome!' );
     221    $clean['message'] = wp_kses_post( $input['message'] ?? '' );
     222    $clean['shortcode'] = sanitize_text_field( $input['shortcode'] ?? '' );
     223    $clean['button_text'] = sanitize_text_field( $input['button_text'] ?? 'Continue' );
     224    $clean['show_on'] = in_array( $input['show_on'] ?? '', array( 'all', 'front', 'custom' ) ) ? $input['show_on'] : 'all';
     225    $clean['custom_pages'] = sanitize_text_field( $input['custom_pages'] ?? '' );
     226    $clean['cookie_days'] = absint( $input['cookie_days'] ?? 7 );
     227    $clean['delay_ms'] = absint( $input['delay_ms'] ?? 500 );
     228    $clean['animation'] = in_array( $input['animation'] ?? '', array( 'fade', 'slide', 'zoom' ) ) ? $input['animation'] : 'fade';
     229    $clean['bg_color'] = sanitize_hex_color( $input['bg_color'] ?? '#0f0f0f' ) ?: '#0f0f0f';
     230    $clean['overlay_opacity'] = min( 100, max( 0, absint( $input['overlay_opacity'] ?? 85 ) ) );
     231    $clean['accent_color'] = sanitize_hex_color( $input['accent_color'] ?? '#6ee7b7' ) ?: '#6ee7b7';
     232    $clean['icon_type'] = sanitize_text_field( $input['icon_type'] ?? 'info' );
     233    $clean['custom_icon'] = esc_url_raw( $input['custom_icon'] ?? '' );
     234    $clean['title_color'] = sanitize_hex_color( $input['title_color'] ?? '#1e293b' ) ?: '#1e293b';
     235    $clean['message_color'] = sanitize_hex_color( $input['message_color'] ?? '#475569' ) ?: '#475569';
     236    $clean['button_text_color'] = sanitize_hex_color( $input['button_text_color'] ?? '#064e3b' ) ?: '#064e3b';
     237    $clean['button_hover_color'] = sanitize_hex_color( $input['button_hover_color'] ?? '#059669' ) ?: '#059669';
     238    $clean['border_radius'] = absint( $input['border_radius'] ?? 20 );
     239    $clean['popup_width'] = absint( $input['popup_width'] ?? 600 );
     240    $clean['show_close_button'] = ! empty( $input['show_close_button'] ) ? '1' : '0';
     241    $clean['allow_outside_click'] = ! empty( $input['allow_outside_click'] ) ? '1' : '0';
     242    $clean['show_timer'] = ! empty( $input['show_timer'] ) ? '1' : '0';
     243    $clean['timer_seconds'] = absint( $input['timer_seconds'] ?? 5 );
     244    $clean['confirm_button_shape'] = in_array( $input['confirm_button_shape'] ?? '', array( 'round', 'square', 'pill' ) ) ? $input['confirm_button_shape'] : 'round';
     245    $clean['popup_shadow'] = ! empty( $input['popup_shadow'] ) ? '1' : '0';
     246    $clean['confetti_effect'] = ! empty( $input['confetti_effect'] ) ? '1' : '0';
     247    $clean['sound_effect'] = ! empty( $input['sound_effect'] ) ? '1' : '0';
     248   
     249    return $clean;
     250}
     251
     252// =============================================
     253// RENDER ADMIN PAGE
     254// =============================================
     255
    185256function sss_render_admin_page() {
    186257    if ( ! current_user_can( 'manage_options' ) ) return;
     258   
     259    $settings = get_option( 'sss_settings', array() );
     260    $is_enabled = isset( $settings['enabled'] ) && $settings['enabled'] === '1';
     261    $active_tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : 'content';
    187262    ?>
    188     <div class="wrap sss-admin-wrap">
    189         <div class="sss-admin-header">
    190             <span class="sss-logo">✦</span>
    191             <div class="sss-header-text">
    192                 <h1><?php esc_html_e( 'Smart Splash Screen', 'smart-splash' ); ?></h1>
    193                 <p class="sss-tagline"><?php esc_html_e( 'Beautiful, cookie-aware popups — zero bloat.', 'smart-splash' ); ?></p>
     263    <div class="wrap">
     264        <style>
     265            /* Main Container */
     266            .sss-admin-wrapper {
     267                max-width: 1100px;
     268                margin: 20px auto;
     269                background: #fff;
     270                border-radius: 12px;
     271                box-shadow: 0 1px 3px rgba(0,0,0,0.08);
     272                overflow: hidden;
     273            }
     274           
     275            /* Header */
     276            .sss-header {
     277                background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     278                padding: 25px 30px;
     279                color: #fff;
     280            }
     281           
     282            .sss-header h1 {
     283                margin: 0;
     284                font-size: 24px;
     285                font-weight: 600;
     286            }
     287           
     288            .sss-header p {
     289                margin: 8px 0 0;
     290                opacity: 0.9;
     291                font-size: 14px;
     292            }
     293           
     294            /* Stats Row */
     295            .sss-stats-row {
     296                display: flex;
     297                background: #f8fafc;
     298                border-bottom: 1px solid #e2e8f0;
     299            }
     300           
     301            .sss-stat-box {
     302                flex: 1;
     303                text-align: center;
     304                padding: 20px;
     305                border-right: 1px solid #e2e8f0;
     306            }
     307           
     308            .sss-stat-box:last-child {
     309                border-right: none;
     310            }
     311           
     312            .sss-stat-icon {
     313                font-size: 28px;
     314                margin-bottom: 8px;
     315            }
     316           
     317            .sss-stat-number {
     318                font-size: 22px;
     319                font-weight: 700;
     320                color: #667eea;
     321            }
     322           
     323            .sss-stat-label {
     324                font-size: 12px;
     325                color: #64748b;
     326                margin-top: 4px;
     327            }
     328           
     329            /* Tabs */
     330            .sss-tabs-wrapper {
     331                background: #fff;
     332                border-bottom: 1px solid #e2e8f0;
     333                padding: 0 25px;
     334                display: flex;
     335                flex-wrap: wrap;
     336                gap: 5px;
     337            }
     338           
     339            .sss-tab-btn {
     340                padding: 12px 20px;
     341                background: none;
     342                border: none;
     343                cursor: pointer;
     344                font-size: 14px;
     345                font-weight: 500;
     346                color: #64748b;
     347                transition: all 0.2s;
     348                position: relative;
     349            }
     350           
     351            .sss-tab-btn:hover {
     352                color: #667eea;
     353                background: #f8fafc;
     354            }
     355           
     356            .sss-tab-btn.active {
     357                color: #667eea;
     358            }
     359           
     360            .sss-tab-btn.active::after {
     361                content: '';
     362                position: absolute;
     363                bottom: -1px;
     364                left: 0;
     365                right: 0;
     366                height: 2px;
     367                background: #667eea;
     368            }
     369           
     370            /* Content Area */
     371            .sss-content-area {
     372                padding: 25px;
     373                min-height: 450px;
     374            }
     375           
     376            .sss-tab-pane {
     377                display: none;
     378            }
     379           
     380            .sss-tab-pane.active {
     381                display: block;
     382                animation: sssFadeIn 0.3s ease;
     383            }
     384           
     385            @keyframes sssFadeIn {
     386                from {
     387                    opacity: 0;
     388                    transform: translateY(10px);
     389                }
     390                to {
     391                    opacity: 1;
     392                    transform: translateY(0);
     393                }
     394            }
     395           
     396            /* Form Table */
     397            .sss-form-table {
     398                width: 100%;
     399                border-collapse: collapse;
     400            }
     401           
     402            .sss-form-table tr {
     403                border-bottom: 1px solid #f0f0f0;
     404            }
     405           
     406            .sss-form-table th {
     407                width: 250px;
     408                padding: 15px 20px 15px 0;
     409                text-align: left;
     410                font-weight: 600;
     411                color: #1e293b;
     412                vertical-align: top;
     413            }
     414           
     415            .sss-form-table td {
     416                padding: 15px 0;
     417                vertical-align: top;
     418            }
     419           
     420            /* Form Inputs */
     421            .regular-text {
     422                width: 100%;
     423                max-width: 400px;
     424                padding: 8px 12px;
     425                border: 1px solid #cbd5e1;
     426                border-radius: 6px;
     427            }
     428           
     429            .large-text {
     430                width: 100%;
     431                max-width: 500px;
     432                padding: 8px 12px;
     433                border: 1px solid #cbd5e1;
     434                border-radius: 6px;
     435                font-family: monospace;
     436            }
     437           
     438            .small-text {
     439                width: 100px;
     440                padding: 8px 12px;
     441                border: 1px solid #cbd5e1;
     442                border-radius: 6px;
     443                text-align: center;
     444            }
     445           
     446            .regular-text:focus,
     447            .large-text:focus,
     448            .small-text:focus,
     449            .sss-select:focus {
     450                border-color: #667eea;
     451                outline: none;
     452                box-shadow: 0 0 0 2px rgba(102,126,234,0.1);
     453            }
     454           
     455            /* Toggle Switch */
     456            .sss-switch {
     457                position: relative;
     458                display: inline-block;
     459                width: 50px;
     460                height: 24px;
     461            }
     462           
     463            .sss-switch input {
     464                opacity: 0;
     465                width: 0;
     466                height: 0;
     467            }
     468           
     469            .sss-slider {
     470                position: absolute;
     471                cursor: pointer;
     472                top: 0;
     473                left: 0;
     474                right: 0;
     475                bottom: 0;
     476                background-color: #cbd5e1;
     477                transition: 0.3s;
     478                border-radius: 24px;
     479            }
     480           
     481            .sss-slider:before {
     482                position: absolute;
     483                content: "";
     484                height: 18px;
     485                width: 18px;
     486                left: 3px;
     487                bottom: 3px;
     488                background-color: white;
     489                transition: 0.3s;
     490                border-radius: 50%;
     491            }
     492           
     493            input:checked + .sss-slider {
     494                background-color: #10b981;
     495            }
     496           
     497            input:checked + .sss-slider:before {
     498                transform: translateX(26px);
     499            }
     500           
     501            /* Color Picker */
     502            .sss-color-field {
     503                width: 60px;
     504                height: 38px;
     505                padding: 2px;
     506                border: 1px solid #cbd5e1;
     507                border-radius: 6px;
     508                cursor: pointer;
     509            }
     510           
     511            /* Select Dropdown */
     512            .sss-select {
     513                padding: 8px 12px;
     514                border: 1px solid #cbd5e1;
     515                border-radius: 6px;
     516                background: #fff;
     517                min-width: 200px;
     518            }
     519           
     520            /* Hire Banner */
     521            .sss-hire-banner {
     522                background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
     523                border-radius: 10px;
     524                padding: 18px 22px;
     525                margin-bottom: 25px;
     526                display: flex;
     527                align-items: center;
     528                justify-content: space-between;
     529                flex-wrap: wrap;
     530                gap: 15px;
     531            }
     532           
     533            .sss-hire-text {
     534                flex: 1;
     535            }
     536           
     537            .sss-hire-text strong {
     538                display: block;
     539                color: #064e3b;
     540                margin-bottom: 4px;
     541            }
     542           
     543            .sss-hire-text p {
     544                margin: 0;
     545                color: #047857;
     546                font-size: 13px;
     547            }
     548           
     549            .sss-hire-btn {
     550                background: #059669;
     551                color: #fff;
     552                padding: 8px 20px;
     553                border-radius: 6px;
     554                text-decoration: none;
     555                font-weight: 600;
     556                font-size: 14px;
     557                transition: all 0.2s;
     558            }
     559           
     560            .sss-hire-btn:hover {
     561                background: #047857;
     562                transform: translateY(-1px);
     563                color: #fff;
     564            }
     565           
     566            /* Notice */
     567            .sss-notice {
     568                padding: 12px 18px;
     569                border-radius: 8px;
     570                margin-bottom: 25px;
     571            }
     572           
     573            .sss-notice.success {
     574                background: #ecfdf5;
     575                border-left: 4px solid #10b981;
     576                color: #064e3b;
     577            }
     578           
     579            .sss-notice.warning {
     580                background: #fffbeb;
     581                border-left: 4px solid #f59e0b;
     582                color: #92400e;
     583            }
     584           
     585            /* Shortcode Box */
     586            .sss-shortcode-box {
     587                background: #f8fafc;
     588                border-radius: 10px;
     589                padding: 20px;
     590                margin-top: 25px;
     591                border: 1px solid #e2e8f0;
     592            }
     593           
     594            .sss-shortcode-box h3 {
     595                margin: 0 0 15px;
     596                font-size: 16px;
     597            }
     598           
     599            .sss-shortcode-item {
     600                background: #fff;
     601                padding: 12px 15px;
     602                margin-bottom: 10px;
     603                border-radius: 8px;
     604                display: flex;
     605                align-items: center;
     606                justify-content: space-between;
     607                flex-wrap: wrap;
     608                gap: 10px;
     609                border: 1px solid #e2e8f0;
     610            }
     611           
     612            .sss-shortcode-code {
     613                font-family: monospace;
     614                background: #f1f5f9;
     615                padding: 4px 10px;
     616                border-radius: 4px;
     617                font-size: 12px;
     618            }
     619           
     620            .sss-copy-btn {
     621                background: #667eea;
     622                color: #fff;
     623                border: none;
     624                padding: 5px 15px;
     625                border-radius: 5px;
     626                cursor: pointer;
     627                font-size: 12px;
     628                transition: all 0.2s;
     629            }
     630           
     631            .sss-copy-btn:hover {
     632                background: #764ba2;
     633            }
     634           
     635            /* Action Buttons */
     636            .sss-actions {
     637                margin-top: 25px;
     638                padding-top: 20px;
     639                border-top: 1px solid #e2e8f0;
     640            }
     641           
     642            /* Responsive */
     643            @media (max-width: 782px) {
     644                .sss-header {
     645                    padding: 20px;
     646                }
     647               
     648                .sss-header h1 {
     649                    font-size: 20px;
     650                }
     651               
     652                .sss-stats-row {
     653                    flex-direction: column;
     654                }
     655               
     656                .sss-stat-box {
     657                    border-right: none;
     658                    border-bottom: 1px solid #e2e8f0;
     659                    padding: 15px;
     660                }
     661               
     662                .sss-stat-box:last-child {
     663                    border-bottom: none;
     664                }
     665               
     666                .sss-tabs-wrapper {
     667                    padding: 0 15px;
     668                }
     669               
     670                .sss-tab-btn {
     671                    padding: 10px 14px;
     672                    font-size: 12px;
     673                }
     674               
     675                .sss-content-area {
     676                    padding: 20px;
     677                }
     678               
     679                .sss-form-table th {
     680                    width: 100%;
     681                    display: block;
     682                    padding-bottom: 5px;
     683                }
     684               
     685                .sss-form-table td {
     686                    display: block;
     687                    padding-top: 0;
     688                }
     689               
     690                .regular-text,
     691                .large-text {
     692                    max-width: 100%;
     693                }
     694               
     695                .sss-hire-banner {
     696                    flex-direction: column;
     697                    text-align: center;
     698                }
     699            }
     700        </style>
     701       
     702        <div class="sss-admin-wrapper">
     703            <!-- Header -->
     704            <div class="sss-header">
     705                <h1>✨ Smart Splash Screen</h1>
     706                <p>Create beautiful, engaging popups that your visitors will love</p>
    194707            </div>
    195         </div>
    196 
    197         <div class="sss-hire-banner">
    198             <div class="sss-hire-inner">
    199                 <div class="sss-hire-avatar">👨‍💻</div>
    200                 <div class="sss-hire-text">
    201                     <strong><?php esc_html_e( 'Plugin built by Susheel — Open to Work!', 'smart-splash' ); ?></strong>
    202                     <p><?php esc_html_e( 'Available for full-time, remote, or freelance WordPress & PHP development opportunities.', 'smart-splash' ); ?></p>
     708           
     709            <!-- Stats -->
     710            <div class="sss-stats-row">
     711                <div class="sss-stat-box">
     712                    <div class="sss-stat-icon">🎨</div>
     713                    <div class="sss-stat-number">25+</div>
     714                    <div class="sss-stat-label">Options</div>
    203715                </div>
    204                 <div class="sss-hire-actions">
    205                     <a href="mailto:susheelhbti@gmail.com" class="sss-hire-btn">
    206                         ✉️ <?php esc_html_e( 'Hire Me', 'smart-splash' ); ?>
    207                     </a>
    208                     <a href="http://susheelonline.com" target="_blank" rel="noopener noreferrer" class="sss-hire-link">
    209                         <?php esc_html_e( 'View Portfolio →', 'smart-splash' ); ?>
    210                     </a>
     716                <div class="sss-stat-box">
     717                    <div class="sss-stat-icon">🍪</div>
     718                    <div class="sss-stat-number">365</div>
     719                    <div class="sss-stat-label">Max Days</div>
     720                </div>
     721                <div class="sss-stat-box">
     722                    <div class="sss-stat-icon">⚡</div>
     723                    <div class="sss-stat-number">500ms</div>
     724                    <div class="sss-stat-label">Delay</div>
     725                </div>
     726                <div class="sss-stat-box">
     727                    <div class="sss-stat-icon">📱</div>
     728                    <div class="sss-stat-number">100%</div>
     729                    <div class="sss-stat-label">Responsive</div>
     730                </div>
     731            </div>
     732           
     733            <!-- Tabs -->
     734            <div class="sss-tabs-wrapper">
     735                <button class="sss-tab-btn <?php echo $active_tab === 'content' ? 'active' : ''; ?>" data-tab="content">📝 Content</button>
     736                <button class="sss-tab-btn <?php echo $active_tab === 'icon' ? 'active' : ''; ?>" data-tab="icon">🎨 Icon</button>
     737                <button class="sss-tab-btn <?php echo $active_tab === 'colors' ? 'active' : ''; ?>" data-tab="colors">🎨 Colors</button>
     738                <button class="sss-tab-btn <?php echo $active_tab === 'appearance' ? 'active' : ''; ?>" data-tab="appearance">📐 Appearance</button>
     739                <button class="sss-tab-btn <?php echo $active_tab === 'behavior' ? 'active' : ''; ?>" data-tab="behavior">⚙️ Behavior</button>
     740                <button class="sss-tab-btn <?php echo $active_tab === 'effects' ? 'active' : ''; ?>" data-tab="effects">✨ Effects</button>
     741                <button class="sss-tab-btn <?php echo $active_tab === 'targeting' ? 'active' : ''; ?>" data-tab="targeting">🎯 Targeting</button>
     742            </div>
     743           
     744            <!-- Content -->
     745            <div class="sss-content-area">
     746                <!-- Hire Banner -->
     747                <div class="sss-hire-banner">
     748                    <div class="sss-hire-text">
     749                        <strong>🚀 Need Custom WordPress Development?</strong>
     750                        <p>Available for freelance work - Custom plugins, themes, and solutions</p>
     751                    </div>
     752                    <a href="mailto:susheelhbti@gmail.com" class="sss-hire-btn">✉️ Hire Me</a>
     753                </div>
     754               
     755                <!-- Status -->
     756                <?php if ( $is_enabled ): ?>
     757                    <div class="sss-notice success">
     758                        ✅ <strong>Smart Splash Screen is active</strong> - Your visitors will see the popup based on your settings
     759                    </div>
     760                <?php else: ?>
     761                    <div class="sss-notice warning">
     762                        ⚠️ <strong>Smart Splash Screen is disabled</strong> - Enable it to start showing popups to your visitors
     763                    </div>
     764                <?php endif; ?>
     765               
     766                <!-- Form -->
     767                <form method="post" action="options.php">
     768                    <?php settings_fields( 'sss_group' ); ?>
     769                   
     770                    <!-- Content Tab -->
     771                    <div id="tab-content" class="sss-tab-pane <?php echo $active_tab === 'content' ? 'active' : ''; ?>">
     772                        <table class="sss-form-table">
     773                            <?php do_settings_fields( 'smart-splash-screen', 'sss_content_section' ); ?>
     774                        </table>
     775                    </div>
     776                   
     777                    <!-- Icon Tab -->
     778                    <div id="tab-icon" class="sss-tab-pane <?php echo $active_tab === 'icon' ? 'active' : ''; ?>">
     779                        <table class="sss-form-table">
     780                            <?php do_settings_fields( 'smart-splash-screen', 'sss_icon_section' ); ?>
     781                        </table>
     782                        <div id="custom-icon-preview" style="margin-top: 20px; <?php echo sss_get('icon_type') !== 'custom' ? 'display:none;' : ''; ?>">
     783                            <table class="sss-form-table">
     784                                <tr>
     785                                    <th>Icon Preview</th>
     786                                    <td>
     787                                        <?php $custom_icon = sss_get('custom_icon'); ?>
     788                                        <?php if ( $custom_icon ): ?>
     789                                            <img src="<?php echo esc_url( $custom_icon ); ?>" style="max-width: 80px; max-height: 80px; border-radius: 10px; border: 1px solid #e2e8f0; padding: 5px;" />
     790                                        <?php else: ?>
     791                                            <p style="color: #64748b; margin: 0;">Enter a URL above to preview your custom icon</p>
     792                                        <?php endif; ?>
     793                                    </td>
     794                                </tr>
     795                            </table>
     796                        </div>
     797                    </div>
     798                   
     799                    <!-- Colors Tab -->
     800                    <div id="tab-colors" class="sss-tab-pane <?php echo $active_tab === 'colors' ? 'active' : ''; ?>">
     801                        <table class="sss-form-table">
     802                            <?php do_settings_fields( 'smart-splash-screen', 'sss_color_section' ); ?>
     803                        </table>
     804                    </div>
     805                   
     806                    <!-- Appearance Tab -->
     807                    <div id="tab-appearance" class="sss-tab-pane <?php echo $active_tab === 'appearance' ? 'active' : ''; ?>">
     808                        <table class="sss-form-table">
     809                            <?php do_settings_fields( 'smart-splash-screen', 'sss_appearance_section' ); ?>
     810                        </table>
     811                    </div>
     812                   
     813                    <!-- Behavior Tab -->
     814                    <div id="tab-behavior" class="sss-tab-pane <?php echo $active_tab === 'behavior' ? 'active' : ''; ?>">
     815                        <table class="sss-form-table">
     816                            <?php do_settings_fields( 'smart-splash-screen', 'sss_behavior_section' ); ?>
     817                        </table>
     818                        <div id="timer-preview" style="margin-top: 20px; <?php echo sss_get('show_timer') !== '1' ? 'display:none;' : ''; ?>">
     819                            <table class="sss-form-table">
     820                                <tr>
     821                                    <th>Timer Preview</th>
     822                                    <td>
     823                                        <div style="background: #f1f5f9; padding: 12px; border-radius: 8px; font-size: 14px;">
     824                                            ⏱️ Popup will auto-close after <strong><?php echo sss_get('timer_seconds'); ?> seconds</strong>
     825                                        </div>
     826                                    </td>
     827                                </tr>
     828                            </table>
     829                        </div>
     830                    </div>
     831                   
     832                    <!-- Effects Tab -->
     833                    <div id="tab-effects" class="sss-tab-pane <?php echo $active_tab === 'effects' ? 'active' : ''; ?>">
     834                        <table class="sss-form-table">
     835                            <?php do_settings_fields( 'smart-splash-screen', 'sss_effects_section' ); ?>
     836                        </table>
     837                    </div>
     838                   
     839                    <!-- Targeting Tab -->
     840                    <div id="tab-targeting" class="sss-tab-pane <?php echo $active_tab === 'targeting' ? 'active' : ''; ?>">
     841                        <table class="sss-form-table">
     842                            <?php do_settings_fields( 'smart-splash-screen', 'sss_targeting_section' ); ?>
     843                        </table>
     844                        <div id="pages-preview" style="margin-top: 20px; <?php echo sss_get('show_on') !== 'custom' ? 'display:none;' : ''; ?>">
     845                            <table class="sss-form-table">
     846                                <tr>
     847                                    <th>Pages Preview</th>
     848                                    <td>
     849                                        <?php
     850                                        $pages_str = sss_get('custom_pages');
     851                                        if ( ! empty( $pages_str ) ) {
     852                                            $pages = explode( ',', $pages_str );
     853                                            echo '<ul style="margin: 0; padding-left: 20px;">';
     854                                            foreach ( $pages as $page_id ) {
     855                                                $page_id = trim( $page_id );
     856                                                if ( is_numeric( $page_id ) ) {
     857                                                    echo '<li>Page ID: ' . esc_html( $page_id ) . '</li>';
     858                                                }
     859                                            }
     860                                            echo '</ul>';
     861                                        } else {
     862                                            echo '<p style="color: #64748b; margin: 0;">Enter page IDs above to see preview</p>';
     863                                        }
     864                                        ?>
     865                                    </td>
     866                                </tr>
     867                            </table>
     868                        </div>
     869                    </div>
     870                   
     871                    <!-- Actions -->
     872                    <div class="sss-actions">
     873                        <?php submit_button( '💾 Save Settings', 'primary', 'submit', false ); ?>
     874                    </div>
     875                </form>
     876               
     877                <!-- Shortcodes -->
     878                <div class="sss-shortcode-box">
     879                    <h3>📋 Shortcodes</h3>
     880                    <div class="sss-shortcode-item">
     881                        <code class="sss-shortcode-code">[smart_splash]</code>
     882                        <span>Force display the splash screen anywhere</span>
     883                        <button class="sss-copy-btn" onclick="copyShortcode('[smart_splash]', this)">Copy</button>
     884                    </div>
     885                    <div class="sss-shortcode-item">
     886                        <code class="sss-shortcode-code">[smart_splash_reset]</code>
     887                        <span>Reset cookie to show popup again</span>
     888                        <button class="sss-copy-btn" onclick="copyShortcode('[smart_splash_reset]', this)">Copy</button>
     889                    </div>
     890                    <div class="sss-shortcode-item">
     891                        <code class="sss-shortcode-code">[smart_splash_reset text="Show Again"]</code>
     892                        <span>Custom link text for reset</span>
     893                        <button class="sss-copy-btn" onclick="copyShortcode('[smart_splash_reset text=\"Show Again\"]', this)">Copy</button>
     894                    </div>
    211895                </div>
    212896            </div>
    213897        </div>
    214 
    215         <?php settings_errors( 'sss_settings' ); ?>
    216 
    217         <form method="post" action="options.php" class="sss-admin-form">
    218             <?php settings_fields( 'sss_group' ); ?>
    219 
    220             <div class="sss-card">
    221                 <h2 class="sss-section-title">⚙️ <?php esc_html_e( 'General', 'smart-splash' ); ?></h2>
    222                 <?php do_settings_fields( 'smart-splash-screen', 'sss_general' ); ?>
    223             </div>
    224 
    225             <div class="sss-card">
    226                 <h2 class="sss-section-title">🎛 <?php esc_html_e( 'Behaviour', 'smart-splash' ); ?></h2>
    227                 <?php do_settings_fields( 'smart-splash-screen', 'sss_behaviour' ); ?>
    228             </div>
    229 
    230             <div class="sss-card">
    231                 <h2 class="sss-section-title">🎨 <?php esc_html_e( 'Appearance', 'smart-splash' ); ?></h2>
    232                 <?php do_settings_fields( 'smart-splash-screen', 'sss_appearance' ); ?>
    233             </div>
    234 
    235             <div class="sss-shortcode-info sss-card">
    236                 <h2 class="sss-section-title">📋 <?php esc_html_e( 'Shortcodes', 'smart-splash' ); ?></h2>
    237                 <p><?php esc_html_e( 'Force the splash to appear anywhere on your site:', 'smart-splash' ); ?></p>
    238                 <code>[smart_splash]</code>
    239                 <p><?php esc_html_e( 'Reset cookie so it shows again for current visitor:', 'smart-splash' ); ?></p>
    240                 <code>[smart_splash_reset]</code>
    241             </div>
    242 
    243             <?php submit_button( __( 'Save Settings', 'smart-splash' ), 'primary sss-save-btn' ); ?>
    244         </form>
    245898    </div>
     899   
     900    <script>
     901    jQuery(document).ready(function($) {
     902        // Initialize color pickers
     903        if (typeof $.fn.wpColorPicker === 'function') {
     904            $('.sss-color-field').wpColorPicker();
     905        }
     906       
     907        // Tab switching
     908        $('.sss-tab-btn').on('click', function() {
     909            var tab = $(this).data('tab');
     910            $('.sss-tab-btn').removeClass('active');
     911            $(this).addClass('active');
     912            $('.sss-tab-pane').removeClass('active');
     913            $('#tab-' + tab).addClass('active');
     914           
     915            // Update URL
     916            var url = new URL(window.location.href);
     917            url.searchParams.set('tab', tab);
     918            window.history.pushState({}, '', url);
     919        });
     920       
     921        // Toggle custom icon preview
     922        $('#icon_type').on('change', function() {
     923            if ($(this).val() === 'custom') {
     924                $('#custom-icon-preview').show();
     925            } else {
     926                $('#custom-icon-preview').hide();
     927            }
     928        });
     929       
     930        // Toggle timer preview
     931        $('#show_timer').on('change', function() {
     932            if ($(this).is(':checked')) {
     933                $('#timer-preview').show();
     934            } else {
     935                $('#timer-preview').hide();
     936            }
     937        });
     938       
     939        // Update timer seconds display
     940        $('input[name="sss_settings[timer_seconds]"]').on('change', function() {
     941            var seconds = $(this).val();
     942            $('#timer-preview strong').text(seconds);
     943        });
     944       
     945        // Toggle pages preview
     946        $('#show_on').on('change', function() {
     947            if ($(this).val() === 'custom') {
     948                $('#pages-preview').show();
     949            } else {
     950                $('#pages-preview').hide();
     951            }
     952        });
     953       
     954        // Update custom icon preview
     955        $('input[name="sss_settings[custom_icon]"]').on('change', function() {
     956            var url = $(this).val();
     957            if (url) {
     958                var img = $('<img>').attr('src', url).css({
     959                    'max-width': '80px',
     960                    'max-height': '80px',
     961                    'border-radius': '10px',
     962                    'border': '1px solid #e2e8f0',
     963                    'padding': '5px'
     964                });
     965                $('#custom-icon-preview td').html(img);
     966            }
     967        });
     968    });
     969   
     970    // Copy shortcode function
     971    function copyShortcode(text, button) {
     972        var tempInput = document.createElement('textarea');
     973        tempInput.value = text;
     974        document.body.appendChild(tempInput);
     975        tempInput.select();
     976        document.execCommand('copy');
     977        document.body.removeChild(tempInput);
     978       
     979        var originalText = button.innerHTML;
     980        button.innerHTML = '✓ Copied!';
     981        setTimeout(function() {
     982            button.innerHTML = originalText;
     983        }, 2000);
     984    }
     985    </script>
    246986    <?php
    247987}
    248 
    249 function sss_admin_inline_css() {
    250     return '
    251     .sss-admin-wrap { max-width: 800px; }
    252     .sss-admin-header { display:flex; align-items:center; gap:12px; margin-bottom:20px; border-bottom:2px solid #6ee7b7; padding-bottom:16px; }
    253     .sss-logo { font-size:28px; flex-shrink:0; }
    254     .sss-header-text h1 { margin:0; font-size:22px; }
    255     .sss-tagline { margin:2px 0 0; color:#666; font-size:13px; }
    256 
    257     /* ── Hire banner ── */
    258     .sss-hire-banner { background:linear-gradient(135deg,#ecfdf5 0%,#d1fae5 100%); border:1.5px solid #6ee7b7; border-radius:10px; padding:18px 22px; margin-bottom:24px; }
    259     .sss-hire-inner { display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
    260     .sss-hire-avatar { font-size:36px; flex-shrink:0; }
    261     .sss-hire-text { flex:1; min-width:200px; }
    262     .sss-hire-text strong { display:block; font-size:14px; color:#064e3b; margin-bottom:3px; }
    263     .sss-hire-text p { margin:0; font-size:13px; color:#047857; }
    264     .sss-hire-actions { display:flex; align-items:center; gap:12px; flex-shrink:0; }
    265     .sss-hire-btn { display:inline-block; background:#059669; color:#fff !important; font-size:13px; font-weight:600; padding:8px 18px; border-radius:6px; text-decoration:none; transition:background .2s; }
    266     .sss-hire-btn:hover { background:#047857; }
    267     .sss-hire-link { font-size:13px; color:#059669 !important; text-decoration:underline; }
    268 
    269     .sss-card { background:#fff; border:1px solid #e2e8f0; border-radius:8px; padding:24px 28px; margin-bottom:20px; }
    270     .sss-section-title { margin-top:0; font-size:15px; border-bottom:1px solid #f1f5f9; padding-bottom:10px; }
    271     .sss-card table { width:100%; }
    272     .sss-card th { width:230px; text-align:left; padding:8px 0; vertical-align:top; padding-top:12px; font-weight:500; }
    273     .sss-card td { padding:8px 0; }
    274     .sss-shortcode-info code { display:inline-block; background:#f8fafc; border:1px solid #e2e8f0; padding:4px 10px; border-radius:4px; font-size:14px; margin:4px 0 12px; }
    275     .sss-save-btn { margin-top:8px !important; background:#6ee7b7 !important; border-color:#34d399 !important; color:#064e3b !important; font-weight:600 !important; }
    276 
    277     @media (max-width:600px) {
    278         .sss-hire-inner { flex-direction:column; align-items:flex-start; }
    279         .sss-hire-actions { width:100%; }
    280     }
    281     ';
    282 }
  • forameal-splash-screen/trunk/includes/shortcode.php

    r3510361 r3510687  
    11<?php
    22/**
    3  * Shortcodes for Smart Splash Screen.
    4  *
    5  *  [smart_splash]        – manually trigger the popup on any page/post.
    6  *  [smart_splash_reset]  – output a link that clears the dismiss cookie.
     3 * Shortcodes for Smart Splash Screen
     4 *
     5 * @package SmartSplashScreen
    76 */
    87
    98if ( ! defined( 'ABSPATH' ) ) exit;
    109
    11 add_shortcode( 'smart_splash',       'sss_shortcode_show' );
     10// Register shortcodes
     11add_shortcode( 'smart_splash', 'sss_shortcode_show' );
    1212add_shortcode( 'smart_splash_reset', 'sss_shortcode_reset' );
    1313
    1414/**
    15  * Force-show the splash on whatever page the shortcode is placed on.
    16  * Works by injecting a tiny inline script that removes the dismiss cookie.
     15 * Force show splash screen
     16 * Usage: [smart_splash]
    1717 */
    1818function sss_shortcode_show( $atts ) {
    1919    $atts = shortcode_atts( array(), $atts, 'smart_splash' );
    20 
    21     // Enqueue assets so the popup is always loaded when the shortcode is used
    22     add_filter( 'sss_force_show', '__return_true' );
    23 
    24     ob_start();
    25     ?>
    26     <script>
    27     document.cookie = "sss_dismissed=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
    28     </script>
    29     <?php
    30     return ob_get_clean();
     20   
     21    // Delete cookie to force show
     22    if ( isset( $_COOKIE['sss_dismissed'] ) ) {
     23        setcookie( 'sss_dismissed', '', time() - 3600, '/' );
     24    }
     25   
     26    return '<!-- Smart Splash Screen: Force show triggered -->';
    3127}
    3228
    3329/**
    34  * Renders an accessible link that, when clicked, clears the dismiss cookie
    35  * and reloads the page so the splash appears again.
    36  * Usage: [smart_splash_reset text="Show welcome popup again"]
     30 * Reset cookie to show splash again
     31 * Usage: [smart_splash_reset text="Show popup again"]
    3732 */
    3833function sss_shortcode_reset( $atts ) {
    3934    $atts = shortcode_atts(
    40         array( 'text' => __( 'Show welcome popup again', 'smart-splash' ) ),
     35        array(
     36            'text' => __( 'Show welcome popup again', 'smart-splash' ),
     37            'class' => 'sss-reset-link'
     38        ),
    4139        $atts,
    4240        'smart_splash_reset'
    4341    );
    44 
     42   
    4543    $text = esc_html( $atts['text'] );
    46 
    47     return '<a href="#" class="sss-reset-link" onclick="'
    48         . "document.cookie='sss_dismissed=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'; location.reload(); return false;"
    49         . '">' . $text . '</a>';
     44    $class = esc_attr( $atts['class'] );
     45   
     46    return '<a href="#" class="' . $class . '" onclick="document.cookie=\'sss_dismissed=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;\'; location.reload(); return false;">' . $text . '</a>';
    5047}
    51 
    52 // Allow force-show from shortcode to override the should-show check
    53 add_filter( 'sss_should_show_override', function( $show ) {
    54     return apply_filters( 'sss_force_show', $show );
    55 } );
  • forameal-splash-screen/trunk/readme.txt

    r3510371 r3510687  
    11=== Smart Splash Screen ===
    2 Contributors:      susheelhbti
    3 Tags:              splash screen, popup, cookie, shortcode, welcome screen
     2Contributors: susheelhbti
     3Tags: splash screen, popup, sweetalert2, welcome screen, cookie, modal
    44Requires at least: 5.8
    5 Tested up to:      6.7
    6 Requires PHP:      7.4
    7 Stable tag:        1.0.1
    8 License:           GPLv2 or later
    9 License URI:       https://www.gnu.org/licenses/gpl-2.0.html
     5Tested up to: 6.7
     6Requires PHP: 7.4
     7Stable tag: 2.1.0
     8License: GPLv2 or later
     9License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 A modern, secure, cookie-aware splash screen / popup plugin with AJAX dismiss, shortcode support, animations, and a full admin settings panel.
     11A modern, beautiful, fully customizable splash screen plugin powered by SweetAlert2.
    1212
    1313== Description ==
    1414
    15 **Smart Splash Screen** lets you show a beautiful welcome popup to first-time visitors — and then stay out of the way. It uses a cookie so the popup only appears once per visitor (configurable). Everything is controlled from a clean Settings page — no coding required.
     15**Smart Splash Screen** is a professional WordPress plugin that displays beautiful, engaging popups to your visitors. Powered by SweetAlert2, it offers stunning animations, complete customization, and smart cookie-based dismissal.
    1616
    1717= Key Features =
    1818
    19 * ✅ **Enable / disable** with one click
    20 * 🍪 **Cookie control** — choose how many days to suppress the popup after dismiss
    21 * ⚡ **AJAX dismiss** — closes instantly with no page reload; server-side action hook fires on every dismiss
    22 * 📱 **Mobile responsive** — fluid card layout with `clamp()` fluid typography
    23 * 🎬 **3 entry animations** — Fade, Slide-up, or Zoom-in; respects `prefers-reduced-motion`
    24 * 🎨 **Full appearance control** — overlay background color, overlay opacity, and accent / button color
    25 * 📄 **Page targeting** — show on all pages, front page only, or specific page IDs
    26 * ⌨️ **Fully accessible** — `role="dialog"`, `aria-modal`, Escape-key dismissal, focus trapping
    27 * 🔌 **Shortcode support** — embed any shortcode (contact forms, newsletter sign-ups, etc.) inside the popup
    28 * 🛡 **Secure** — nonce-verified AJAX, `wp_kses_post`, `sanitize_hex_color`, zero remote HTTP calls, zero eval
     19✨ **Beautiful Design** - Modern, sleek popups that impress
     20🎨 **Fully Customizable** - Colors, animations, icons, and more
     21🍪 **Smart Cookies** - Configurable dismissal duration
     22⚡ **AJAX Tracking** - Server-side dismiss events
     23📱 **100% Responsive** - Perfect on all devices
     24🎬 **Smooth Animations** - Fade, Slide, Zoom effects
     25🎯 **Page Targeting** - Show on specific pages
     26🔌 **Shortcode Support** - Embed anywhere
     27♿ **Accessible** - Keyboard navigation support
     28🚀 **Lightweight** - Optimized for performance
     29
     30= New in Version 2.1 =
     31
     32✨ 15+ New Customization Options
     33🎨 Custom icon upload support
     34🌈 Full color control
     35📐 Adjustable border radius & width
     36🔘 Multiple button shapes
     37⏰ Auto-close timer
     38✨ Confetti effect on dismiss
     39🔊 Sound effects
    2940
    3041= Shortcodes =
    3142
    32 `[smart_splash]`
    33 Place on any page or post to force-show the popup regardless of the cookie.
     43`[smart_splash]` - Force display the splash screen
     44`[smart_splash_reset]` - Reset cookie to show again
    3445
    35 `[smart_splash_reset text="See welcome popup again"]`
    36 Renders a link that clears the dismiss cookie and reloads the page so the popup re-appears.
     46= Developer Hooks =
    3747
    38 = Developer Hook =
    39 
    40 `do_action( 'sss_splash_dismissed' )` fires every time a visitor dismisses the popup via AJAX. Hook in to log analytics, send events, update user meta, etc.
    41 
    42 = About the Author =
    43 
    44 Plugin developed by **Susheel** (susheelhbti@gmail.com).
    45 I am currently **open to work** — full-time, remote, or freelance WordPress / PHP development roles.
    46 Feel free to reach out: susheelhbti@gmail.com | [sakshamapp.com](http://sakshamapp.com)
     48`do_action( 'sss_splash_dismissed' )` - Fires when popup is dismissed
    4749
    4850== Installation ==
    4951
    50 1. Upload the `smart-splash-screen` folder to `/wp-content/plugins/`, or install directly via **Plugins → Add New → Upload Plugin**.
    51 2. Activate the plugin through the **Plugins** menu in WordPress.
    52 3. Go to **Settings → Smart Splash** to configure the popup content, behaviour, and appearance.
     521. Upload to `/wp-content/plugins/`
     532. Activate through WordPress admin
     543. Go to **Settings → Smart Splash** to configure
    5355
    5456== Frequently Asked Questions ==
    5557
    56 = Will the popup show every time? =
     58= Will it work with any theme? =
     59Yes! SweetAlert2 ensures consistent display across all themes.
    5760
    58 No. After a visitor dismisses it, a cookie is set and the popup will not appear again for the number of days you configure (default: 7 days).
     61= Can I embed forms? =
     62Yes! Enter any shortcode in the settings.
    5963
    60 = Can I embed a contact form or newsletter signup inside the popup? =
     64= Is it mobile friendly? =
     65Yes, fully responsive with touch optimization.
    6166
    62 Yes! Enter your form's shortcode (without the square brackets) in the **Embed shortcode** field in the settings, and it will be rendered inside the popup.
    63 
    64 = How do I make the popup appear again for testing? =
    65 
    66 Use the `[smart_splash_reset]` shortcode, or simply clear your browser cookies and reload the page.
    67 
    68 = Does this plugin use jQuery or any external libraries? =
    69 
    70 No. The frontend JavaScript is plain vanilla JS (~2 KB). There are zero external dependencies and zero remote HTTP requests.
    71 
    72 = Is it accessible? =
    73 
    74 Yes. The popup uses `role="dialog"` and `aria-modal="true"`, traps focus inside the modal while open, supports Escape-key dismissal, and respects the `prefers-reduced-motion` media query.
    75 
    76 = What PHP version do I need? =
    77 
    78 PHP 7.4 or higher is required.
     67= Does it affect performance? =
     68No, it's lightweight and loads only when needed.
    7969
    8070== Screenshots ==
    8171
    82 1. Admin settings page — General section
    83 2. Admin settings page — Appearance section
    84 3. Example popup on the front end (Fade animation)
    85 4. Mobile view of the popup
     721. Beautiful popup display
     732. Admin settings panel
     743. Mobile responsive view
     754. Color customization options
    8676
    8777== Changelog ==
    8878
    89 = 1.0.1 =
    90 * Added `Requires at least`, `Tested up to`, and `Requires PHP` headers to resolve WordPress.org compatibility warning.
    91 * Added "Open to Work" notice in admin settings panel.
    92 * Improved admin UI: responsive hire-me banner, cleaner section spacing.
    93 * README rewritten with full WordPress.org formatting.
     79= 2.1.0 =
     80* 15+ new customization options
     81* Custom icon upload support
     82* Full color customization
     83* Adjustable border radius and width
     84* Multiple button shapes (Round, Square, Pill)
     85* Auto-close timer with progress bar
     86* Confetti effect on dismiss
     87* Sound effects support
     88* Enhanced responsive design
     89* Performance optimizations
     90
     91= 2.0.0 =
     92* Complete rewrite with SweetAlert2
     93* Modern, beautiful interface
     94* Improved animations
     95* Better reliability
    9496
    9597= 1.0.0 =
    96 * Initial release.
    97 * Cookie-aware splash popup with AJAX dismiss.
    98 * Admin settings: title, message, shortcode embed, button text, page targeting, cookie duration, delay, animation, colors.
    99 * Shortcodes: `[smart_splash]` and `[smart_splash_reset]`.
    100 * Accessible markup: `role="dialog"`, `aria-modal`, Escape key, focus trapping.
    101 * Zero external dependencies, zero remote HTTP calls.
     98* Initial release
    10299
    103100== Upgrade Notice ==
    104101
    105 = 1.0.1 =
    106 Fixes the "hasn't been tested with the latest 3 major releases" warning on WordPress.org. Update recommended.
     102= 2.1.0 =
     103Major update with 15+ new customization options. Highly recommended for all users.
  • forameal-splash-screen/trunk/smart-splash-screen.php

    r3510371 r3510687  
    22/**
    33 * Plugin Name:       Smart Splash Screen
    4  * Plugin URI:        https://wordpress.org/plugins/forameal-splash-screen/#description
    5  * Description:       A modern, secure splash/popup screen with cookie control, shortcode support, AJAX dismiss, and a full admin settings panel.
    6  * Version:           1.0.1
    7  * Author:            susheelhbti
    8  * Author URI:        http://sakshamapp.com
     4 * Plugin URI:        https://github.com/susheelhbti/smart-splash-screen
     5 * Description:       A modern, beautiful splash screen/popup plugin powered by SweetAlert2 - fully customizable, cookie-aware, and responsive.
     6 * Version:           2.1.0
     7 * Author:            Susheel
     8 * Author URI:        http://susheelonline.com
    99 * License:           GPL-2.0-or-later
    1010 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    1313 * Tested up to:      6.7
    1414 * Requires PHP:      7.4
     15 *
     16 * @package SmartSplashScreen
    1517 */
    1618
    1719if ( ! defined( 'ABSPATH' ) ) {
    18     exit; // Never allow direct file access
     20    exit;
    1921}
    2022
    21 define( 'SSS_VERSION',     '1.0.1' );
    22 define( 'SSS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    23 define( 'SSS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     23// Define plugin constants
     24define( 'SSS_VERSION',     '2.1.0' );
     25define( 'SSS_PLUGIN_DIR',  plugin_dir_path( __FILE__ ) );
     26define( 'SSS_PLUGIN_URL',  plugin_dir_url( __FILE__ ) );
     27define( 'SSS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
    2428
    25 // ─── Load sub-modules ────────────────────────────────────────────────────────
     29// Load required modules
    2630require_once SSS_PLUGIN_DIR . 'includes/settings.php';
    2731require_once SSS_PLUGIN_DIR . 'includes/shortcode.php';
    2832require_once SSS_PLUGIN_DIR . 'includes/frontend.php';
    2933require_once SSS_PLUGIN_DIR . 'includes/ajax.php';
     34
     35// Activation hook
     36register_activation_hook( __FILE__, 'sss_activate_plugin' );
     37function sss_activate_plugin() {
     38    if ( ! get_option( 'sss_settings' ) ) {
     39        $defaults = array(
     40            'enabled' => '1',
     41            'title' => 'Welcome!',
     42            'message' => 'Thanks for visiting our website!',
     43            'shortcode' => '',
     44            'button_text' => 'Continue to site',
     45            'show_on' => 'all',
     46            'custom_pages' => '',
     47            'cookie_days' => '7',
     48            'delay_ms' => '500',
     49            'animation' => 'fade',
     50            'bg_color' => '#0f0f0f',
     51            'overlay_opacity' => '85',
     52            'accent_color' => '#6ee7b7',
     53            'icon_type' => 'info',
     54            'custom_icon' => '',
     55            'title_color' => '#1e293b',
     56            'message_color' => '#475569',
     57            'button_text_color' => '#064e3b',
     58            'button_hover_color' => '#059669',
     59            'border_radius' => '20',
     60            'popup_width' => '600',
     61            'show_close_button' => '1',
     62            'allow_outside_click' => '1',
     63            'show_timer' => '0',
     64            'timer_seconds' => '5',
     65            'confirm_button_shape' => 'round',
     66            'popup_shadow' => '1',
     67            'confetti_effect' => '0',
     68            'sound_effect' => '0',
     69        );
     70        add_option( 'sss_settings', $defaults );
     71    }
     72}
     73
     74// Deactivation hook
     75register_deactivation_hook( __FILE__, 'sss_deactivate_plugin' );
     76function sss_deactivate_plugin() {
     77    // Clean up if needed
     78    flush_rewrite_rules();
     79}
Note: See TracChangeset for help on using the changeset viewer.