=== PrayerBoard ===
Contributors: motiondigital
Tags: prayer, islamic, prayer-times, mosque, islam
Requires at least: 4.7
Tested up to: 6.8
Requires PHP: 7.0
Stable tag: 1.1.7
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Islamic prayer times with clocks, templates, marquee messages, and auto-refresh for mosque digital displays and mobile devices.

== Description ==

PrayerBoard is a comprehensive WordPress plugin that provides accurate Islamic prayer times using advanced calculation methods. The plugin includes advanced features like multiple calculation methods, customizable prayer time offsets, template displays, marquee messages, and integrated clock functionality.

**Key Features:**

* **Accurate Prayer Times**: Real-time prayer time calculations with automatic API integration
* **Multiple Calculation Methods**: 10 different calculation methods (Muslim World League, ISNA, Egyptian, Makkah, etc.)
* **Timezone Detection**: Browser-based timezone detection with manual override options
* **Hijri Date Support**: Local Hijri date calculations with no external dependencies
* **Integrated Clocks**: Analog and digital clocks with current date display
* **Template System**: 3 pre-designed templates with customizable colors and marquee message integration
* **Marquee Messages**: Create and manage scrolling message displays for announcements and prayers
* **Auto-Refresh**: Configurable page reload at 12:01 AM (location time) or a chosen time to keep displays updated
* **Fullscreen tip**: One-time on-screen hint (smart TV vs keyboard) with F11/fullscreen notes; kiosk-friendly
* **Clean URLs**: SEO-friendly prayer board URLs (/prayer-board/1, /prayer-board/2, /prayer-board/3)
* **Dashboard Widget**: Quick access to all plugin features from WordPress dashboard
* **Customizable Offsets**: Configurable prayer time and iqamah time offsets
* **Jummah Settings**: Customizable Jummah prayer time and duration
* **Responsive Design**: Optimized for various screen sizes including 1920x1080 displays
* **File-Based Templates**: HTML templates in templates/01/, 02/, 03/ for easy customization
* **Clean Architecture**: Optimized codebase with consolidated functions and no redundant code

**Prayer Board Display:**

* `/prayer-board/1` - Left side with slides board
* `/prayer-board/2` - Right side with slides board
* `/prayer-board/3` - Standard no slides board


**Clock and Widget Features:**

* `[pba_analog_clock]` - Displays analog clock with moving hands
* `[pba_digital_clock]` - Digital clock with format options (12/24h, seconds, AM/PM)
* `[pba_current_date]` - Current date with multiple format options
* `[pba_countdown]` - Live countdown to the next prayer (Fajr/Zuhr/Asr/Maghrib/Isha)

**Prayer Time Embeds:**

* `[pba_salah_fajr]`, `[pba_salah_zuhr]`, `[pba_salah_asr]`, `[pba_salah_maghrib]`, `[pba_salah_isha]` - Individual prayer times
* `[pba_iqamah_fajr]`, `[pba_iqamah_zuhr]`, `[pba_iqamah_asr]`, `[pba_iqamah_maghrib]`, `[pba_iqamah_isha]` - Iqamah times
* `[pba_hijri_date]`, `[pba_jummah]`, `[pba_jummah_duration]`, `[pba_sunrise]` - Additional information

**Countdown Embed:**

* `[pba_countdown]` shows a live countdown through Athan → Iqamah states for the next prayer
* Updates every second using browser time in the board location timezone
* After Isha, rolls over to tomorrow’s Fajr

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/md-prayer-board/`
2. Activate the plugin through the 'Plugins' screen in WordPress
3. Log in as a WordPress Administrator and navigate to the PrayerBoard dashboard widget or plugin settings page
4. Configure your location and preferences in the appropriate tabs:
   - **Setup**: Connect to api.prayerboard.io, set location, and finish onboarding
   - **Calculation**: City selection, calculation method, and juristic method
   - **Prayer Times**: Prayer times configuration
   - **Marquee Messages**: Create and manage scrolling message groups
   - **Templates**: Customize template colors and marquee message integration
   - **Embeds**: Copy embed codes for posts/pages
   - **Settings**: Auto-refresh configuration and other plugin options
5. Use the prayer board URLs (/prayer-board/1, /prayer-board/2, /prayer-board/3) or embed codes in your posts, pages, or widgets
6. When a new PrayerBoard version is published, a connected site shows an Update button on the Dashboard. Review the changelog in the modal, then update from there (the zip is served by api.prayerboard.io, not WordPress.org).

== Frequently Asked Questions ==

= What calculation methods are available? =

The plugin supports these prayer time calculation methods:
* University of Islamic Sciences
* Islamic Society of North America (USA and Canada)
* Muslim World League (most European countries)
* Umm Al-Qura University (Makkah)
* Egyptian General Authority of Survey (Egypt and most of Africa)

= What Asr juristic method are available? =

For Asr time calculation, choose one of:
* Hanafi (Turkey and parts of Asia)
* Hanbali, Maliki, Shafii (most of the Middle East; standard Asr for the juristic method=1)

= How does timezone detection work? =

The plugin uses browser-based timezone detection with `Intl.DateTimeFormat().resolvedOptions().timeZone`. If this fails, it falls back to HTML5 Geolocation API for coordinate-based timezone estimation. Admins can also manually set the timezone in settings.

= What if the API is down? =

PrayerBoard caches the last known prayer times so displays keep working during outages. When the connection is restored it will automatically refresh.

= How do I update PrayerBoard? =

Connect the site to PrayerBoard (Setup / Account). When a new version is available, the Dashboard shows an Update button. Open it to read the version, release date, and changelog, then click Update now. The plugin downloads the package from api.prayerboard.io. You need permission to update plugins in WordPress.

= Who can manage the PrayerBoard plugin in WordPress? =

Only WordPress Administrators can manage PrayerBoard settings, boards, slides, plans, and billing. Subscribers and normal website users cannot manage the plugin. Public prayer board display pages can still be viewed using their board link.

= What are the template features? =

The plugin includes 3 pre-designed prayer boards with customizable colors and marquee message integration. Prayer boards can be accessed via clean URLs (/prayer-board/1, /prayer-board/2, /prayer-board/3) or embedded anywhere using embed codes. HTML templates are stored as files in templates/01/, templates/02/, and templates/03/ (template.html and styles.css per folder) for easy customization and version control.

= How do marquee messages work? =

Create marquee message groups in the admin panel, add multiple messages per group, and assign them to templates. Messages will scroll continuously on the display screen. Messages can be reordered via drag-and-drop and deleted individually. You can use embed codes in marquee messages.

= How does auto-refresh work? =

Auto-refresh can be configured in Settings with two modes:
* **12:01 AM (default)**: Once per location calendar day (after 12:01 AM), the plugin runs a server-side daily rollover (prayer times, Hijri date, daily ayah/hadith/dua), bumps board cache URLs, then open displays reload via cache sync
* **Scheduled**: Same rollover once per day at a specific time you choose
An hourly cron backup runs the rollover if a kiosk misses the client trigger. Use **Run refresh now** in Settings to test without waiting for midnight.

= Can I customize the prayer time offsets? =

Yes, you can set offsets for both prayer times and iqamah times ranging from 5 minutes to 1 hour after the adhan time.

= What Jummah duration options are available? =

Jummah duration can be set from 15 minutes to 1 hour, with customizable increments.

= Will fullscreen mode persist after auto-refresh? =

When you use the browser's fullscreen mode (for example F11 on a PC), the browser usually keeps that state across normal reloads (F5, midnight auto-refresh, etc.). A short display tip may appear once per browser tab session; it does not replace fullscreen mode.

= What data is removed when uninstalling? =

**Uninstall removes all PrayerBoard data** from your WordPress site: plugin database tables, generated calendar files under `wp-content/uploads/prayer-board/`, cron jobs, and plugin options/transients.

If you install PrayerBoard again later, it starts as a **fresh install** (onboarding and API connection).

**Deactivate** only disables the plugin temporarily and keeps your data. Use uninstall when you want PrayerBoard fully removed.

== Screenshots ==

1. Admin settings interface with tabbed configuration
2. Prayer times display with analog clock
3. Digital clock and current date display
4. Fullscreen mode for wall displays
5. Widget configuration options

== Changelog ==

= 1.1.7 =
* **Organisation**: New Organisation tab for masjid name, logo, address, phone, email, and website with autosave.
* **Organisation**: Site-wide branding stored on pba_settings; migration 002 adds columns on existing installs.
* **Organisation**: Sidebar 1:1 branding chip beside Refresh shows logo, initials, or mosque icon and opens Organisation.
* **Organisation**: WordPress media logo picker with live preview; sidebar chip updates after save.
* **Auto refresh**: Rewrote daily rollover into one pba_publish_board_update() pipeline (times, daily content, board bump).
* **Auto refresh**: Fixed kiosks staying on yesterday's snapshot after midnight in the mosque timezone.
* **Auto refresh**: prayer-board.js detects a new location day, calls server rollover, then reloads the board.
* **Auto refresh**: Hourly cron warms today's snapshot when a kiosk misses the client midnight trigger.
* **Auto refresh**: Settings shows last daily refresh status; Run refresh now forces rollover from admin.
* **Code**: Consolidated board cache and version helpers into functions-cache.php.

= 1.1.6 =
* **Updates**: Dashboard update and Changelog now share one release list from PrayerBoard (works offline too).
* **Release catalog**: API history.json is the only file for version, date, and changelog text.
* **Release catalog**: One catalog fetch powers update checks, Update modal, footer Changelog, and offline fallback.
* **Release catalog**: Removed readme/dates-only JSON/latest.json split; one sync copies history to the plugin.
* **Code**: Consolidated release loading into pba_plugin_release_catalog(); removed parallel changelog paths.
* **Dashboard**: Footer Changelog shows full version history with release dates from the API.
* **Board UI**: Redesigned Board tab with step cards and right-hand inspector panels for faster setup.
* **Board fonts**: Set a font per board or leave blank to inherit the global Settings default.
* **Colour presets**: Background picker is hex-only again (fixed Coloris alpha slider on solid colours).
* **Colour presets**: Background colours normalised to #rrggbb on load, change, and save.
* **Colour presets**: Preset swatches and picker labels refresh correctly after catalog sync.
* **Content**: Slide group saves apply reliably when switching between slide groups.
* **Content**: Fixed Ayat, Hadith, and Dua slides not saving (hidden Title field no longer required).
* **Content**: Unified slide save pipeline; field edits update cards without remounting the editor.

= 1.1.5 =
* **Plugin updates**: Simplified update checks on Dashboard and Plugins (live API per visit, no stale cache); install via WordPress upgrader only.
* **Colour presets**: Built-in presets sync from the PrayerBoard API catalog (with bundled offline fallback).
* **Colour presets**: New Led display preset (Electric Neon) added to the install seed.
* **Plan entitlements**: Preset access uses catalog categories only; removed legacy max_builtin_presets cap.
* **Plan entitlements**: Pricing table preset counts are now derived from the live colour catalog.
* **API requests**: GET calls to PrayerBoard API now pass parameters as query strings instead of a JSON body.
* **Dashboard**: Redesigned in-plugin Update modal with clearer layout, typography, and changelog list.
* **Dashboard**: Footer Changelog link opens full release history (newest first, scrollable).
* **Board refresh**: Sidebar Refresh board button applies pending public cache bumps after admin saves.
* **Scan to device**: Scan to device slide lets patrons scan a QR code to open PrayerBoard on their phone.
* **Embeds**: Fixed embed shortcodes adding ?_=timestamp to regular website page URLs.
* **Embeds**: Board cache sync now runs on kiosk /prayer-board/ pages only.
* **Code consolidation**: Consolidated admin autosave, board timestamp bump, and pending refresh helpers.
* **Code consolidation**: Colour catalog sync moved into a dedicated module.
* **Bug fixes**: Assorted admin stability improvements.

= 1.1.4 =
* **Plugin updates**: Unified update caches so Dashboard and Plugins stay in sync.
* **Plugins list**: “Get powerful features” opens the in-admin Buy now modal instead of leaving WordPress.

= 1.1.3 =
* **Content schedule**: Start and end dates no longer clear while you are still editing a schedule.
* **New slides**: Adding Event countdown and other slide types no longer errors before required fields are filled.
* **Content editor**: Smoother saving while typing — the open slide editor no longer remounts on every autosave.
* **Scan to device**: New slide type — show a QR code so visitors can open this Prayer Board on their phone.
* **Board preview**: Public `/prayer-board/preview` route with display-only template, colour, and font overrides for marketing embeds.
* **Embed HTML**: Code panel uses the PBA custom scrollbar.
* **Updates**: WordPress Plugins screen shows the same update notice as the Dashboard.

= 1.1.2 =
* **Prayer Offsets**: Setup card matches other tabs; prayer rows stay aligned with Athan and Iqamah settings.
* **Mobile admin**: Layout stays inside the WordPress 782px viewport; Settings filter cards stay half-width on desktop without clipping.
* **Dashboard**: Header logo links to prayerboard.io; Motion Digital credit under the version line.

= 1.1.1 =
* **Dashboard polish**: Version label under footer links; header/footer dividers; tighter logo spacing.
* **Admin footer**: Suppress WordPress name and version on all admin screens.
* **Update path**: Ready for in-plugin update from 1.1.0 via the Dashboard modal.

= 1.1.0 =
* **In-plugin updates**: Connected sites check api.prayerboard.io for a new version, then update from the Dashboard changelog modal.
* **Database migrations**: Existing sites apply numbered SQL files in `includes/migration/updates/` and store `pba_db_version` in PrayerBoard settings.
* **Production cleanup**: Removed leftover local dataset-install gates from onboarding.

= 1.0.3 =
* **Fullscreen hint**: Replaced the `[pba_fullscreen_button]` shortcode with a one-time (per tab), ~5-second modal from `prayer-board.js`, with TV/kiosk vs desktop messaging; body fullscreen classes unchanged.
* **Daily rollover auto-refresh**: Midnight refresh runs server-side prayer/Hijri/daily-content refresh, bumps board cache URLs, then reloads kiosks via cache sync; gregorian date and rollover share the 1s location clock tick (00:00:00 date, 00:01:00 rollover).
* **Uninstall cleanup**: Uninstall now removes all PrayerBoard database tables and `wp-content/uploads/prayer-board/` files so a later reinstall starts clean.

= 1.0.2 =
* **Template System Refactoring**: Unified template system with cloud-based HTML loading
* **Marquee Messages System**: Complete marquee message management with drag-and-drop reordering
* **Auto-Refresh Feature**: Configurable refresh modes for midnight or a chosen time
* **Dashboard Widget**: Quick access widget with plugin navigation links
* **Clean URLs**: SEO-friendly prayer board URLs (/prayer-board/1, /prayer-board/2, /prayer-board/3)
* **Fullscreen Persistence**: Fullscreen state preserved across page refreshes
* **Settings Tab**: Auto-refresh configuration and plugin options
* **Template Colors**: 3 pre-designed templates with customizable color presets
* **File-Based Templates**: Templates loaded from templates/01/, 02/, 03/
* **API Integration**: PrayerBoard service API integration
* **Improved Uninstall**: Preserves client data on uninstall

= 1.0.1 =
* **Major code cleanup and optimization**
* Removed redundant class files and boilerplate code
* Consolidated duplicate functions into global helper functions
* Cleaned up CSS files and removed duplicate styles
* Optimized file structure and removed unnecessary files
* Removed non-functional cache tab and related features
* Improved prayer time display formatting (12-hour format with AM/PM)
* Enhanced code maintainability and performance
* Streamlined admin interface

= 1.0.0 =
* Initial release with prayer time API integration
* Browser-based timezone detection
* Local Hijri date calculations
* Integrated analog and digital clocks
* Fullscreen functionality
* Multiple prayer calculation methods
* Customizable prayer time offsets
* Jummah settings
* Comprehensive embeds system

== Upgrade Notice ==

= 1.1.7 =
Organisation branding (logo + masjid details), sidebar branding chip, auto-refresh rewrite, and midnight rollover fix. Update from the Dashboard or Plugins screen.

= 1.1.6 =
Unified release catalog, Board tab inspector UI, per-board fonts, colour preset fixes, slide group saves, and Ayat/Hadith/Dua save fix. Update from the Dashboard or Plugins screen.

= 1.1.5 =
Adds Led display colour preset, API catalog sync, dashboard changelog modal, sidebar board refresh, embed shortcode URL fix, and GET request improvements. Update from the Dashboard or Plugins screen.

= 1.0.3 =
Removes the `[pba_fullscreen_button]` shortcode. Fullscreen help is shown automatically via `prayer-board.js` (once per browser tab session).

= 1.0.2 =
Major update with unified template system, marquee messages, auto-refresh, and dashboard widget. Templates loaded from plugin files (templates/01/, 02/, 03/). Fullscreen state persistence across refreshes.

= 1.0.1 =
Major cleanup and optimization release. Improved performance, removed redundant code, and enhanced maintainability.

= 1.0.0 =
Initial release with comprehensive prayer time functionality and integrated clock features.

== Technical Details ==

**Requirements:**
* WordPress 4.7+
* PHP 7.0+
* Modern web browser with JavaScript enabled

**Plugin Structure:**
```
md-prayer-board/
├── prayer-board.php - Main plugin file
├── prayer-board.js - Auto-refresh and cache busting
├── public/
│   ├── prayer-board/
│   │   └── display.php - Prayer board display renderer
│   ├── css/
│   │   ├── prayerboard-global.css - Reset, prayer times, tokens, watermark
│   │   ├── prayerboard-shortcodes.css - Marquee, countdown, clock, fullscreen hint
│   │   ├── prayerboard-content-widgets.css - Widget-components slide (T04–T06)
│   │   ├── prayerboard-layouts-XX.css - Per-template layout slices
│   │   └── prayerboard-content.css - Rotator slides + shared slide chrome
│   └── js/ - Marquee functionality
├── templates/
│   ├── 01/ - Left side with slides (template.html, styles.css)
│   ├── 02/ - Right side with slides (template.html, styles.css)
│   └── 03/ - Standard no slides (template.html, styles.css)
├── uninstall.php - Comprehensive cleanup script
├── admin/
│   ├── css/admin.css - Admin interface styles
│   └── js/admin.js - Admin JavaScript
└── includes/
    ├── data/cities-database.php - Cities data
    └── function/
        ├── functions.php - Core functionality
        ├── functions-marquee.php - Marquee CRUD/shortcode/save
        └── functions-marquee-admin.php - Marquee admin UI
```

**API Integration:**
* PrayerBoard service API with secure endpoint integration
* Real-time prayer time calculations with fallback caching

**Timezone Detection:**
* Primary: `Intl.DateTimeFormat().resolvedOptions().timeZone`
* Fallback: HTML5 Geolocation API
* Manual override available in admin settings

**Hijri Date Calculation:**
* Local Julian Day Number-based calculations
* No external dependencies
* Timezone-aware calculations

**Performance Features:**
* API response caching with automatic updates
* Efficient data storage with consolidated options
* Minimal external API calls
* Fallback system for offline functionality
* Global helper functions for consistent data access
* Configurable auto-refresh for wall displays
* Browser cache clearing on template updates

**Security Features:**
* All user inputs sanitized with WordPress functions
* API responses validated and sanitized
* Secure WordPress coding practices
* Nonce verification for form submissions
* File-based HTML templates in plugin directory
* No sensitive data exposure
* Uninstall preserves client data
* Template HTML stored as files in templates/01/, 02/, 03/

**Code Quality:**
* Consolidated duplicate functions
* Global reference functions for consistent data
* Clean, maintainable code structure
* No redundant or conflicting code
* Professional coding standards
* Unified save button for all admin tabs
* Template system with centralized configuration
* Separation of concerns (functions, templates, admin)

== Support ==

For technical support or feature requests, please refer to the plugin documentation or contact the development team.

**Plugin Homepage:** [https://prayerboard.io](https://prayerboard.io)

**Documentation:** Available in WordPress admin dashboard widget

== Credits ==

Developed by Motion Digital IT
Website: [https://motiondigital.com.au](https://motiondigital.com.au)

This plugin provides accurate prayer time calculations using advanced Islamic calendar algorithms.