Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| de93aa50ca | |||
| a9d76decae | |||
| a298a4c217 | |||
| c7b2258471 | |||
| 09b61cc950 | |||
| 224fccd6c4 | |||
| 32a3040e39 | |||
| 7a747b829b | |||
| 0dc3a220d9 | |||
| 2bd501d610 |
+245
@@ -9,6 +9,251 @@ Format: [Keep a Changelog 1.1.0](https://keepachangelog.com/en/1.1.0/) — versi
|
||||
|
||||
---
|
||||
|
||||
## [0.7.4] — 2026-05-30 — WordPress.org submission cleanup (updater out, LICENSE in)
|
||||
|
||||
Walks back the Update URI guard pattern from v0.7.3 and replaces it with the simpler, actually-correct answer: just remove the custom updater entirely. The WordPress.org Plugin Check tool (PCP) raised `plugin_updater_detected` on the v0.7.3 build with the message *"Including An Update Checker / Changing Updates functionality. Plugin Updater detected. Use of the Update URI header is not allowed in plugins hosted on WordPress.org."* PCP scans the source as-shipped, not as-distributed, so the build-time `sed` strip we relied on in v0.7.3 never had a chance to run before the scan — and the scanner flagged both the header and the `inc/updater.php` file itself. Two options remained: (a) keep dancing around PCP with branches and build scripts, or (b) accept that WordPress.org is the canonical update channel once a plugin is hosted there and drop the custom system. We went with (b).
|
||||
|
||||
This release also closes the per-file GPL declaration loop by adding a top-level LICENSE file with the full GPL v2 text and explicit GPL header blocks to the CSS and JS assets — every shipped file now declares its license unambiguously.
|
||||
|
||||
### Removed
|
||||
- **`inc/updater.php`** — the self-hosted Gitea updater. Deleted from the working tree (still recoverable from git history at tag `v0.7.3` if ever needed for a non-wp.org distribution). With the file gone, PCP's `plugin_updater_detected` check is silent.
|
||||
- **`Update URI:` header** in `radio.php`. PCP forbids the header in wp.org-hosted plugins, even when its value would legitimately defer updates to wp.org. (The v0.7.3 NOTE block in the file header documenting the strip-on-package pattern was removed along with it.)
|
||||
- **`require_once RADIO_PATH . 'inc/updater.php';`** line in `radio.php`. The file no longer exists, so no require is needed.
|
||||
- **Updates panel render block + `function_exists()` guard** in `inc/settings.php`. The panel function no longer exists in any build, so the call site is gone. Settings page now ends cleanly at the *Save Changes* button.
|
||||
- **"Self-hosted update checker against the Gitea repo"** bullet in the top-level `README.md`. Replaced with *"Updates via WordPress.org (the canonical channel once published)"*.
|
||||
- **"Self-hosted updater" bullet** in the `readme.txt` Privacy section. Replaced with a positive statement that updates come from WordPress.org through the normal core update process.
|
||||
|
||||
### Added
|
||||
- **`LICENSE` file** at the plugin root — verbatim canonical GPL v2 text from `https://www.gnu.org/licenses/gpl-2.0.txt`, 338 lines. The plugin header has always declared GPL v2+ but wp.org reviewers like to see the full text shipped alongside.
|
||||
- **GPL header block in `assets/css/radio.css`** (Copyright, GPL v2+ grant, pointer to LICENSE) so the CSS file's licensing is explicit at the file level, not inferred from the plugin header.
|
||||
- **GPL header block in `assets/js/radio.js`** — same treatment as the CSS. The original `/** Radio — vanilla JS audio controller. */` opening is preserved verbatim as the "module overview" section below the license header.
|
||||
- **GPL header block in `radio.php`'s docblock** — Copyright line + GPL v2+ grant + LICENSE pointer added below the `@package` tag. Sits alongside the existing `License:` / `License URI:` header fields rather than replacing them.
|
||||
|
||||
### Changed
|
||||
- **`readme.txt` Stable tag** → `0.7.4`.
|
||||
- **`inc/about.php` Version history** — v0.7.4 rotated into the "latest" slot; v0.7.3 demoted to a one-liner in the earlier-releases list with a note explaining the walkback.
|
||||
- **`RADIO_GITEA_URL` constant** is kept in `radio.php`. It's no longer used by an updater, but `inc/about.php` still uses it to render the *"View the full CHANGELOG.md →"* outbound link on the About page. Linking to a self-hosted source repo as a documentation reference is not the same as running a custom updater — that's fine in wp.org-hosted plugins. ([WordPress.org allows links to external source repos](https://developer.wordpress.org/plugins/wordpress-org/detailed-plugin-guidelines/) — the prohibition is on the update *mechanism*, not on referring to where the source lives.)
|
||||
|
||||
### Migration
|
||||
- **Existing wp.org installs** (post-acceptance): WordPress core handles updates automatically. Nothing to do.
|
||||
- **Existing Gitea-installed copies of v0.7.3 or earlier** (e.g. M5): the `inc/updater.php` file on disk will become orphaned after this update lands on them — it's no longer required from `radio.php`, so it just sits there as a dormant file until the next reinstall. **Recommended path for those installs:** once a-radio is accepted onto WordPress.org, uninstall the Gitea-sourced copy and reinstall from WordPress.org. Future updates then flow through wp.org. Until acceptance, those installs simply stop receiving updates (the v0.7.3 updater code is gone in v0.7.4, so there's nothing to advertise newer versions back to them).
|
||||
- **No data loss** in any case: station + volume + theme + history + favourites all live in `user_meta` and survive uninstall/reinstall cycles.
|
||||
|
||||
### Why this is the right answer (and v0.7.3 was clever but wrong)
|
||||
v0.7.3's Update URI guard pattern reasoned correctly about WordPress core's behaviour — the `Update URI` header genuinely does opt a plugin out of wp.org's update channel, and the runtime guard genuinely would short-circuit the updater on stripped builds. But the whole scheme assumed the reviewer would see the *stripped* build. The Plugin Check tool runs against the *source* artifact — the same source that's in the public repository, that future contributors clone, that automated audits scan. From PCP's point of view, the plugin was "shipping" an updater regardless of what the build script did with it later. The simpler answer (just delete the updater for the wp.org branch) sidesteps that entire class of "the static scanner doesn't know about your build pipeline" problem.
|
||||
|
||||
---
|
||||
|
||||
## [0.7.3] — 2026-05-30 — WordPress.org guideline 8 compliance + Privacy section
|
||||
|
||||
WordPress.org's detailed plugin guidelines require that plugins distributed via the directory **must not** ship their own updater that pulls from a non-wp.org server (guideline 8). RangerHQ Radio's self-hosted Gitea updater predates the wp.org submission and serves real-world installs on the author's own infrastructure, so it cannot simply be removed. The fix is the **Update URI guard pattern**: the plugin ships pointing at Gitea by default, and the build script that produces the wp.org submission zip strips the `Update URI:` header line. At load time the updater inspects that header and short-circuits if it's empty or points at wordpress.org.
|
||||
|
||||
Net effect: one source tree, two build artifacts, both compliant.
|
||||
|
||||
### Added
|
||||
- **`Update URI:` header in `radio.php`** pointing at `https://git.davidtkeane.com/ranger/a-radio`. WordPress core uses this header to decide whether wp.org should poll this plugin for updates — a non-wordpress.org URI opts the plugin out of wp.org's update channel, which is exactly what we want for the Gitea-distributed build. A NOTE block in the file header documents the strip-on-package convention so future-me doesn't get confused.
|
||||
- **`radio_should_skip_custom_updater()` helper** at the top of `inc/updater.php`. Reads the live `Update URI:` header via `get_file_data()`, caches the result, and returns `true` when the header is empty (wp.org default) or contains `wordpress.org`. Followed by `if ( radio_should_skip_custom_updater() ) { return; }` — the rest of the updater file (constants, transient filter, AJAX handlers, panel renderer) is never even defined when the guard trips, so there is zero overhead and zero risk of the custom updater running on a wp.org install.
|
||||
- **`function_exists()` guard around `radio_render_updates_panel()` in `inc/settings.php`** — necessary because the panel function only exists when the updater module was allowed to load. With the guard, the Settings page silently omits the panel on wp.org installs and renders it normally on Gitea installs.
|
||||
- **Dedicated `== Privacy ==` section in `readme.txt`** — explicit, bullet-by-bullet inventory of every connection the plugin can make: no telemetry from the plugin itself, no data leaving the site, audio streamed directly from SomaFM, current-track polling against `somafm.com/songs/{station}.json` every 30 seconds **only while playing**, search-provider links outbound only, no third-party JS, and an explicit note that the self-hosted updater is dormant on wp.org installs. Written so a reader who doesn't want any third-party traffic at all knows the answer: don't press Play.
|
||||
- **SomaFM Terms of Use link** (`https://somafm.com/legal/`) prominently in the readme's third-party-service note. Required because RangerHQ Radio is a thin wrapper around a third party's streams — listeners should know whose terms cover the audio they're hearing.
|
||||
|
||||
### Changed
|
||||
- **`readme.txt` Stable tag** → `0.7.3`.
|
||||
- **`readme.txt` Description third-party block** restructured from a single combined bullet into a separate "Third-party service" callout (with the ToS link) and a pointer to the new Privacy section, so the privacy policy isn't buried in the dependencies paragraph.
|
||||
- **`inc/about.php` Version history** — v0.7.3 rotated into the "latest" slot (full description); v0.7.2 demoted to a one-liner in the earlier-releases list.
|
||||
|
||||
### Why
|
||||
WordPress.org's guidelines page (Aug 2024 revision) is explicit: "Plugins may not contact external services without the explicit informed consent of the user… Plugins may not update themselves from anywhere other than WordPress.org once they're hosted there." The Update URI guard is the documented escape hatch — the same pattern Yoast, Jetpack, and Sucuri use for their commercial editions. The Privacy section is not strictly mandatory, but the GDPR-era reviewer notes have started flagging missing privacy disclosures even for telemetry-free plugins. Easier to ship with one than to play the comments game after submission.
|
||||
|
||||
### Migration
|
||||
None. Existing installs from Gitea continue to receive updates from Gitea exactly as before (because the `Update URI:` line is present, the guard does not trip, the updater runs unchanged). The wp.org submission zip — once built — will have the line stripped and the updater will be dormant. No user-visible behaviour change in either distribution.
|
||||
|
||||
---
|
||||
|
||||
## [0.7.2] — 2026-05-30 — Screenshots + correct wp.org contributor handle
|
||||
|
||||
Two small but real submission-prep moves:
|
||||
|
||||
### Added
|
||||
- **Five screenshots** at the plugin root, named per WordPress.org convention (`screenshot-1.png` through `screenshot-5.png`). Sizes 1087–1422 wide. Order matches the readme:
|
||||
1. Dashboard widget
|
||||
2. Settings page
|
||||
3. History page (star + four search-provider links)
|
||||
4. Pop-out mini-player window
|
||||
5. About page
|
||||
|
||||
### Changed
|
||||
- **`Contributors:`** in `readme.txt` updated from `davidtkeane` (placeholder) to **`ir240474`** — actual wp.org username confirmed (profile: <https://profiles.wordpress.org/ir240474/>).
|
||||
- **`Stable tag:`** bumped to `0.7.2`.
|
||||
- **Screenshots section** in `readme.txt` rewritten to match the five actual screenshots provided.
|
||||
|
||||
### Notes
|
||||
- Source images came from an `images/` working folder (David's working location); they've been moved/renamed to plugin root for the wp.org screenshot convention, and the working folder removed.
|
||||
- After this release the only PCP residue is the `.gitignore` hidden-file warning, which is unavoidable on the dev install and won't be in the submission zip.
|
||||
|
||||
**Files changed:** `radio.php` (version), `readme.txt` (Contributors, Stable Tag, Screenshots section, new 0.7.2 changelog + upgrade notice), `CHANGELOG.md`, `inc/about.php` (rotate v0.7.2 → latest), **5 new files** `screenshot-1.png` through `screenshot-5.png` at plugin root, `images/` directory removed.
|
||||
|
||||
---
|
||||
|
||||
## [0.7.1] — 2026-05-30 — Plugin Check follow-up: tested-up-to + .DS_Store re-cleanup
|
||||
|
||||
A re-run of PCP after v0.7.0 dropped the issue count from 169 → 4. This release closes the only real one of the four:
|
||||
|
||||
### Fixed
|
||||
- **`Tested up to` bumped: 6.7 → 7.0** in `readme.txt` (PCP `outdated_tested_upto_header`). WordPress 7.0 is current; the previous header would have been flagged as out-of-date at submission review.
|
||||
- **Stable Tag bumped to 0.7.1** in `readme.txt`.
|
||||
|
||||
### Removed (again)
|
||||
- `.DS_Store` files (root + `assets/`). macOS Finder regenerated them between PCP runs; they will not be present in the actual submission zip. `.gitignore` already covers them.
|
||||
|
||||
### Known PCP residue (not addressable in source)
|
||||
- The `.gitignore` file itself triggers a `hidden_files` WARNING (sev 8) on PCP because it's a dot-file. Keeping `.gitignore` is needed for git; it will be excluded from the submission zip. Acceptable per WP.org packaging conventions.
|
||||
|
||||
**Files changed:** `radio.php` (version), `readme.txt` (Tested-up-to + Stable Tag + new 0.7.1 changelog + upgrade notice), `CHANGELOG.md`, `.DS_Store` files deleted.
|
||||
|
||||
---
|
||||
|
||||
## [0.7.0] — 2026-05-30 — WordPress.org submission prep (full Plugin Check clean)
|
||||
|
||||
Ran the official WordPress.org **Plugin Check (PCP)** against v0.6.3 — surfaced **169 issues**. This release closes all of them so the plugin is submission-ready for the WordPress.org plugin directory.
|
||||
|
||||
### Changed — branding
|
||||
- **Plugin Name renamed: "Radio" → "RangerHQ Radio"** to (a) remove the trademarked term "SomaFM" from the plugin name surface (PCP `trademarked_term` warning) and (b) line up with the RangerHQ plugin family. SomaFM is still credited in the Description and on the About page as the data source. Plugin folder/slug stays `a-radio` — no install path changes; existing user_meta keys (`radio_state` / `radio_history` / `radio_favourites`) untouched.
|
||||
- **`Text Domain` header renamed**: `radio` → `a-radio` (matched the slug for the first time; PCP `textdomain_mismatch`).
|
||||
- **`Requires at least` bumped**: `5.0` → `5.3` (matches `wp_date()` usage in `inc/history.php`; PCP `wp_function_not_compatible_with_requires_wp`).
|
||||
- **File docstring header** dropped "SomaFM" from the prominent first line.
|
||||
|
||||
### Changed — code (mass-mechanical)
|
||||
- **134 i18n call sites** rewritten from `'radio'` text domain → `'a-radio'` across `radio.php`, `inc/admin-page.php`, `inc/dashboard-widget.php`, `inc/settings.php`, `inc/about.php`, `inc/history.php`, `inc/updater.php`. Single sed pass on the unique pattern `, 'radio' )` (the 6 menu-slug `'radio'` references in `add_menu_page` / `add_submenu_page` were left alone — they're the URL slug, not the text domain).
|
||||
|
||||
### Fixed — security
|
||||
- **8 × `MissingUnslash` + 8 × `InputNotSanitized`** in the v0.5.0 history endpoints (`radio_ajax_log_track`, `radio_ajax_toggle_favourite`). All four `$_POST['artist|title|station|station_id']` access points are now wrapped `sanitize_text_field( wp_unslash( $_POST['…'] ) )` (or `sanitize_key()` for `station_id`) at the access point. The downstream `radio_sanitize_entry()` helper still re-sanitizes as belt+braces.
|
||||
|
||||
### Added — translator comments
|
||||
- 6 × `printf` / `sprintf` calls with placeholders now carry `/* translators: ... */` comments: pop-out window title, updater status messages (HTTP error / available / up-to-date / download), history page "%s ago" relative time.
|
||||
|
||||
### Refactored — pop-out window
|
||||
- Inline `<link>` stylesheets, inline `<style>` block, and `<script>` tag in `radio_render_popout_page()` replaced with `wp_enqueue_style()` + `wp_enqueue_script()` + `wp_localize_script()` registered before the HTML output, then `wp_print_styles()` in `<head>` and `wp_print_footer_scripts()` at end of `<body>`.
|
||||
- Popup-specific CSS (header, close button, wrap, layout overrides, popup dark theme) moved out of the inline `<style>` and into `assets/css/radio.css` under `body.radio-popout` scope so it only fires inside the popup.
|
||||
|
||||
### Removed
|
||||
- `.DS_Store` files (root + `assets/`) — stray macOS Finder artefacts; PCP `hidden_files`. `.gitignore` already covers them.
|
||||
|
||||
### Added — distribution
|
||||
- **`readme.txt`** in proper WordPress.org format: Plugin headers, Contributors, Donate link, Tags, Requires-at-least, Tested-up-to, Stable Tag, Requires-PHP, License, License URI, short description (≤150 chars), Description, Installation, FAQ, Screenshots, Changelog, Upgrade Notice.
|
||||
|
||||
### Compat notes
|
||||
- No behaviour change for existing users. Per-user state (`radio_state` / `radio_history` / `radio_favourites`) is preserved across the upgrade — no migration needed.
|
||||
- The displayed Plugin Name in **Plugins → Installed** changes from "Radio" to "RangerHQ Radio" — that's the only visible difference on update.
|
||||
|
||||
**Files changed:** `radio.php` (header + 6 translator comments + 8 $_POST hardenings + popup enqueue refactor), `inc/admin-page.php` / `inc/dashboard-widget.php` / `inc/settings.php` / `inc/about.php` / `inc/history.php` / `inc/updater.php` (textdomain mass-fix + translator comments where applicable + about-page version rotation), `assets/css/radio.css` (popup styles moved in under `body.radio-popout`), **new** `readme.txt`, **removed** `.DS_Store`, `assets/.DS_Store`.
|
||||
|
||||
---
|
||||
|
||||
## [0.6.3] — 2026-05-30 — Discreet "buy me a coffee" support link
|
||||
|
||||
### Added
|
||||
- New `RADIO_SUPPORT_URL` constant in `radio.php` (default `https://buymeacoffee.com/davidtkeane`). Wrapped in `if ( ! defined(...) )` so it's override-able from `wp-config.php`.
|
||||
- Tiny footer line `☕ Like Radio? If You fancy to buy me a coffee →` inside the **Updates panel** on Settings, below the manual-update note.
|
||||
- Matching footer line at the bottom of the **Credits + thanks** card on the About page.
|
||||
- Both spots render from the same constant — change one place, both update.
|
||||
- **Conditional render**: if `RADIO_SUPPORT_URL` is empty / undefined, the link is silently hidden. Forks can strip funding with one line.
|
||||
|
||||
### Design
|
||||
- Muted styling deliberate: 12 px, admin-theme-coloured link, subtle top border. Reads as housekeeping ("here's where to send thanks") not a sales pitch. No yellow BMC brand chrome.
|
||||
- Dark-theme variant for the divider (`#3c434a`) so it stays subtle on the dark surface.
|
||||
|
||||
**Files changed:** `radio.php` (version, `RADIO_SUPPORT_URL` constant), `inc/updater.php` (link inside the Updates panel after the manual-update paragraph), `inc/about.php` (link inside the Credits + thanks card; rotate v0.6.3 into latest expanded slot, v0.6.2 into earlier-releases list), `assets/css/radio.css` (`.radio-support-link` styling + dark-theme override).
|
||||
|
||||
---
|
||||
|
||||
## [0.6.2] — 2026-05-30 — Current version badge on Settings
|
||||
|
||||
### Added
|
||||
- Small grey pill follows the **"Radio — Settings"** heading: `v{RADIO_VERSION}`. Visible at a glance so you don't have to hover the plugin row in *Plugins → Installed* or open *About* just to check what version you're on.
|
||||
- Dark-theme variant of the badge (`#2c3338` background, `#c3c4c7` text) so it stays readable when `theme=dark`.
|
||||
|
||||
**Files changed:** `radio.php` (version), `inc/settings.php` (`<span class="radio-version-badge">v…</span>` inside the H1), `assets/css/radio.css` (`.radio-version-badge` styling + dark-theme override).
|
||||
|
||||
---
|
||||
|
||||
## [0.6.1] — 2026-05-30 — About page restructure
|
||||
|
||||
By v0.6.0 the About page had eight version-history entries, each a full paragraph, dwarfing the other cards and pushing Credits + thanks off the visible area. v0.6.1 rebalances the layout.
|
||||
|
||||
### Changed
|
||||
- **Three short cards on top** (What / Who / **Credits**) — equal-height, balanced row. Credits is no longer a fourth card buried under the version history; it sits beside What and Who where it belongs.
|
||||
- **Version history is its own full-width card below.** Only the **latest** release is shown in full; **earlier releases collapse to one line each** (version + date + headline). The card now stays compact however many versions ship — adding a future release adds one line, not a paragraph.
|
||||
- **Full prose for older versions lives in `CHANGELOG.md` on Gitea** — the "View the full CHANGELOG.md →" link does the heavy lifting. Single source of truth, no duplication.
|
||||
|
||||
**Files changed:** `radio.php` (version), `inc/about.php` (3-card top + new `.radio-about-versions` block with `__latest` / `__earlier` sub-elements; 9 versions in the earlier-releases list incl. v0.1.0), `assets/css/radio.css` (removed dead `.radio-about-card--versions` rules; added `.radio-about-versions` + `__latest` + `__earlier` rules; dark-theme overrides for the new selectors).
|
||||
|
||||
---
|
||||
|
||||
## [0.6.0] — 2026-05-30 — Pop-out mini-player (continuous background play)
|
||||
|
||||
Until v0.5.0 the audio cut every time you navigated between WP admin pages — every navigation is a full page reload, which destroys the `<audio>` element. v0.6.0 fixes the background-music use case by letting you pop the player out into a separate browser window that persists across the parent tab's navigation.
|
||||
|
||||
### Added — **Pop out** button + standalone popup player
|
||||
- Small **`↗ Pop out`** button beside the Play button on both the main Radio page and the Dashboard widget. Click it and a **380×560 standalone window** opens with just the player chrome (no WP admin sidebar / nav).
|
||||
- The popup lives at `admin-post.php?action=radio_popout&play=1` — a new server-side route that renders a **full standalone HTML page** outside the WP admin shell (custom `<!DOCTYPE>`, head, body, no admin chrome).
|
||||
- Popup is `radio_popout`-named so a second click on Pop out **re-focuses the existing window** instead of opening a new one.
|
||||
- The popup's `<audio>` element is never destroyed by parent-tab navigation, so the music keeps playing while you click around Plugins, Posts, Users, etc.
|
||||
|
||||
### Auto-resume — pick up where the main tab left off
|
||||
- The Pop-out button URL carries `&play=1`. `radio.js` reads it from the localized config and auto-calls `audio.play()` 200 ms after init. Same-origin user-gesture popups are exempt from autoplay-blocking on every modern browser, so it just works.
|
||||
- On opening the popup, **every other audio surface in the main tab is paused** so you don't end up with two streams running simultaneously.
|
||||
|
||||
### Popup details
|
||||
- Theme follows the user's saved choice (`radio_state['theme']`) — light by default, dark if explicitly set; the popup body gets the `radio-theme-dark` class so the existing dark-mode CSS rules apply.
|
||||
- The popup includes everything you need to listen and switch: now-playing block (with dancing bars + Web Audio visualizer), play/pause, mute, volume, full station dropdown grouped by genre, error slot.
|
||||
- Close button (`✕`) in the top-right calls `window.close()`.
|
||||
- Pop out button **does not appear inside the popup** itself (would be infinite); the JS detects `popoutUrl === ''` in the localized config and hides any Pop-out button it finds.
|
||||
- Popup blocked? The button shows a clear alert: *"Pop-out blocked by the browser. Allow popups for this site, then try again."*
|
||||
|
||||
### State stays in sync
|
||||
- The popup uses the **same `radio_save_state` AJAX endpoint** as the main player. If you change station or volume in the popup, it persists to user_meta; the next time you load any Radio page in the main tab it picks up the new values.
|
||||
- Track history continues to log from whichever surface is playing — the popup polls SomaFM and POSTs to `radio_log_track` exactly like the main player.
|
||||
|
||||
**Files changed:** `radio.php` (version, `popoutUrl` added to localized config, new `admin_post_radio_popout` action + `radio_render_popout_page` handler with full standalone HTML), `inc/admin-page.php` + `inc/dashboard-widget.php` (Pop-out button beside Play), `assets/css/radio.css` (Pop-out button styling), `assets/js/radio.js` (`bindPopOut` opens the window + pauses other surfaces, autoplay branch reads `cfg.autoPlay`), `inc/about.php` (history entry).
|
||||
|
||||
---
|
||||
|
||||
## [0.5.0] — 2026-05-29 — Track history + favourites
|
||||
|
||||
SomaFM plays deep cuts you'll never hear again. v0.5.0 quietly logs every track that scrolls past so you can find it again later — and a star button keeps the ones worth keeping forever.
|
||||
|
||||
### Added — `Radio → History` admin page (per-user)
|
||||
- **History tab** — capped FIFO list of the last 500 played tracks. Each row shows when (relative time, full timestamp on hover), station, *artist — title*, four search links, and a favourite-star toggle.
|
||||
- **Favourites tab** — uncapped list of starred tracks. Same row layout. Survives even when the history rolls over.
|
||||
- **Filter** by artist/title (live, client-side) and by station (dropdown). **Clear history** button on the History tab — favourites preserved.
|
||||
- **Four search providers** per row, brand-tinted on hover: **Spotify** (green), **YouTube** (red), **Apple Music** (pink), **Bandcamp** (teal). Deep-link search URLs only — no API keys, no third-party JS.
|
||||
- Empty-state messages on both tabs.
|
||||
|
||||
### Added — automatic logging during playback
|
||||
- `fetchTrack` (the existing 30s SomaFM polling loop) now hands every new track to a new `logTrackIfNew` helper that POSTs it to `wp_ajax_radio_log_track`.
|
||||
- **Dedup**: client-side via `lastLoggedSig` so the 30s polling doesn't re-log the same song; server-side against the last entry in user_meta as belt-and-braces.
|
||||
- **Junk filtering**: `(unknown)` artists and entries missing artist *or* title are dropped server-side in `radio_sanitize_entry`.
|
||||
|
||||
### Added — per-user storage
|
||||
- Two new `user_meta` keys, separate from `radio_state` so frequent track inserts don't churn the player-state blob:
|
||||
- `radio_history` — capped at **500 entries** (~50–80 KB max).
|
||||
- `radio_favourites` — uncapped, expected to stay small (user-curated).
|
||||
|
||||
### Added — three new AJAX endpoints
|
||||
- `wp_ajax_radio_log_track` — append a track (nonce: `radio_save_state`; player-page only).
|
||||
- `wp_ajax_radio_toggle_favourite` — toggle a track in favourites (nonce: `radio_history`; History-page only).
|
||||
- `wp_ajax_radio_clear_history` — clear the history list (nonce: `radio_history`; History-page only). Favourites untouched.
|
||||
|
||||
### Notes
|
||||
- Per-user — nothing is shared, nothing leaves the site. Just your own listening history on your own WP account.
|
||||
- **No PII concern** — entries are public station/artist/title strings from SomaFM's own JSON.
|
||||
- Search-link UI tints toward each provider's brand colour on hover only — keeps the row visually calm in the default state.
|
||||
|
||||
**Files changed:** `radio.php` (version, require, submenu, asset enqueue hook, three AJAX endpoints, three new localized strings), **new** `inc/history.php` (storage helpers + page renderer), `assets/css/radio.css` (history-page table, toolbar, search-link pills, favourite star, dark-theme overrides), `assets/js/radio.js` (`logTrackIfNew` wired into `fetchTrack`; `bindHistoryPage` for filter/favourite/clear), `inc/about.php` (history entry).
|
||||
|
||||
---
|
||||
|
||||
## [0.4.0] — 2026-05-29 — Now-playing indicator: dancing bars + Web Audio visualizer
|
||||
|
||||
A small visual that instantly says *"this is playing right now."* Two layers — a reliable CSS-only indicator that always works, and a progressive Web Audio upgrade that draws actual frequency data when the browser allows.
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
<https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Moe Ghoul>, 1 April 1989
|
||||
Moe Ghoul, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -8,7 +8,7 @@ A small, focused, free WordPress plugin that drops a SomaFM radio player into yo
|
||||
- Dedicated page at **WP Admin → Radio → My Radio**
|
||||
- Plays via HTML5 `<audio>` — no proxy server, no third-party tracking
|
||||
- Per-user state: each admin remembers their own station + volume
|
||||
- Self-hosted update checker against the Gitea repo
|
||||
- Updates via WordPress.org (the canonical channel once published)
|
||||
|
||||
## Installation
|
||||
|
||||
|
||||
+272
-24
@@ -1,4 +1,14 @@
|
||||
/* Radio — admin styles, WordPress-native */
|
||||
/*!
|
||||
* RangerHQ Radio — admin styles, WordPress-native.
|
||||
*
|
||||
* Copyright (C) 2026 David Keane
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version. See LICENSE in the plugin root
|
||||
* for the full text, or visit https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
* Player layout (works inside .postbox .inside on main page,
|
||||
@@ -166,6 +176,16 @@
|
||||
font-family: "Helvetica Neue", Arial, sans-serif;
|
||||
}
|
||||
|
||||
/* v0.6.0: Pop-out button — small secondary button beside Play. Uses WP
|
||||
native .button styles; the ↗ glyph signals "opens in another window." */
|
||||
.radio-player__popout {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.radio-player__popout span[aria-hidden] { font-size: 13px; line-height: 1; }
|
||||
|
||||
.radio-player__volume {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -287,6 +307,39 @@
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* v0.6.3: Discreet "buy me a coffee" support line. Rendered in two
|
||||
spots from the single RADIO_SUPPORT_URL constant — bottom of the
|
||||
Updates panel in Settings, and bottom of the Credits + thanks card
|
||||
on About. Muted styling deliberate: housekeeping not sales pitch. */
|
||||
.radio-support-link {
|
||||
display: block;
|
||||
margin-top: 12px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid #f0f0f1;
|
||||
font-size: 12px;
|
||||
color: var(--wp-admin-theme-color, #2271b1);
|
||||
text-decoration: none;
|
||||
}
|
||||
.radio-support-link::before { content: '☕ '; opacity: 0.8; }
|
||||
.radio-support-link:hover { text-decoration: underline; }
|
||||
.radio-theme-dark .radio-support-link { border-top-color: #3c434a; }
|
||||
|
||||
/* Small grey pill that follows the Settings page H1 — at-a-glance
|
||||
confirmation of the version you are running. */
|
||||
.radio-version-badge {
|
||||
display: inline-block;
|
||||
margin-left: 8px;
|
||||
padding: 2px 8px;
|
||||
background: #e2e4e7;
|
||||
color: #50575e;
|
||||
border-radius: 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
vertical-align: middle;
|
||||
letter-spacing: 0.02em;
|
||||
}
|
||||
.radio-theme-dark .radio-version-badge { background: #2c3338; color: #c3c4c7; }
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
* Dashboard widget — no nested card; bare content inside .inside
|
||||
* (WP renders the widget as a postbox already; don't double up)
|
||||
@@ -349,27 +402,50 @@
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
.radio-about-card--versions ul {
|
||||
list-style: none;
|
||||
padding: 12px;
|
||||
margin: 0;
|
||||
.radio-about-changelog-link {
|
||||
display: inline-block;
|
||||
margin: 0 12px 12px;
|
||||
font-size: 13px;
|
||||
color: var(--wp-admin-theme-color, #2271b1);
|
||||
text-decoration: none;
|
||||
}
|
||||
.radio-about-changelog-link:hover { text-decoration: underline; }
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
* Version history — full-width card BELOW the top row of cards
|
||||
* (v0.6.1). Latest release shown in full; earlier releases collapse
|
||||
* to one line each so the card stays compact however many versions
|
||||
* ship. Full prose for older versions lives in the CHANGELOG on Gitea.
|
||||
* ─────────────────────────────────────────────────────────────── */
|
||||
|
||||
.radio-about-versions {
|
||||
max-width: 1100px;
|
||||
margin-top: 16px;
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
|
||||
.radio-about-card--versions li {
|
||||
margin-bottom: 10px;
|
||||
.radio-about-versions h2 {
|
||||
margin: 0;
|
||||
padding: 8px 12px;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
background: #f6f7f7;
|
||||
border-bottom: 1px solid #c3c4c7;
|
||||
}
|
||||
|
||||
.radio-about-versions__latest {
|
||||
padding: 12px 12px 8px;
|
||||
}
|
||||
|
||||
.radio-about-versions__latest .ver {
|
||||
font-weight: 600;
|
||||
color: var(--wp-admin-theme-color, #2271b1);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.radio-about-card--versions li:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.radio-about-card--versions .ver {
|
||||
font-weight: 600;
|
||||
color: var(--wp-admin-theme-color, #2271b1);
|
||||
}
|
||||
|
||||
.radio-about-card--versions .latest {
|
||||
.radio-about-versions__latest .latest {
|
||||
display: inline-block;
|
||||
margin-left: 6px;
|
||||
padding: 1px 7px;
|
||||
@@ -381,16 +457,47 @@
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.radio-about-changelog-link {
|
||||
display: inline-block;
|
||||
margin: 0 12px 12px;
|
||||
.radio-about-versions__latest p {
|
||||
margin: 6px 0 0;
|
||||
font-size: 13px;
|
||||
color: var(--wp-admin-theme-color, #2271b1);
|
||||
text-decoration: none;
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.radio-about-changelog-link:hover {
|
||||
text-decoration: underline;
|
||||
.radio-about-versions h3 {
|
||||
margin: 4px 0 0;
|
||||
padding: 8px 12px 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #646970;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
border-top: 1px solid #f0f0f1;
|
||||
}
|
||||
|
||||
.radio-about-versions__earlier {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 4px 12px 8px;
|
||||
}
|
||||
|
||||
.radio-about-versions__earlier li {
|
||||
padding: 4px 0;
|
||||
font-size: 13px;
|
||||
color: #50575e;
|
||||
}
|
||||
|
||||
.radio-about-versions__earlier .ver {
|
||||
display: inline-block;
|
||||
min-width: 48px;
|
||||
font-weight: 600;
|
||||
color: var(--wp-admin-theme-color, #2271b1);
|
||||
}
|
||||
|
||||
.radio-about-versions__earlier .ver-date {
|
||||
display: inline-block;
|
||||
min-width: 110px;
|
||||
font-size: 11px;
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
@@ -440,6 +547,12 @@
|
||||
color: #f0f0f1;
|
||||
border-bottom-color: #3c434a;
|
||||
}
|
||||
.radio-theme-dark .radio-about-versions { background: #1d2327; border-color: #3c434a; color: #c3c4c7; }
|
||||
.radio-theme-dark .radio-about-versions h2 { background: #2c3338; color: #f0f0f1; border-bottom-color: #3c434a; }
|
||||
.radio-theme-dark .radio-about-versions h3 { color: #a7aaad; border-top-color: #3c434a; }
|
||||
.radio-theme-dark .radio-about-versions__latest p { color: #c3c4c7; }
|
||||
.radio-theme-dark .radio-about-versions__earlier li { color: #c3c4c7; }
|
||||
.radio-theme-dark .radio-about-versions__earlier .ver-date { color: #a7aaad; }
|
||||
.radio-theme-dark #radio_dashboard_widget .radio-player__credit {
|
||||
border-top-color: #3c434a;
|
||||
}
|
||||
@@ -453,3 +566,138 @@
|
||||
border-radius: 3px;
|
||||
border: 1px solid #3c434a;
|
||||
}
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
* Pop-out window (v0.6.0 → moved here from inline <style> in v0.7.0
|
||||
* for PCP cleanliness). All scoped to body.radio-popout so these
|
||||
* rules only fire inside the popup window, never bleed onto admin
|
||||
* pages that load the same radio.css.
|
||||
* ─────────────────────────────────────────────────────────────── */
|
||||
body.radio-popout {
|
||||
/* Popup has no WP admin chrome to provide --wp-admin-theme-color;
|
||||
set a reasonable default so the player + links still tint. */
|
||||
--wp-admin-theme-color: #2271b1;
|
||||
margin: 0;
|
||||
padding: 14px;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||
background: #f0f0f1;
|
||||
color: #1d2327;
|
||||
font-size: 13px;
|
||||
}
|
||||
body.radio-popout .radio-popout-header { display: flex; justify-content: space-between; align-items: center; margin: 0 0 12px; }
|
||||
body.radio-popout .radio-popout-header h1 { margin: 0; font-size: 14px; font-weight: 600; color: #1d2327; }
|
||||
body.radio-popout .radio-popout-header h1::before { content: '📻 '; }
|
||||
body.radio-popout .radio-popout-close { background: none; border: 0; font-size: 18px; cursor: pointer; color: #646970; padding: 4px 8px; line-height: 1; border-radius: 3px; }
|
||||
body.radio-popout .radio-popout-close:hover { color: #b32d2e; background: rgba(179, 45, 46, 0.08); }
|
||||
body.radio-popout .radio-popout-wrap { background: #fff; border: 1px solid #c3c4c7; padding: 14px; border-radius: 3px; }
|
||||
body.radio-popout .radio-popout-wrap .radio-player__station-select select { max-width: 100%; }
|
||||
body.radio-popout .radio-popout-wrap .radio-player__volume { width: 100%; }
|
||||
body.radio-popout .radio-popout-wrap .radio-player__controls { flex-direction: column; align-items: stretch; gap: 10px; }
|
||||
|
||||
/* Popup dark theme — keeps the popup readable when theme=dark */
|
||||
body.radio-popout.radio-theme-dark { background: #101213; color: #f0f0f1; }
|
||||
body.radio-popout.radio-theme-dark .radio-popout-header h1 { color: #f0f0f1; }
|
||||
body.radio-popout.radio-theme-dark .radio-popout-wrap { background: #1d2327; border-color: #3c434a; }
|
||||
body.radio-popout.radio-theme-dark .radio-popout-close { color: #a7aaad; }
|
||||
|
||||
/* ──────────────────────────────────────────────────────────────────
|
||||
* History + Favourites page (v0.5.0)
|
||||
* ─────────────────────────────────────────────────────────────── */
|
||||
|
||||
.radio-history-wrap { max-width: 1100px; }
|
||||
|
||||
.radio-tab-count {
|
||||
color: #646970;
|
||||
font-weight: 400;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.radio-history-toolbar {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin: 12px 0 16px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.radio-history-toolbar input[type="search"] {
|
||||
flex: 1 1 220px;
|
||||
max-width: 360px;
|
||||
}
|
||||
.radio-history-toolbar select { max-width: 220px; }
|
||||
.radio-history-clear { margin-left: auto !important; }
|
||||
|
||||
.radio-history-empty {
|
||||
margin-top: 24px;
|
||||
padding: 24px;
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
color: #50575e;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.radio-history-table { background: #fff; }
|
||||
.radio-history-table th,
|
||||
.radio-history-table td { padding: 10px 12px; vertical-align: middle; }
|
||||
.radio-history-table th.when,
|
||||
.radio-history-table th.station,
|
||||
.radio-history-table th.fav { white-space: nowrap; }
|
||||
.radio-history-table .when,
|
||||
.radio-history-table .station {
|
||||
color: #646970; font-size: 12px; white-space: nowrap;
|
||||
}
|
||||
.radio-history-table .track { font-size: 14px; }
|
||||
.radio-history-table .track strong { color: #1d2327; }
|
||||
.radio-history-table .search { white-space: nowrap; }
|
||||
.radio-history-table .fav { text-align: center; width: 42px; }
|
||||
|
||||
/* Search-link pills, brand-tinted on hover */
|
||||
.radio-search-link {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
margin-right: 4px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
border-radius: 10px;
|
||||
text-decoration: none;
|
||||
background: #e2e4e7;
|
||||
color: #1d2327;
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
.radio-search-link:hover { background: #d0d3d6; }
|
||||
.radio-search-link--spotify:hover { background: #1ed760; color: #000; }
|
||||
.radio-search-link--youtube:hover { background: #ff0000; color: #fff; }
|
||||
.radio-search-link--apple:hover { background: #fa57c1; color: #fff; }
|
||||
.radio-search-link--bandcamp:hover { background: #629aa9; color: #fff; }
|
||||
|
||||
/* Favourite star — grey by default, golden when starred */
|
||||
.radio-fav-btn {
|
||||
background: none;
|
||||
border: 0;
|
||||
padding: 4px 6px;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
color: #c3c4c7;
|
||||
transition: transform 0.12s ease, color 0.12s ease;
|
||||
}
|
||||
.radio-fav-btn:hover { transform: scale(1.2); color: #f0b849; }
|
||||
.radio-fav-btn:focus { outline: 2px solid var(--wp-admin-theme-color, #2271b1); outline-offset: 1px; }
|
||||
.radio-fav-btn.is-fav { color: #f0b849; }
|
||||
.radio-fav-btn[disabled] { opacity: 0.5; cursor: progress; }
|
||||
|
||||
/* Filtered-out rows hidden via JS */
|
||||
.radio-history-row.is-filtered { display: none; }
|
||||
|
||||
/* Dark theme — history surfaces */
|
||||
.radio-theme-dark .radio-history-table { background: #1d2327; color: #c3c4c7; border-color: #3c434a; }
|
||||
.radio-theme-dark .radio-history-table th { background: #2c3338; color: #f0f0f1; border-bottom-color: #3c434a; }
|
||||
.radio-theme-dark .radio-history-table .track strong { color: #f0f0f1; }
|
||||
.radio-theme-dark .radio-history-table .when,
|
||||
.radio-theme-dark .radio-history-table .station { color: #a7aaad; }
|
||||
.radio-theme-dark .radio-search-link { background: #2c3338; color: #c3c4c7; }
|
||||
.radio-theme-dark .radio-history-empty { background: #1d2327; border-color: #3c434a; color: #c3c4c7; }
|
||||
.radio-theme-dark .radio-fav-btn { color: #50575e; }
|
||||
.radio-theme-dark .radio-fav-btn.is-fav,
|
||||
.radio-theme-dark .radio-fav-btn:hover { color: #f0b849; }
|
||||
|
||||
+145
-3
@@ -1,5 +1,15 @@
|
||||
/**
|
||||
* Radio — vanilla JS audio controller.
|
||||
/*!
|
||||
* RangerHQ Radio — vanilla JS audio controller.
|
||||
*
|
||||
* Copyright (C) 2026 David Keane
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version. See LICENSE in the plugin root
|
||||
* for the full text, or visit https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* --- module overview ---
|
||||
*
|
||||
* Binds to every `.radio-player` element on the page (dashboard widget
|
||||
* + main page can co-exist; both share one logical audio session per
|
||||
@@ -109,7 +119,8 @@
|
||||
}
|
||||
|
||||
/** SomaFM current-track polling. Best-effort: stays hidden if the API
|
||||
* is unreachable / CORS-blocked (the plugin keeps working regardless). */
|
||||
* is unreachable / CORS-blocked (the plugin keeps working regardless).
|
||||
* v0.5.0: hands new tracks to logTrackIfNew so they land in user history. */
|
||||
function startTrackPolling(player, station) {
|
||||
stopTrackPolling(player);
|
||||
var trackEl = player.querySelector('[data-radio-track]');
|
||||
@@ -129,6 +140,7 @@
|
||||
if (!title && !artist) { trackEl.hidden = true; return; }
|
||||
trackEl.textContent = artist ? (title + ' — ' + artist) : title;
|
||||
trackEl.hidden = false;
|
||||
logTrackIfNew(artist, title, station);
|
||||
})
|
||||
.catch(function () { trackEl.hidden = true; });
|
||||
}
|
||||
@@ -136,6 +148,29 @@
|
||||
player._trackTimer = setInterval(fetchTrack, 30000);
|
||||
}
|
||||
|
||||
/** v0.5.0: POST a newly-played track to the server history.
|
||||
* Deduped client-side via lastLoggedSig so consecutive polls of the
|
||||
* same song don't spam the endpoint (server dedups too as belt+braces). */
|
||||
var lastLoggedSig = '';
|
||||
function logTrackIfNew(artist, title, station) {
|
||||
if (!cfg.ajaxUrl || !cfg.nonce) { return; }
|
||||
if (!artist || !title) { return; }
|
||||
if (artist.toLowerCase() === '(unknown)') { return; }
|
||||
var sig = (artist + '|' + title + '|' + ((station && station.id) || '')).toLowerCase();
|
||||
if (sig === lastLoggedSig) { return; }
|
||||
lastLoggedSig = sig;
|
||||
|
||||
var fd = new FormData();
|
||||
fd.append('action', 'radio_log_track');
|
||||
fd.append('nonce', cfg.nonce);
|
||||
fd.append('artist', artist);
|
||||
fd.append('title', title);
|
||||
fd.append('station', (station && station.name) || '');
|
||||
fd.append('station_id', (station && station.id) || '');
|
||||
fetch(cfg.ajaxUrl, { method: 'POST', credentials: 'same-origin', body: fd })
|
||||
.catch(function () { /* track log is best-effort */ });
|
||||
}
|
||||
|
||||
function stopTrackPolling(player) {
|
||||
if (player._trackTimer) {
|
||||
clearInterval(player._trackTimer);
|
||||
@@ -387,6 +422,44 @@
|
||||
}
|
||||
|
||||
bindMute(player, audio, volumeIn, volPctEl);
|
||||
bindPopOut(player);
|
||||
|
||||
// v0.6.0: popout auto-resume — when opened with ?play=1, immediately
|
||||
// pick up where the main tab left off. Same-origin user-gesture popups
|
||||
// are exempt from autoplay blocking on every modern browser.
|
||||
if (cfg.autoPlay) {
|
||||
setTimeout(function () {
|
||||
if (audio.paused) { audio.play().catch(function () { /* autoplay denied — user just clicks play */ }); }
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
/** v0.6.0: Pop-out window button. Opens a 380×560 standalone window
|
||||
* with just the player chrome (no WP admin), via admin-post.php?
|
||||
* action=radio_popout&play=1. The popup persists across main-tab
|
||||
* navigation so background music doesn't cut when you move around
|
||||
* the WP admin. Pauses every other audio surface in this tab so
|
||||
* there's only one stream playing at a time. */
|
||||
function bindPopOut(player) {
|
||||
var btn = player.querySelector('[data-radio-popout]');
|
||||
if (!btn) { return; }
|
||||
if (!cfg.popoutUrl) { btn.style.display = 'none'; return; } // already in popout
|
||||
btn.addEventListener('click', function () {
|
||||
var w = window.open(
|
||||
cfg.popoutUrl + '&play=1',
|
||||
'radio_popout',
|
||||
'width=380,height=560,resizable=yes,scrollbars=no,toolbar=no,location=no,menubar=no,status=no'
|
||||
);
|
||||
if (!w) {
|
||||
window.alert('Pop-out blocked by the browser. Allow popups for this site, then try again.');
|
||||
return;
|
||||
}
|
||||
w.focus();
|
||||
// Pause every audio surface in this tab — the popup is the new player.
|
||||
document.querySelectorAll('[data-radio-audio]').forEach(function (a) {
|
||||
if (!a.paused) { a.pause(); }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** Keep all .radio-player surfaces on the same station. */
|
||||
@@ -435,10 +508,79 @@
|
||||
});
|
||||
}
|
||||
|
||||
/** v0.5.0: wire the History admin page — filter, favourite-toggle,
|
||||
* clear-history. No-op on pages without these elements. */
|
||||
function bindHistoryPage() {
|
||||
var searchIn = document.getElementById('radio-history-search');
|
||||
var stationSel = document.getElementById('radio-history-station');
|
||||
var rows = document.querySelectorAll('.radio-history-row');
|
||||
var clearBtn = document.getElementById('radio-history-clear');
|
||||
|
||||
function applyFilter() {
|
||||
if (!rows.length) { return; }
|
||||
var q = (searchIn ? searchIn.value : '').toLowerCase().trim();
|
||||
var s = stationSel ? stationSel.value : '';
|
||||
rows.forEach(function (row) {
|
||||
var matchQ = !q || (row.dataset.search || '').indexOf(q) !== -1;
|
||||
var matchS = !s || row.dataset.stationId === s;
|
||||
row.classList.toggle('is-filtered', !(matchQ && matchS));
|
||||
});
|
||||
}
|
||||
if (searchIn) { searchIn.addEventListener('input', applyFilter); }
|
||||
if (stationSel) { stationSel.addEventListener('change', applyFilter); }
|
||||
|
||||
// Favourite-toggle buttons (per row)
|
||||
document.querySelectorAll('.radio-fav-btn').forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
var fd = new FormData();
|
||||
fd.append('action', 'radio_toggle_favourite');
|
||||
fd.append('nonce', btn.dataset.nonce || '');
|
||||
fd.append('artist', btn.dataset.artist || '');
|
||||
fd.append('title', btn.dataset.title || '');
|
||||
fd.append('station', btn.dataset.station || '');
|
||||
fd.append('station_id', btn.dataset.stationId || '');
|
||||
btn.disabled = true;
|
||||
fetch(cfg.ajaxUrl, { method: 'POST', credentials: 'same-origin', body: fd })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (res) {
|
||||
btn.disabled = false;
|
||||
if (!res || !res.success) { return; }
|
||||
var isFav = !!(res.data && res.data.favourite);
|
||||
btn.classList.toggle('is-fav', isFav);
|
||||
btn.textContent = isFav ? '★' : '☆';
|
||||
btn.setAttribute('aria-label', isFav
|
||||
? (cfg.strings.removeFav || 'Remove from favourites')
|
||||
: (cfg.strings.addFav || 'Add to favourites'));
|
||||
})
|
||||
.catch(function () { btn.disabled = false; });
|
||||
});
|
||||
});
|
||||
|
||||
// Clear-history button (history tab only)
|
||||
if (clearBtn) {
|
||||
clearBtn.addEventListener('click', function () {
|
||||
var msg = cfg.strings.clearConfirm || 'Clear all track history? (Favourites are kept.)';
|
||||
if (!window.confirm(msg)) { return; }
|
||||
var fd = new FormData();
|
||||
fd.append('action', 'radio_clear_history');
|
||||
fd.append('nonce', clearBtn.dataset.nonce || '');
|
||||
clearBtn.disabled = true;
|
||||
fetch(cfg.ajaxUrl, { method: 'POST', credentials: 'same-origin', body: fd })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (res) {
|
||||
if (res && res.success) { window.location.reload(); }
|
||||
else { clearBtn.disabled = false; }
|
||||
})
|
||||
.catch(function () { clearBtn.disabled = false; });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
var players = document.querySelectorAll('.radio-player');
|
||||
for (var i = 0; i < players.length; i++) { bindPlayer(players[i]); }
|
||||
bindSettingsSlider();
|
||||
bindHistoryPage();
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
|
||||
+60
-48
@@ -2,91 +2,60 @@
|
||||
/**
|
||||
* Radio — About page (WP Admin → Radio → About).
|
||||
*
|
||||
* Plain-language explanation of what the plugin does + version
|
||||
* history + link to the CHANGELOG.md on Gitea. Pattern mirrors
|
||||
* a-buddy/inc/about.php.
|
||||
* Top row: three short cards (What / Who / Credits) — equal-height,
|
||||
* balanced layout. Below: a full-width Version history card with the
|
||||
* latest release shown in full and earlier releases as a one-line
|
||||
* summary list, capped by a link to the full CHANGELOG on Gitea.
|
||||
*
|
||||
* Pattern mirrors a-buddy/inc/about.php.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
function radio_render_about_page() {
|
||||
if ( ! current_user_can( 'read' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'radio' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'a-radio' ) );
|
||||
}
|
||||
|
||||
$count = count( radio_get_stations_flat() );
|
||||
?>
|
||||
<div class="wrap radio-about-wrap">
|
||||
<h1><?php esc_html_e( 'About Radio', 'radio' ); ?></h1>
|
||||
<h1><?php esc_html_e( 'About Radio', 'a-radio' ); ?></h1>
|
||||
|
||||
<!-- ── Top row: three short cards (What / Who / Credits) ── -->
|
||||
<div class="radio-about-grid">
|
||||
|
||||
<div class="radio-about-card">
|
||||
<h2><?php esc_html_e( 'What Radio does', 'radio' ); ?></h2>
|
||||
<h2><?php esc_html_e( 'What Radio does', 'a-radio' ); ?></h2>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %d = station count */
|
||||
esc_html__( 'Adds a small, focused radio player to your WordPress dashboard. %d hand-curated SomaFM stations across 10 genres — ambient, electronic, lounge, rock, metal, jazz, world, reggae, holiday and specials. Plays in your admin pages while you work. Your chosen station + volume persist per user.', 'radio' ),
|
||||
esc_html__( 'Adds a small, focused radio player to your WordPress dashboard. %d hand-curated SomaFM stations across 10 genres — ambient, electronic, lounge, rock, metal, jazz, world, reggae, holiday and specials. Plays in your admin pages while you work. Your chosen station + volume persist per user.', 'a-radio' ),
|
||||
(int) $count
|
||||
);
|
||||
?>
|
||||
</p>
|
||||
<p>
|
||||
<?php esc_html_e( 'Audio plays directly in your browser via HTML5 — no server-side proxy, no extra services to host, no third-party tracking. Just an <audio> element pointed at SomaFM\'s public streams.', 'radio' ); ?>
|
||||
<?php esc_html_e( 'Audio plays directly in your browser via HTML5 — no server-side proxy, no extra services to host, no third-party tracking. Just an <audio> element pointed at SomaFM\'s public streams.', 'a-radio' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="radio-about-card">
|
||||
<h2><?php esc_html_e( 'Who Radio is for', 'radio' ); ?></h2>
|
||||
<h2><?php esc_html_e( 'Who Radio is for', 'a-radio' ); ?></h2>
|
||||
<p>
|
||||
<?php esc_html_e( 'Anyone who likes background music while working in the WordPress admin. Coders, writers, support agents, content editors. The 44 SomaFM stations cover a wide enough range that there\'s something for any mood — from coding-focus ambient (Groove Salad, Drone Zone) to drive-time electronic (DEF CON Radio, Beat Blender) to mellow lounge (Lush, Secret Agent) to specifically-quirky picks (SF 10-33 mixes ambient with San Francisco public-safety radio).', 'radio' ); ?>
|
||||
<?php esc_html_e( 'Anyone who likes background music while working in the WordPress admin. Coders, writers, support agents, content editors. The 44 SomaFM stations cover a wide enough range that there\'s something for any mood — from coding-focus ambient (Groove Salad, Drone Zone) to drive-time electronic (DEF CON Radio, Beat Blender) to mellow lounge (Lush, Secret Agent) to specifically-quirky picks (SF 10-33 mixes ambient with San Francisco public-safety radio).', 'a-radio' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="radio-about-card radio-about-card--versions">
|
||||
<h2><?php esc_html_e( 'Version history', 'radio' ); ?></h2>
|
||||
<ul>
|
||||
<li>
|
||||
<span class="ver">v0.4.0</span> — 29 May 2026 <span class="latest">latest</span><br>
|
||||
<?php esc_html_e( 'Now-playing visual indicator. Four tiny dancing bars next to "Now Playing" pulse while the audio is playing (pure CSS, always works). On top of that, a Web Audio frequency visualizer tries to draw live frequency bars on a small canvas — if the browser allows it and the stream is CORS-friendly it kicks in automatically; if not, the CSS bars stay and nothing breaks.', 'radio' ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">v0.3.2</span> — 29 May 2026<br>
|
||||
<?php esc_html_e( 'Play-button glyph baseline fix. The dashicon used for play/pause was rendering below the button text. Swapped to a plain Unicode glyph (▶ / ‖) that sits on the text baseline like any other character.', 'radio' ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">v0.3.1</span> — 29 May 2026<br>
|
||||
<?php esc_html_e( 'My Radio layout polish + dropped dark-auto. Player no longer stretches edge-to-edge (max-width 880px); volume slider fixed width so the % label sits next to it; station dropdown capped at 360px; play-button icon shrunk to match the button text baseline; intro paragraph now fits one line. Removed the prefers-color-scheme dark-auto behaviour that was unreadable against WordPress\'s still-white postbox; theme=dark is still available as an explicit choice and now gives the player its own dark surface so it actually reads.', 'radio' ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">v0.3.0</span> — 29 May 2026<br>
|
||||
<?php esc_html_e( 'Dark theme wired through. Mute toggle on the speaker icon. OS media keys (F8 / headphone buttons / lock-screen) play and pause via MediaSession. Current track polled from SomaFM and shown under the station description while playing. Save errors surface as a brief notice instead of being swallowed. Genre badge restyled as an inline pill.', 'radio' ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">v0.2.0</span> — 26 May 2026<br>
|
||||
<?php esc_html_e( 'UI rebuilt to WordPress admin standards. Postbox container, native Play/Pause button with text label, picks up your admin colour scheme via var(--wp-admin-theme-color), genre badge moved inline, dashboard widget no longer renders a card-inside-a-card. Functionality identical to v0.1.0 — purely visual polish.', 'radio' ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<span class="ver">v0.1.0</span> — 26 May 2026<br>
|
||||
<?php esc_html_e( 'First release. 44 SomaFM stations grouped by 10 genres, dashboard widget + dedicated admin page, per-user state in user_meta, self-hosted update checker against Gitea. Direct HTML5 audio playback — no proxy, no build step, no tracking.', 'radio' ); ?>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="radio-about-changelog-link"
|
||||
href="<?php echo esc_url( RADIO_GITEA_URL . '/src/branch/main/CHANGELOG.md' ); ?>"
|
||||
target="_blank" rel="noopener">
|
||||
<?php esc_html_e( 'View the full CHANGELOG.md →', 'radio' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="radio-about-card">
|
||||
<h2><?php esc_html_e( 'Credits + thanks', 'radio' ); ?></h2>
|
||||
<h2><?php esc_html_e( 'Credits + thanks', 'a-radio' ); ?></h2>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
wp_kses(
|
||||
/* translators: %s = link to somafm.com */
|
||||
__( 'All stations and streams are provided by %s — an independent, listener-supported, commercial-free internet radio network broadcasting from San Francisco since 2000. Radio is just a small WordPress wrapper around their public streams. If you enjoy this plugin, please consider donating to SomaFM directly.', 'radio' ),
|
||||
__( 'All stations and streams are provided by %s — an independent, listener-supported, commercial-free internet radio network broadcasting from San Francisco since 2000. Radio is just a small WordPress wrapper around their public streams. If you enjoy this plugin, please consider donating to SomaFM directly.', 'a-radio' ),
|
||||
array( 'a' => array( 'href' => true, 'target' => true, 'rel' => true ) )
|
||||
),
|
||||
'<a href="https://somafm.com/support/" target="_blank" rel="noopener">SomaFM</a>'
|
||||
@@ -94,11 +63,54 @@ function radio_render_about_page() {
|
||||
?>
|
||||
</p>
|
||||
<p>
|
||||
<?php esc_html_e( 'Plugin author: David Keane. Part of the RangerHQ plugin family. GPL v2 or later. Source on Gitea.', 'radio' ); ?>
|
||||
<?php esc_html_e( 'Plugin author: David Keane. Part of the RangerHQ plugin family. GPL v2 or later. Source on Gitea.', 'a-radio' ); ?>
|
||||
</p>
|
||||
<?php if ( defined( 'RADIO_SUPPORT_URL' ) && RADIO_SUPPORT_URL ) : ?>
|
||||
<a class="radio-support-link" href="<?php echo esc_url( RADIO_SUPPORT_URL ); ?>" target="_blank" rel="noopener">
|
||||
<?php esc_html_e( 'Like Radio? If You fancy to buy me a coffee →', 'a-radio' ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div><!-- /.radio-about-grid -->
|
||||
|
||||
<!-- ── Version history: latest in full, earlier as one-liners ── -->
|
||||
<div class="radio-about-versions">
|
||||
<h2><?php esc_html_e( 'Version history', 'a-radio' ); ?></h2>
|
||||
|
||||
<div class="radio-about-versions__latest">
|
||||
<span class="ver">v0.7.4</span> — 30 May 2026 <span class="latest"><?php esc_html_e( 'latest', 'a-radio' ); ?></span>
|
||||
<p>
|
||||
<?php esc_html_e( 'WordPress.org submission cleanup. Removed the self-hosted Gitea updater (`inc/updater.php`) and the `Update URI` header from `radio.php` — WordPress.org explicitly disallows both for hosted plugins (Plugin Check `plugin_updater_detected`). Updates now flow through WordPress.org as the canonical channel. Added a top-level LICENSE file with the full GPL v2 text and GPL header blocks to the CSS and JS assets so the licensing of every shipped file is explicit. No user-visible behaviour changes for the player — only the small `Updates` panel that used to sit at the bottom of Radio → Settings is gone.', 'a-radio' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h3><?php esc_html_e( 'Earlier releases', 'a-radio' ); ?></h3>
|
||||
<ul class="radio-about-versions__earlier">
|
||||
<li><span class="ver">v0.7.3</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'Privacy section in readme + SomaFM terms-of-use link (Update URI guard pattern from this release was walked back in v0.7.4 — Plugin Check disallows it for wp.org-hosted plugins regardless of header value)', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.7.2</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'Screenshots + correct wp.org contributor handle (ir240474)', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.7.1</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'Plugin Check follow-up — Tested-up-to bumped to 7.0, .DS_Store re-cleanup', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.7.0</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'WordPress.org submission prep — full Plugin Check clean (169 → 4 issues, branding, textdomain, security, popup refactor, readme.txt)', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.6.3</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'Discreet buy-me-a-coffee support link (Updates panel + Credits card)', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.6.2</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'Current version badge on the Settings page', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.6.1</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'About page restructure — balanced 3-card top row + compact version history', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.6.0</span> <span class="ver-date">30 May 2026</span> — <?php esc_html_e( 'Pop-out mini-player — continuous background play across admin navigation', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.5.0</span> <span class="ver-date">29 May 2026</span> — <?php esc_html_e( 'Track history + favourites (Spotify / YouTube / Apple Music / Bandcamp search links)', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.4.0</span> <span class="ver-date">29 May 2026</span> — <?php esc_html_e( 'Now-playing indicator — dancing bars + Web Audio frequency visualizer', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.3.2</span> <span class="ver-date">29 May 2026</span> — <?php esc_html_e( 'Play-button glyph baseline fix (dashicon → Unicode ▶ / ‖)', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.3.1</span> <span class="ver-date">29 May 2026</span> — <?php esc_html_e( 'My Radio layout polish + dropped dark-auto', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.3.0</span> <span class="ver-date">29 May 2026</span> — <?php esc_html_e( 'Dark theme + mute + OS media keys + SomaFM current-track display', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.2.0</span> <span class="ver-date">26 May 2026</span> — <?php esc_html_e( 'UI rebuilt to WordPress admin standards', 'a-radio' ); ?></li>
|
||||
<li><span class="ver">v0.1.0</span> <span class="ver-date">26 May 2026</span> — <?php esc_html_e( 'First release — 44 SomaFM stations, dashboard widget + dedicated admin page, per-user state, self-hosted Gitea updater', 'a-radio' ); ?></li>
|
||||
</ul>
|
||||
|
||||
<a class="radio-about-changelog-link"
|
||||
href="<?php echo esc_url( RADIO_GITEA_URL . '/src/branch/main/CHANGELOG.md' ); ?>"
|
||||
target="_blank" rel="noopener">
|
||||
<?php esc_html_e( 'View the full CHANGELOG.md →', 'a-radio' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
+14
-10
@@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
function radio_render_main_page() {
|
||||
if ( ! current_user_can( 'read' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'radio' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'a-radio' ) );
|
||||
}
|
||||
|
||||
$state = radio_get_state();
|
||||
@@ -21,13 +21,13 @@ function radio_render_main_page() {
|
||||
$count = count( radio_get_stations_flat() );
|
||||
?>
|
||||
<div class="wrap radio-wrap">
|
||||
<h1><?php esc_html_e( 'Radio', 'radio' ); ?></h1>
|
||||
<h1><?php esc_html_e( 'Radio', 'a-radio' ); ?></h1>
|
||||
|
||||
<p class="radio-intro">
|
||||
<?php
|
||||
printf(
|
||||
/* translators: %d = number of stations */
|
||||
esc_html__( 'A tab of background music for your WordPress admin. %d hand-curated SomaFM stations across 10 genres — free, no ads, no tracking.', 'radio' ),
|
||||
esc_html__( 'A tab of background music for your WordPress admin. %d hand-curated SomaFM stations across 10 genres — free, no ads, no tracking.', 'a-radio' ),
|
||||
(int) $count
|
||||
);
|
||||
?>
|
||||
@@ -35,7 +35,7 @@ function radio_render_main_page() {
|
||||
|
||||
<div class="postbox">
|
||||
<div class="postbox-header">
|
||||
<h2 class="hndle"><?php esc_html_e( 'Player', 'radio' ); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e( 'Player', 'a-radio' ); ?></h2>
|
||||
</div>
|
||||
<div class="inside">
|
||||
<div class="radio-player" data-radio-surface="main">
|
||||
@@ -45,7 +45,7 @@ function radio_render_main_page() {
|
||||
<span class="radio-player__bars"><span></span><span></span><span></span><span></span></span>
|
||||
<canvas class="radio-player__viz" data-radio-viz hidden></canvas>
|
||||
</span>
|
||||
<span class="radio-player__label"><?php esc_html_e( 'Now Playing', 'radio' ); ?></span>
|
||||
<span class="radio-player__label"><?php esc_html_e( 'Now Playing', 'a-radio' ); ?></span>
|
||||
<span class="radio-player__station-name" data-radio-name><?php echo esc_html( $station['name'] ); ?></span>
|
||||
<span class="radio-player__station-genre" data-radio-genre><?php echo esc_html( $station['genre'] ); ?></span>
|
||||
<p class="radio-player__station-desc" data-radio-desc><?php echo esc_html( $station['description'] ); ?></p>
|
||||
@@ -55,20 +55,24 @@ function radio_render_main_page() {
|
||||
<div class="radio-player__controls">
|
||||
<button type="button" class="button button-primary radio-player__play" data-radio-play>
|
||||
<span class="radio-player__play-glyph" data-radio-play-glyph aria-hidden="true">▶</span>
|
||||
<span data-radio-play-label><?php esc_html_e( 'Play', 'radio' ); ?></span>
|
||||
<span data-radio-play-label><?php esc_html_e( 'Play', 'a-radio' ); ?></span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="button radio-player__popout" data-radio-popout title="<?php esc_attr_e( 'Open in a pop-out window — keeps playing while you navigate the admin', 'a-radio' ); ?>">
|
||||
<span aria-hidden="true">↗</span> <?php esc_html_e( 'Pop out', 'a-radio' ); ?>
|
||||
</button>
|
||||
|
||||
<div class="radio-player__volume">
|
||||
<button type="button" class="radio-player__mute" data-radio-mute aria-label="<?php esc_attr_e( 'Mute', 'radio' ); ?>">
|
||||
<button type="button" class="radio-player__mute" data-radio-mute aria-label="<?php esc_attr_e( 'Mute', 'a-radio' ); ?>">
|
||||
<span class="dashicons dashicons-controls-volumeon" aria-hidden="true"></span>
|
||||
</button>
|
||||
<input type="range" min="0" max="100" value="<?php echo esc_attr( (int) round( $state['volume'] * 100 ) ); ?>" data-radio-volume aria-label="<?php esc_attr_e( 'Volume', 'radio' ); ?>">
|
||||
<input type="range" min="0" max="100" value="<?php echo esc_attr( (int) round( $state['volume'] * 100 ) ); ?>" data-radio-volume aria-label="<?php esc_attr_e( 'Volume', 'a-radio' ); ?>">
|
||||
<span class="radio-player__volume-pct" data-radio-volume-pct><?php echo esc_html( (int) round( $state['volume'] * 100 ) ); ?>%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="radio-player__station-select">
|
||||
<label for="radio-station-main"><?php esc_html_e( 'Station', 'radio' ); ?></label>
|
||||
<label for="radio-station-main"><?php esc_html_e( 'Station', 'a-radio' ); ?></label>
|
||||
<select id="radio-station-main" data-radio-station>
|
||||
<?php foreach ( $stations as $genre => $entries ) :
|
||||
if ( empty( $entries ) ) { continue; }
|
||||
@@ -96,7 +100,7 @@ function radio_render_main_page() {
|
||||
printf(
|
||||
wp_kses(
|
||||
/* translators: %s = link to somafm.com */
|
||||
__( 'Stations and streams provided by %s — an independent, listener-supported, commercial-free internet radio network. Please consider supporting them.', 'radio' ),
|
||||
__( 'Stations and streams provided by %s — an independent, listener-supported, commercial-free internet radio network. Please consider supporting them.', 'a-radio' ),
|
||||
array( 'a' => array( 'href' => true, 'target' => true, 'rel' => true ) )
|
||||
),
|
||||
'<a href="https://somafm.com/" target="_blank" rel="noopener">SomaFM</a>'
|
||||
|
||||
@@ -21,7 +21,7 @@ function radio_register_dashboard_widget() {
|
||||
|
||||
wp_add_dashboard_widget(
|
||||
'radio_dashboard_widget',
|
||||
__( 'Radio', 'radio' ),
|
||||
__( 'Radio', 'a-radio' ),
|
||||
'radio_render_dashboard_widget'
|
||||
);
|
||||
}
|
||||
@@ -38,7 +38,7 @@ function radio_render_dashboard_widget() {
|
||||
<span class="radio-player__bars"><span></span><span></span><span></span><span></span></span>
|
||||
<canvas class="radio-player__viz" data-radio-viz hidden></canvas>
|
||||
</span>
|
||||
<span class="radio-player__label"><?php esc_html_e( 'Now Playing', 'radio' ); ?></span>
|
||||
<span class="radio-player__label"><?php esc_html_e( 'Now Playing', 'a-radio' ); ?></span>
|
||||
<span class="radio-player__station-name" data-radio-name><?php echo esc_html( $station['name'] ); ?></span>
|
||||
<span class="radio-player__station-genre" data-radio-genre><?php echo esc_html( $station['genre'] ); ?></span>
|
||||
<p class="radio-player__station-desc" data-radio-desc><?php echo esc_html( $station['description'] ); ?></p>
|
||||
@@ -48,20 +48,24 @@ function radio_render_dashboard_widget() {
|
||||
<div class="radio-player__controls">
|
||||
<button type="button" class="button button-primary radio-player__play" data-radio-play>
|
||||
<span class="radio-player__play-glyph" data-radio-play-glyph aria-hidden="true">▶</span>
|
||||
<span data-radio-play-label><?php esc_html_e( 'Play', 'radio' ); ?></span>
|
||||
<span data-radio-play-label><?php esc_html_e( 'Play', 'a-radio' ); ?></span>
|
||||
</button>
|
||||
|
||||
<button type="button" class="button radio-player__popout" data-radio-popout title="<?php esc_attr_e( 'Open in a pop-out window — keeps playing while you navigate', 'a-radio' ); ?>">
|
||||
<span aria-hidden="true">↗</span> <?php esc_html_e( 'Pop out', 'a-radio' ); ?>
|
||||
</button>
|
||||
|
||||
<div class="radio-player__volume">
|
||||
<button type="button" class="radio-player__mute" data-radio-mute aria-label="<?php esc_attr_e( 'Mute', 'radio' ); ?>">
|
||||
<button type="button" class="radio-player__mute" data-radio-mute aria-label="<?php esc_attr_e( 'Mute', 'a-radio' ); ?>">
|
||||
<span class="dashicons dashicons-controls-volumeon" aria-hidden="true"></span>
|
||||
</button>
|
||||
<input type="range" min="0" max="100" value="<?php echo esc_attr( (int) round( $state['volume'] * 100 ) ); ?>" data-radio-volume aria-label="<?php esc_attr_e( 'Volume', 'radio' ); ?>">
|
||||
<input type="range" min="0" max="100" value="<?php echo esc_attr( (int) round( $state['volume'] * 100 ) ); ?>" data-radio-volume aria-label="<?php esc_attr_e( 'Volume', 'a-radio' ); ?>">
|
||||
<span class="radio-player__volume-pct" data-radio-volume-pct><?php echo esc_html( (int) round( $state['volume'] * 100 ) ); ?>%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="radio-player__station-select">
|
||||
<label for="radio-station-widget"><?php esc_html_e( 'Station', 'radio' ); ?></label>
|
||||
<label for="radio-station-widget"><?php esc_html_e( 'Station', 'a-radio' ); ?></label>
|
||||
<select id="radio-station-widget" data-radio-station>
|
||||
<?php foreach ( $stations as $genre => $entries ) :
|
||||
if ( empty( $entries ) ) { continue; }
|
||||
@@ -86,7 +90,7 @@ function radio_render_dashboard_widget() {
|
||||
printf(
|
||||
wp_kses(
|
||||
/* translators: %s = link to somafm.com */
|
||||
__( 'Powered by %s', 'radio' ),
|
||||
__( 'Powered by %s', 'a-radio' ),
|
||||
array( 'a' => array( 'href' => true, 'target' => true, 'rel' => true ) )
|
||||
),
|
||||
'<a href="https://somafm.com/" target="_blank" rel="noopener">SomaFM</a>'
|
||||
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
<?php
|
||||
/**
|
||||
* Radio — track history + favourites (v0.5.0).
|
||||
*
|
||||
* Storage: two per-user `wp_usermeta` keys, separate from `radio_state`
|
||||
* so frequent track logging doesn't rewrite the whole state blob.
|
||||
* radio_history — capped FIFO list of recently played tracks
|
||||
* radio_favourites — uncapped list of user-starred tracks
|
||||
*
|
||||
* Entry shape:
|
||||
* array(
|
||||
* 'artist' => string,
|
||||
* 'title' => string,
|
||||
* 'station' => string, // display name e.g. "DEF CON Radio"
|
||||
* 'station_id' => string, // e.g. "soma-defcon"
|
||||
* 'at' => int, // unix timestamp
|
||||
* )
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
const RADIO_HISTORY_KEY = 'radio_history';
|
||||
const RADIO_FAVOURITES_KEY = 'radio_favourites';
|
||||
const RADIO_HISTORY_CAP = 500;
|
||||
|
||||
/** Current user's track history (oldest first). */
|
||||
function radio_get_history( $user_id = 0 ) {
|
||||
$user_id = $user_id ? (int) $user_id : get_current_user_id();
|
||||
if ( ! $user_id ) { return array(); }
|
||||
$h = get_user_meta( $user_id, RADIO_HISTORY_KEY, true );
|
||||
return is_array( $h ) ? $h : array();
|
||||
}
|
||||
|
||||
/** Current user's favourited tracks (oldest first). */
|
||||
function radio_get_favourites( $user_id = 0 ) {
|
||||
$user_id = $user_id ? (int) $user_id : get_current_user_id();
|
||||
if ( ! $user_id ) { return array(); }
|
||||
$f = get_user_meta( $user_id, RADIO_FAVOURITES_KEY, true );
|
||||
return is_array( $f ) ? $f : array();
|
||||
}
|
||||
|
||||
/** Normalise raw POSTed track data; returns null on junk input. */
|
||||
function radio_sanitize_entry( $entry ) {
|
||||
if ( ! is_array( $entry ) ) { return null; }
|
||||
$artist = isset( $entry['artist'] ) ? sanitize_text_field( wp_unslash( $entry['artist'] ) ) : '';
|
||||
$title = isset( $entry['title'] ) ? sanitize_text_field( wp_unslash( $entry['title'] ) ) : '';
|
||||
$station = isset( $entry['station'] ) ? sanitize_text_field( wp_unslash( $entry['station'] ) ) : '';
|
||||
$station_id = isset( $entry['station_id'] ) ? sanitize_key( wp_unslash( $entry['station_id'] ) ) : '';
|
||||
if ( ! $artist || ! $title ) { return null; }
|
||||
if ( strtolower( $artist ) === '(unknown)' ) { return null; } // SomaFM promo / dead-air placeholder
|
||||
return array(
|
||||
'artist' => mb_substr( $artist, 0, 200 ),
|
||||
'title' => mb_substr( $title, 0, 200 ),
|
||||
'station' => mb_substr( $station, 0, 100 ),
|
||||
'station_id' => $station_id,
|
||||
'at' => time(),
|
||||
);
|
||||
}
|
||||
|
||||
/** Dedup signature — artist|title|station_id, lowercased + trimmed. */
|
||||
function radio_entry_signature( $entry ) {
|
||||
$a = isset( $entry['artist'] ) ? $entry['artist'] : '';
|
||||
$t = isset( $entry['title'] ) ? $entry['title'] : '';
|
||||
$s = isset( $entry['station_id'] ) ? $entry['station_id'] : '';
|
||||
return strtolower( trim( $a . '|' . $t . '|' . $s ) );
|
||||
}
|
||||
|
||||
/** Append a track to the user's history, deduped against the last entry
|
||||
* and capped at RADIO_HISTORY_CAP. Returns true if appended. */
|
||||
function radio_log_track( $entry, $user_id = 0 ) {
|
||||
$user_id = $user_id ? (int) $user_id : get_current_user_id();
|
||||
if ( ! $user_id ) { return false; }
|
||||
$clean = radio_sanitize_entry( $entry );
|
||||
if ( ! $clean ) { return false; }
|
||||
|
||||
$history = radio_get_history( $user_id );
|
||||
if ( ! empty( $history ) ) {
|
||||
$last_sig = radio_entry_signature( $history[ count( $history ) - 1 ] );
|
||||
if ( radio_entry_signature( $clean ) === $last_sig ) { return false; }
|
||||
}
|
||||
|
||||
$history[] = $clean;
|
||||
if ( count( $history ) > RADIO_HISTORY_CAP ) {
|
||||
$history = array_slice( $history, -RADIO_HISTORY_CAP );
|
||||
}
|
||||
update_user_meta( $user_id, RADIO_HISTORY_KEY, $history );
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Toggle whether an entry is favourited. Returns the new state
|
||||
* (true = now favourited, false = now unfavourited). */
|
||||
function radio_toggle_favourite( $entry, $user_id = 0 ) {
|
||||
$user_id = $user_id ? (int) $user_id : get_current_user_id();
|
||||
if ( ! $user_id ) { return false; }
|
||||
$clean = radio_sanitize_entry( $entry );
|
||||
if ( ! $clean ) { return false; }
|
||||
$sig = radio_entry_signature( $clean );
|
||||
|
||||
$favs = radio_get_favourites( $user_id );
|
||||
$found = -1;
|
||||
foreach ( $favs as $i => $f ) {
|
||||
if ( radio_entry_signature( $f ) === $sig ) { $found = $i; break; }
|
||||
}
|
||||
if ( $found >= 0 ) {
|
||||
array_splice( $favs, $found, 1 );
|
||||
update_user_meta( $user_id, RADIO_FAVOURITES_KEY, $favs );
|
||||
return false;
|
||||
}
|
||||
$favs[] = $clean;
|
||||
update_user_meta( $user_id, RADIO_FAVOURITES_KEY, $favs );
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Clear the user's history (favourites preserved). */
|
||||
function radio_clear_history_all( $user_id = 0 ) {
|
||||
$user_id = $user_id ? (int) $user_id : get_current_user_id();
|
||||
if ( ! $user_id ) { return false; }
|
||||
delete_user_meta( $user_id, RADIO_HISTORY_KEY );
|
||||
return true;
|
||||
}
|
||||
|
||||
/** URL-build helpers for the four search providers. */
|
||||
function radio_search_urls( $artist, $title ) {
|
||||
$enc = rawurlencode( trim( $artist . ' ' . $title ) );
|
||||
return array(
|
||||
'spotify' => 'https://open.spotify.com/search/' . $enc,
|
||||
'youtube' => 'https://www.youtube.com/results?search_query=' . $enc,
|
||||
'apple' => 'https://music.apple.com/search?term=' . $enc,
|
||||
'bandcamp' => 'https://bandcamp.com/search?q=' . $enc,
|
||||
);
|
||||
}
|
||||
|
||||
/** Render the History admin page (tabs: History / Favourites). */
|
||||
function radio_render_history_page() {
|
||||
if ( ! current_user_can( 'read' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'a-radio' ) );
|
||||
}
|
||||
|
||||
$tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : 'history'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- tab-switch only, no state change
|
||||
if ( ! in_array( $tab, array( 'history', 'favourites' ), true ) ) { $tab = 'history'; }
|
||||
|
||||
$all_history = radio_get_history();
|
||||
$all_favourites = radio_get_favourites();
|
||||
$entries = ( $tab === 'favourites' ) ? $all_favourites : $all_history;
|
||||
$entries = array_reverse( $entries ); // newest first
|
||||
|
||||
// Set of favourite signatures for fast lookup in the row render.
|
||||
$fav_sigs = array();
|
||||
foreach ( $all_favourites as $f ) { $fav_sigs[ radio_entry_signature( $f ) ] = true; }
|
||||
|
||||
// Stations present in the current tab → filter dropdown options.
|
||||
$stations_in_list = array();
|
||||
foreach ( $entries as $e ) {
|
||||
if ( ! empty( $e['station_id'] ) && ! isset( $stations_in_list[ $e['station_id'] ] ) ) {
|
||||
$stations_in_list[ $e['station_id'] ] = $e['station'];
|
||||
}
|
||||
}
|
||||
asort( $stations_in_list );
|
||||
|
||||
$base_url = admin_url( 'admin.php?page=radio-history' );
|
||||
$hist_url = $base_url . '&tab=history';
|
||||
$fav_url = $base_url . '&tab=favourites';
|
||||
$nonce = wp_create_nonce( 'radio_history' );
|
||||
?>
|
||||
<div class="wrap radio-history-wrap">
|
||||
<h1><?php esc_html_e( 'Radio — Track history', 'a-radio' ); ?></h1>
|
||||
|
||||
<h2 class="nav-tab-wrapper">
|
||||
<a href="<?php echo esc_url( $hist_url ); ?>" class="nav-tab <?php echo $tab === 'history' ? 'nav-tab-active' : ''; ?>">
|
||||
<?php esc_html_e( 'History', 'a-radio' ); ?>
|
||||
<span class="radio-tab-count">(<?php echo (int) count( $all_history ); ?>)</span>
|
||||
</a>
|
||||
<a href="<?php echo esc_url( $fav_url ); ?>" class="nav-tab <?php echo $tab === 'favourites' ? 'nav-tab-active' : ''; ?>">
|
||||
★ <?php esc_html_e( 'Favourites', 'a-radio' ); ?>
|
||||
<span class="radio-tab-count">(<?php echo (int) count( $all_favourites ); ?>)</span>
|
||||
</a>
|
||||
</h2>
|
||||
|
||||
<?php if ( empty( $entries ) ) : ?>
|
||||
<p class="radio-history-empty">
|
||||
<?php if ( $tab === 'favourites' ) : ?>
|
||||
<?php esc_html_e( 'No favourites yet — star a track on the History tab to save it here.', 'a-radio' ); ?>
|
||||
<?php else : ?>
|
||||
<?php esc_html_e( 'No tracks logged yet. Play some music in the Radio player — tracks will appear here as they play.', 'a-radio' ); ?>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
<?php else : ?>
|
||||
|
||||
<div class="radio-history-toolbar">
|
||||
<input type="search" id="radio-history-search" placeholder="<?php esc_attr_e( 'Filter by artist or title…', 'a-radio' ); ?>" />
|
||||
<select id="radio-history-station">
|
||||
<option value=""><?php esc_html_e( 'All stations', 'a-radio' ); ?></option>
|
||||
<?php foreach ( $stations_in_list as $sid => $sname ) : ?>
|
||||
<option value="<?php echo esc_attr( $sid ); ?>"><?php echo esc_html( $sname ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php if ( $tab === 'history' ) : ?>
|
||||
<button type="button" id="radio-history-clear" class="button radio-history-clear" data-nonce="<?php echo esc_attr( $nonce ); ?>">
|
||||
🗑 <?php esc_html_e( 'Clear history', 'a-radio' ); ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<table class="widefat radio-history-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="when"><?php esc_html_e( 'When', 'a-radio' ); ?></th>
|
||||
<th class="station"><?php esc_html_e( 'Station', 'a-radio' ); ?></th>
|
||||
<th class="track"><?php esc_html_e( 'Artist — Title', 'a-radio' ); ?></th>
|
||||
<th class="search"><?php esc_html_e( 'Search', 'a-radio' ); ?></th>
|
||||
<th class="fav"><span class="screen-reader-text"><?php esc_html_e( 'Favourite', 'a-radio' ); ?></span>★</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ( $entries as $e ) :
|
||||
$sig = radio_entry_signature( $e );
|
||||
$is_fav = isset( $fav_sigs[ $sig ] );
|
||||
$search = radio_search_urls( $e['artist'], $e['title'] );
|
||||
$ago = human_time_diff( (int) $e['at'], time() );
|
||||
?>
|
||||
<tr class="radio-history-row" data-station-id="<?php echo esc_attr( $e['station_id'] ); ?>" data-search="<?php echo esc_attr( strtolower( $e['artist'] . ' ' . $e['title'] ) ); ?>">
|
||||
<td class="when" title="<?php echo esc_attr( wp_date( 'j M Y, H:i', (int) $e['at'] ) ); ?>">
|
||||
<?php
|
||||
/* translators: %s = human-readable time difference, e.g. "2 minutes" */
|
||||
printf( esc_html__( '%s ago', 'a-radio' ), esc_html( $ago ) );
|
||||
?>
|
||||
</td>
|
||||
<td class="station"><?php echo esc_html( $e['station'] ); ?></td>
|
||||
<td class="track">
|
||||
<strong><?php echo esc_html( $e['artist'] ); ?></strong> — <?php echo esc_html( $e['title'] ); ?>
|
||||
</td>
|
||||
<td class="search">
|
||||
<a href="<?php echo esc_url( $search['spotify'] ); ?>" target="_blank" rel="noopener" class="radio-search-link radio-search-link--spotify">Spotify</a>
|
||||
<a href="<?php echo esc_url( $search['youtube'] ); ?>" target="_blank" rel="noopener" class="radio-search-link radio-search-link--youtube">YouTube</a>
|
||||
<a href="<?php echo esc_url( $search['apple'] ); ?>" target="_blank" rel="noopener" class="radio-search-link radio-search-link--apple">Apple</a>
|
||||
<a href="<?php echo esc_url( $search['bandcamp'] ); ?>" target="_blank" rel="noopener" class="radio-search-link radio-search-link--bandcamp">Bandcamp</a>
|
||||
</td>
|
||||
<td class="fav">
|
||||
<button type="button"
|
||||
class="radio-fav-btn <?php echo $is_fav ? 'is-fav' : ''; ?>"
|
||||
data-artist="<?php echo esc_attr( $e['artist'] ); ?>"
|
||||
data-title="<?php echo esc_attr( $e['title'] ); ?>"
|
||||
data-station="<?php echo esc_attr( $e['station'] ); ?>"
|
||||
data-station-id="<?php echo esc_attr( $e['station_id'] ); ?>"
|
||||
data-nonce="<?php echo esc_attr( $nonce ); ?>"
|
||||
aria-label="<?php echo $is_fav ? esc_attr__( 'Remove from favourites', 'a-radio' ) : esc_attr__( 'Add to favourites', 'a-radio' ); ?>">
|
||||
<?php echo $is_fav ? '★' : '☆'; ?>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
+18
-23
@@ -3,15 +3,14 @@
|
||||
* Radio — Settings page.
|
||||
*
|
||||
* Lets the user pick default station + volume + theme + dashboard
|
||||
* widget opt-out. Renders the Updates panel from `updater.php` at the
|
||||
* bottom.
|
||||
* widget opt-out.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
function radio_render_settings_page() {
|
||||
if ( ! current_user_can( 'read' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'radio' ) );
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'a-radio' ) );
|
||||
}
|
||||
|
||||
// Handle form submission.
|
||||
@@ -39,7 +38,7 @@ function radio_render_settings_page() {
|
||||
$state['hide_dashboard_widget'] = $hide_widget ? 1 : 0;
|
||||
update_user_meta( $user_id, RADIO_META_KEY, $state );
|
||||
|
||||
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Settings saved.', 'radio' ) . '</p></div>';
|
||||
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__( 'Settings saved.', 'a-radio' ) . '</p></div>';
|
||||
}
|
||||
|
||||
$state = radio_get_state();
|
||||
@@ -47,7 +46,10 @@ function radio_render_settings_page() {
|
||||
$hide_widget = ! empty( $state['hide_dashboard_widget'] );
|
||||
?>
|
||||
<div class="wrap radio-settings-wrap">
|
||||
<h1><?php esc_html_e( 'Radio — Settings', 'radio' ); ?></h1>
|
||||
<h1>
|
||||
<?php esc_html_e( 'Radio — Settings', 'a-radio' ); ?>
|
||||
<span class="radio-version-badge">v<?php echo esc_html( RADIO_VERSION ); ?></span>
|
||||
</h1>
|
||||
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field( 'radio_save_settings', 'radio_settings_nonce' ); ?>
|
||||
@@ -55,7 +57,7 @@ function radio_render_settings_page() {
|
||||
<table class="form-table" role="presentation">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="default_station"><?php esc_html_e( 'Default station', 'radio' ); ?></label>
|
||||
<label for="default_station"><?php esc_html_e( 'Default station', 'a-radio' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<select id="default_station" name="default_station">
|
||||
@@ -72,14 +74,14 @@ function radio_render_settings_page() {
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'The station that loads when you open Radio in a fresh tab.', 'radio' ); ?>
|
||||
<?php esc_html_e( 'The station that loads when you open Radio in a fresh tab.', 'a-radio' ); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="default_volume"><?php esc_html_e( 'Default volume', 'radio' ); ?></label>
|
||||
<label for="default_volume"><?php esc_html_e( 'Default volume', 'a-radio' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input type="range" id="default_volume" name="default_volume" min="0" max="100" value="<?php echo esc_attr( (int) round( $state['volume'] * 100 ) ); ?>" aria-describedby="default_volume_label">
|
||||
@@ -89,42 +91,35 @@ function radio_render_settings_page() {
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="theme"><?php esc_html_e( 'Theme', 'radio' ); ?></label>
|
||||
<label for="theme"><?php esc_html_e( 'Theme', 'a-radio' ); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<select id="theme" name="theme">
|
||||
<option value="auto" <?php selected( $state['theme'], 'auto' ); ?>><?php esc_html_e( 'Auto (match WP admin colour scheme)', 'radio' ); ?></option>
|
||||
<option value="light" <?php selected( $state['theme'], 'light' ); ?>><?php esc_html_e( 'Light', 'radio' ); ?></option>
|
||||
<option value="dark" <?php selected( $state['theme'], 'dark' ); ?>><?php esc_html_e( 'Dark', 'radio' ); ?></option>
|
||||
<option value="auto" <?php selected( $state['theme'], 'auto' ); ?>><?php esc_html_e( 'Auto (match WP admin colour scheme)', 'a-radio' ); ?></option>
|
||||
<option value="light" <?php selected( $state['theme'], 'light' ); ?>><?php esc_html_e( 'Light', 'a-radio' ); ?></option>
|
||||
<option value="dark" <?php selected( $state['theme'], 'dark' ); ?>><?php esc_html_e( 'Dark', 'a-radio' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php esc_html_e( 'Dashboard widget', 'radio' ); ?>
|
||||
<?php esc_html_e( 'Dashboard widget', 'a-radio' ); ?>
|
||||
</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="hide_dashboard_widget" value="1" <?php checked( $hide_widget ); ?>>
|
||||
<?php esc_html_e( 'Hide the Radio widget from the WordPress Dashboard', 'radio' ); ?>
|
||||
<?php esc_html_e( 'Hide the Radio widget from the WordPress Dashboard', 'a-radio' ); ?>
|
||||
</label>
|
||||
<p class="description">
|
||||
<?php esc_html_e( 'When checked, Radio is only accessible from the dedicated admin page (WP Admin → Radio → My Radio).', 'radio' ); ?>
|
||||
<?php esc_html_e( 'When checked, Radio is only accessible from the dedicated admin page (WP Admin → Radio → My Radio).', 'a-radio' ); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php submit_button( __( 'Save Changes', 'radio' ), 'primary', 'radio_settings_submit' ); ?>
|
||||
<?php submit_button( __( 'Save Changes', 'a-radio' ), 'primary', 'radio_settings_submit' ); ?>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
// Updates panel — only manage_options users see it.
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
radio_render_updates_panel();
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
-238
@@ -1,238 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Radio — self-hosted update checker against the Gitea repo.
|
||||
*
|
||||
* Direct port of the Buddy / Logbook updater (proven in production).
|
||||
* Polls Gitea's /releases/latest, falls back to /tags?limit=1 when no
|
||||
* formal Release object exists, compares against RADIO_VERSION,
|
||||
* renders an Updates panel on the Settings page. Cached 12h on
|
||||
* success, 1h on negative responses.
|
||||
*
|
||||
* Repo coordinates are constants you can override via define() in
|
||||
* wp-config.php if the repo ever moves.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
if ( ! defined( 'RADIO_GITEA_HOST' ) ) { define( 'RADIO_GITEA_HOST', 'https://git.davidtkeane.com' ); }
|
||||
if ( ! defined( 'RADIO_GITEA_OWNER' ) ) { define( 'RADIO_GITEA_OWNER', 'ranger' ); }
|
||||
if ( ! defined( 'RADIO_GITEA_REPO' ) ) { define( 'RADIO_GITEA_REPO', 'a-radio' ); }
|
||||
|
||||
function radio_gitea_repo_url() {
|
||||
return RADIO_GITEA_HOST . '/' . RADIO_GITEA_OWNER . '/' . RADIO_GITEA_REPO;
|
||||
}
|
||||
function radio_gitea_releases_url() {
|
||||
return radio_gitea_repo_url() . '/releases';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the latest release/tag, normalised. Returns null on hard
|
||||
* error, or an array including `version`.
|
||||
*/
|
||||
function radio_fetch_latest_release( $force_refresh = false ) {
|
||||
$cache_key = 'radio_gitea_latest';
|
||||
|
||||
if ( ! $force_refresh ) {
|
||||
$cached = get_site_transient( $cache_key );
|
||||
if ( is_array( $cached ) ) { return $cached; }
|
||||
}
|
||||
|
||||
$base_api = RADIO_GITEA_HOST . '/api/v1/repos/' . RADIO_GITEA_OWNER . '/' . RADIO_GITEA_REPO;
|
||||
|
||||
// Try formal Release first.
|
||||
$response = wp_remote_get( $base_api . '/releases/latest', array( 'timeout' => 8 ) );
|
||||
if ( is_wp_error( $response ) ) { return null; }
|
||||
|
||||
$code = (int) wp_remote_retrieve_response_code( $response );
|
||||
$body = ( $code === 200 ) ? json_decode( wp_remote_retrieve_body( $response ), true ) : null;
|
||||
|
||||
// Fallback to /tags if no Release object exists yet.
|
||||
if ( $code !== 200 || ! is_array( $body ) || empty( $body['tag_name'] ) ) {
|
||||
$tags_response = wp_remote_get( $base_api . '/tags?limit=1', array( 'timeout' => 8 ) );
|
||||
if ( ! is_wp_error( $tags_response )
|
||||
&& (int) wp_remote_retrieve_response_code( $tags_response ) === 200 ) {
|
||||
$tags = json_decode( wp_remote_retrieve_body( $tags_response ), true );
|
||||
if ( is_array( $tags ) && ! empty( $tags[0]['name'] ) ) {
|
||||
$body = array(
|
||||
'tag_name' => $tags[0]['name'],
|
||||
'html_url' => radio_gitea_repo_url() . '/src/tag/' . rawurlencode( $tags[0]['name'] ),
|
||||
'body' => isset( $tags[0]['message'] ) ? $tags[0]['message'] : '',
|
||||
'published_at' => isset( $tags[0]['commit']['created'] ) ? $tags[0]['commit']['created'] : null,
|
||||
'assets' => array(),
|
||||
);
|
||||
$code = 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $code !== 200 || ! is_array( $body ) || empty( $body['tag_name'] ) ) {
|
||||
$info = array(
|
||||
'version' => null,
|
||||
'html_url' => radio_gitea_releases_url(),
|
||||
'download_url' => null,
|
||||
'body' => '',
|
||||
'published_at' => null,
|
||||
'error_code' => $code,
|
||||
);
|
||||
set_site_transient( $cache_key, $info, HOUR_IN_SECONDS );
|
||||
return $info;
|
||||
}
|
||||
|
||||
$version = ltrim( (string) $body['tag_name'], 'vV' );
|
||||
|
||||
// Prefer a .zip asset; fall back to Gitea source-archive URL.
|
||||
$download_url = null;
|
||||
if ( ! empty( $body['assets'] ) && is_array( $body['assets'] ) ) {
|
||||
foreach ( $body['assets'] as $asset ) {
|
||||
if ( isset( $asset['name'], $asset['browser_download_url'] )
|
||||
&& substr( strtolower( $asset['name'] ), -4 ) === '.zip' ) {
|
||||
$download_url = $asset['browser_download_url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! $download_url ) {
|
||||
$download_url = radio_gitea_repo_url() . '/archive/' . rawurlencode( $body['tag_name'] ) . '.zip';
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'version' => $version,
|
||||
'html_url' => isset( $body['html_url'] ) ? esc_url_raw( $body['html_url'] ) : '',
|
||||
'download_url' => esc_url_raw( $download_url ),
|
||||
'body' => isset( $body['body'] ) ? wp_strip_all_tags( $body['body'] ) : '',
|
||||
'published_at' => isset( $body['published_at'] ) ? $body['published_at'] : null,
|
||||
);
|
||||
|
||||
set_site_transient( $cache_key, $info, 12 * HOUR_IN_SECONDS );
|
||||
return $info;
|
||||
}
|
||||
|
||||
function radio_update_status( $force_refresh = false ) {
|
||||
$current = defined( 'RADIO_VERSION' ) ? RADIO_VERSION : '0.0.0';
|
||||
$latest = radio_fetch_latest_release( $force_refresh );
|
||||
|
||||
if ( ! $latest || empty( $latest['version'] ) ) {
|
||||
$msg = __( 'No releases tagged on the Gitea repo yet.', 'radio' );
|
||||
if ( $latest && ! empty( $latest['error_code'] ) && (int) $latest['error_code'] !== 404 ) {
|
||||
$msg = sprintf( __( 'Could not reach Gitea (HTTP %d). Try again in a few minutes.', 'radio' ), (int) $latest['error_code'] );
|
||||
}
|
||||
return array(
|
||||
'status' => 'unknown',
|
||||
'current' => $current,
|
||||
'message' => $msg,
|
||||
'repo_url' => radio_gitea_repo_url(),
|
||||
);
|
||||
}
|
||||
|
||||
if ( version_compare( $latest['version'], $current, '>' ) ) {
|
||||
return array(
|
||||
'status' => 'available',
|
||||
'current' => $current,
|
||||
'latest' => $latest['version'],
|
||||
'html_url' => $latest['html_url'],
|
||||
'download_url' => $latest['download_url'],
|
||||
'published_at' => $latest['published_at'],
|
||||
'body' => $latest['body'],
|
||||
'message' => sprintf( __( 'A new version (v%1$s) is available — you are on v%2$s.', 'radio' ), $latest['version'], $current ),
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
'status' => 'up-to-date',
|
||||
'current' => $current,
|
||||
'latest' => $latest['version'],
|
||||
'message' => sprintf( __( 'You are up to date (v%s).', 'radio' ), $current ),
|
||||
'repo_url' => radio_gitea_repo_url(),
|
||||
);
|
||||
}
|
||||
|
||||
add_action( 'wp_ajax_radio_check_updates', 'radio_ajax_check_updates' );
|
||||
function radio_ajax_check_updates() {
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( 'Insufficient permissions.', 403 );
|
||||
}
|
||||
check_ajax_referer( 'radio_check_updates', 'nonce' );
|
||||
delete_site_transient( 'radio_gitea_latest' );
|
||||
wp_send_json_success( radio_update_status( true ) );
|
||||
}
|
||||
|
||||
function radio_render_updates_panel() {
|
||||
$status = radio_update_status( false );
|
||||
$nonce = wp_create_nonce( 'radio_check_updates' );
|
||||
$repo_url = radio_gitea_repo_url();
|
||||
$rel_url = radio_gitea_releases_url();
|
||||
?>
|
||||
<div class="radio-updates" style="max-width:720px; margin-top:24px; padding:18px 20px; background:#fff; border:1px solid #ccd0d4; border-radius:4px;">
|
||||
<h2 style="margin-top:0;"><?php esc_html_e( 'Updates', 'radio' ); ?></h2>
|
||||
<p style="margin:0 0 12px;">
|
||||
<?php esc_html_e( 'Radio is self-hosted on Gitea. Click Check now to ask the repo whether there is a newer release than the one you are running.', 'radio' ); ?>
|
||||
</p>
|
||||
|
||||
<p id="radio-update-status" style="margin:0 0 12px;">
|
||||
<strong><?php esc_html_e( 'Status:', 'radio' ); ?></strong>
|
||||
<span id="radio-update-status-text"><?php echo esc_html( $status['message'] ); ?></span>
|
||||
<?php if ( $status['status'] === 'available' && ! empty( $status['download_url'] ) ) : ?>
|
||||
<br>
|
||||
<a href="<?php echo esc_url( $status['download_url'] ); ?>" class="button button-primary" style="margin-top:8px;">
|
||||
<?php
|
||||
/* translators: %s is the latest version number, e.g. "0.2.0" */
|
||||
echo esc_html( sprintf( __( 'Download v%s (.zip)', 'radio' ), $status['latest'] ) );
|
||||
?>
|
||||
</a>
|
||||
<?php if ( ! empty( $status['html_url'] ) ) : ?>
|
||||
<a href="<?php echo esc_url( $status['html_url'] ); ?>" target="_blank" rel="noopener" style="margin-left:8px;"><?php esc_html_e( 'View release notes →', 'radio' ); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
|
||||
<p style="margin:0 0 4px;">
|
||||
<button type="button" id="radio-check-updates-btn" class="button" data-nonce="<?php echo esc_attr( $nonce ); ?>">
|
||||
↻ <?php esc_html_e( 'Check now', 'radio' ); ?>
|
||||
</button>
|
||||
<a href="<?php echo esc_url( $repo_url ); ?>" target="_blank" rel="noopener" class="button" style="margin-left:6px;"><?php esc_html_e( 'View on Gitea', 'radio' ); ?></a>
|
||||
<a href="<?php echo esc_url( $rel_url ); ?>" target="_blank" rel="noopener" class="button" style="margin-left:6px;"><?php esc_html_e( 'View all releases', 'radio' ); ?></a>
|
||||
</p>
|
||||
<p style="margin:10px 0 0; color:#646970; font-size:12px;">
|
||||
<?php esc_html_e( 'Manual update path: download the .zip, deactivate the plugin in WordPress, upload via Plugins → Add New → Upload, reactivate. Your settings survive the upgrade (state is stored in user_meta).', 'radio' ); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var btn = document.getElementById('radio-check-updates-btn');
|
||||
var statusText = document.getElementById('radio-update-status-text');
|
||||
if (!btn || !statusText) { return; }
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
var nonce = btn.getAttribute('data-nonce');
|
||||
btn.disabled = true;
|
||||
var orig = btn.textContent;
|
||||
btn.textContent = '↻ Checking…';
|
||||
statusText.textContent = 'Asking Gitea…';
|
||||
|
||||
var fd = new FormData();
|
||||
fd.append('action', 'radio_check_updates');
|
||||
fd.append('nonce', nonce);
|
||||
|
||||
fetch(ajaxurl, { method: 'POST', credentials: 'same-origin', body: fd })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (res) {
|
||||
if (!res || !res.success) {
|
||||
statusText.textContent = (res && res.data) ? String(res.data) : 'Check failed.';
|
||||
} else {
|
||||
statusText.textContent = res.data.message || 'Check complete.';
|
||||
if (res.data.status === 'available' && res.data.download_url) {
|
||||
setTimeout(function () { window.location.reload(); }, 400);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function () { statusText.textContent = 'Network error — try again in a moment.'; })
|
||||
.finally(function () {
|
||||
btn.disabled = false;
|
||||
btn.textContent = orig;
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
@@ -1,31 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Radio — a free SomaFM player for your WordPress dashboard
|
||||
* RangerHQ Radio — a small, focused internet radio player for your WP dashboard.
|
||||
*
|
||||
* Plugin Name: Radio
|
||||
* Plugin Name: RangerHQ Radio
|
||||
* Plugin URI: https://icanhelp.ie/radio
|
||||
* Description: A small, focused, free radio player for your WordPress admin. 44 SomaFM stations grouped by 10 genres — ambient, electronic, lounge, rock, metal, jazz, world, reggae, holiday, specials. Plays via HTML5 audio; volume + station choice persist per-user.
|
||||
* Version: 0.4.0
|
||||
* Requires at least: 5.0
|
||||
* Description: A small, focused internet radio player for your WordPress admin. 44 hand-curated stations from SomaFM across 10 genres — ambient, electronic, lounge, rock, metal, jazz, world, reggae, holiday, specials. Plays via HTML5 audio; per-user station + volume + history + favourites; pop-out window for continuous background play.
|
||||
* Version: 0.7.4
|
||||
* Requires at least: 5.3
|
||||
* Requires PHP: 7.4
|
||||
* Author: David Keane
|
||||
* Author URI: https://rangersmyth.xyz/
|
||||
* License: GPL v2 or later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Text Domain: radio
|
||||
* Text Domain: a-radio
|
||||
*
|
||||
* @package Radio
|
||||
* @package RangerHQ_Radio
|
||||
*
|
||||
* Copyright (C) 2026 David Keane
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version. See LICENSE for the full text.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
|
||||
// Plugin coordinates.
|
||||
if ( ! defined( 'RADIO_VERSION' ) ) { define( 'RADIO_VERSION', '0.4.0' ); }
|
||||
if ( ! defined( 'RADIO_VERSION' ) ) { define( 'RADIO_VERSION', '0.7.4' ); }
|
||||
if ( ! defined( 'RADIO_FILE' ) ) { define( 'RADIO_FILE', __FILE__ ); }
|
||||
if ( ! defined( 'RADIO_PATH' ) ) { define( 'RADIO_PATH', plugin_dir_path( __FILE__ ) ); }
|
||||
if ( ! defined( 'RADIO_URL' ) ) { define( 'RADIO_URL', plugin_dir_url( __FILE__ ) ); }
|
||||
if ( ! defined( 'RADIO_BASENAME' ) ) { define( 'RADIO_BASENAME', plugin_basename( __FILE__ ) ); }
|
||||
if ( ! defined( 'RADIO_GITEA_URL' ) ) { define( 'RADIO_GITEA_URL', 'https://git.davidtkeane.com/ranger/a-radio' ); }
|
||||
if ( ! defined( 'RADIO_SUPPORT_URL' ) ) { define( 'RADIO_SUPPORT_URL', 'https://buymeacoffee.com/davidtkeane' ); }
|
||||
|
||||
// Includes — each file owns one concern.
|
||||
require_once RADIO_PATH . 'inc/stations.php'; // the 44-station array + genre helpers
|
||||
@@ -34,7 +42,7 @@ require_once RADIO_PATH . 'inc/dashboard-widget.php'; // the compact mini-player
|
||||
require_once RADIO_PATH . 'inc/admin-page.php'; // dedicated Radio admin page (larger player)
|
||||
require_once RADIO_PATH . 'inc/about.php'; // About page
|
||||
require_once RADIO_PATH . 'inc/settings.php'; // Settings page
|
||||
require_once RADIO_PATH . 'inc/updater.php'; // self-hosted update checker against Gitea
|
||||
require_once RADIO_PATH . 'inc/history.php'; // Track history + favourites (v0.5.0)
|
||||
|
||||
/**
|
||||
* Admin menu registration. Radio gets its own top-level menu — having
|
||||
@@ -44,8 +52,8 @@ require_once RADIO_PATH . 'inc/updater.php'; // self-hosted update chec
|
||||
add_action( 'admin_menu', 'radio_register_admin_menu' );
|
||||
function radio_register_admin_menu() {
|
||||
add_menu_page(
|
||||
__( 'Radio', 'radio' ),
|
||||
__( 'Radio', 'radio' ),
|
||||
__( 'Radio', 'a-radio' ),
|
||||
__( 'Radio', 'a-radio' ),
|
||||
'read', // any logged-in user with read access has their own radio
|
||||
'radio',
|
||||
'radio_render_main_page',
|
||||
@@ -59,8 +67,8 @@ function radio_register_admin_menu() {
|
||||
// form gotcha).
|
||||
add_submenu_page(
|
||||
'radio',
|
||||
__( 'My Radio', 'radio' ),
|
||||
__( 'My Radio', 'radio' ),
|
||||
__( 'My Radio', 'a-radio' ),
|
||||
__( 'My Radio', 'a-radio' ),
|
||||
'read',
|
||||
'radio',
|
||||
''
|
||||
@@ -68,8 +76,8 @@ function radio_register_admin_menu() {
|
||||
|
||||
add_submenu_page(
|
||||
'radio',
|
||||
__( 'Settings', 'radio' ),
|
||||
__( 'Settings', 'radio' ),
|
||||
__( 'Settings', 'a-radio' ),
|
||||
__( 'Settings', 'a-radio' ),
|
||||
'manage_options',
|
||||
'radio-settings',
|
||||
'radio_render_settings_page'
|
||||
@@ -77,8 +85,17 @@ function radio_register_admin_menu() {
|
||||
|
||||
add_submenu_page(
|
||||
'radio',
|
||||
__( 'About', 'radio' ),
|
||||
__( 'About', 'radio' ),
|
||||
__( 'Track history', 'a-radio' ),
|
||||
__( 'History', 'a-radio' ),
|
||||
'read',
|
||||
'radio-history',
|
||||
'radio_render_history_page'
|
||||
);
|
||||
|
||||
add_submenu_page(
|
||||
'radio',
|
||||
__( 'About', 'a-radio' ),
|
||||
__( 'About', 'a-radio' ),
|
||||
'read',
|
||||
'radio-about',
|
||||
'radio_render_about_page'
|
||||
@@ -96,6 +113,7 @@ function radio_enqueue_admin_assets( $hook ) {
|
||||
'toplevel_page_radio', // Radio main page
|
||||
'radio_page_radio-settings', // Settings
|
||||
'radio_page_radio-about', // About
|
||||
'radio_page_radio-history', // History + Favourites (v0.5.0)
|
||||
);
|
||||
if ( ! in_array( $hook, $radio_hooks, true ) ) { return; }
|
||||
|
||||
@@ -120,17 +138,21 @@ function radio_enqueue_admin_assets( $hook ) {
|
||||
'stations' => radio_get_stations_flat(),
|
||||
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'radio_save_state' ),
|
||||
'popoutUrl' => admin_url( 'admin-post.php?action=radio_popout' ),
|
||||
'strings' => array(
|
||||
'play' => __( 'Play', 'radio' ),
|
||||
'pause' => __( 'Pause', 'radio' ),
|
||||
'loading' => __( 'Loading…', 'radio' ),
|
||||
'error' => __( 'Stream error — try another station.', 'radio' ),
|
||||
'saveError' => __( 'Preferences not saved — check your connection.', 'radio' ),
|
||||
'mute' => __( 'Mute', 'radio' ),
|
||||
'unmute' => __( 'Unmute', 'radio' ),
|
||||
'nowPlaying' => __( 'Now Playing', 'radio' ),
|
||||
'volume' => __( 'Volume', 'radio' ),
|
||||
'station' => __( 'Station', 'radio' ),
|
||||
'play' => __( 'Play', 'a-radio' ),
|
||||
'pause' => __( 'Pause', 'a-radio' ),
|
||||
'loading' => __( 'Loading…', 'a-radio' ),
|
||||
'error' => __( 'Stream error — try another station.', 'a-radio' ),
|
||||
'saveError' => __( 'Preferences not saved — check your connection.', 'a-radio' ),
|
||||
'mute' => __( 'Mute', 'a-radio' ),
|
||||
'unmute' => __( 'Unmute', 'a-radio' ),
|
||||
'nowPlaying' => __( 'Now Playing', 'a-radio' ),
|
||||
'volume' => __( 'Volume', 'a-radio' ),
|
||||
'station' => __( 'Station', 'a-radio' ),
|
||||
'addFav' => __( 'Add to favourites', 'a-radio' ),
|
||||
'removeFav' => __( 'Remove from favourites', 'a-radio' ),
|
||||
'clearConfirm' => __( 'Clear all track history? (Favourites are kept.)', 'a-radio' ),
|
||||
),
|
||||
) );
|
||||
}
|
||||
@@ -162,6 +184,180 @@ function radio_ajax_save_state() {
|
||||
wp_send_json_success( radio_get_state() );
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX: log a played track to the user's history (v0.5.0).
|
||||
* Nonce: same `radio_save_state` token used for state saves — both come
|
||||
* from the same `wp_localize_script` config available on player pages.
|
||||
*/
|
||||
add_action( 'wp_ajax_radio_log_track', 'radio_ajax_log_track' );
|
||||
function radio_ajax_log_track() {
|
||||
if ( ! is_user_logged_in() ) { wp_send_json_error( 'Not logged in.', 401 ); }
|
||||
check_ajax_referer( 'radio_save_state', 'nonce' );
|
||||
// Unslash + sanitize at access; radio_sanitize_entry() also re-sanitizes
|
||||
// downstream as belt+braces, but PCP wants the cleanup AT the access point.
|
||||
$logged = radio_log_track( array(
|
||||
'artist' => isset( $_POST['artist'] ) ? sanitize_text_field( wp_unslash( $_POST['artist'] ) ) : '',
|
||||
'title' => isset( $_POST['title'] ) ? sanitize_text_field( wp_unslash( $_POST['title'] ) ) : '',
|
||||
'station' => isset( $_POST['station'] ) ? sanitize_text_field( wp_unslash( $_POST['station'] ) ) : '',
|
||||
'station_id' => isset( $_POST['station_id'] ) ? sanitize_key( wp_unslash( $_POST['station_id'] ) ) : '',
|
||||
) );
|
||||
wp_send_json_success( array( 'logged' => (bool) $logged ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* AJAX: toggle whether a track is favourited.
|
||||
* Nonce: `radio_history` — created fresh per History-page render so the
|
||||
* AJAX is gated to users who actually loaded the page.
|
||||
*/
|
||||
add_action( 'wp_ajax_radio_toggle_favourite', 'radio_ajax_toggle_favourite' );
|
||||
function radio_ajax_toggle_favourite() {
|
||||
if ( ! is_user_logged_in() ) { wp_send_json_error( 'Not logged in.', 401 ); }
|
||||
check_ajax_referer( 'radio_history', 'nonce' );
|
||||
$new_state = radio_toggle_favourite( array(
|
||||
'artist' => isset( $_POST['artist'] ) ? sanitize_text_field( wp_unslash( $_POST['artist'] ) ) : '',
|
||||
'title' => isset( $_POST['title'] ) ? sanitize_text_field( wp_unslash( $_POST['title'] ) ) : '',
|
||||
'station' => isset( $_POST['station'] ) ? sanitize_text_field( wp_unslash( $_POST['station'] ) ) : '',
|
||||
'station_id' => isset( $_POST['station_id'] ) ? sanitize_key( wp_unslash( $_POST['station_id'] ) ) : '',
|
||||
) );
|
||||
wp_send_json_success( array( 'favourite' => (bool) $new_state ) );
|
||||
}
|
||||
|
||||
/** AJAX: clear the current user's history (favourites preserved). */
|
||||
add_action( 'wp_ajax_radio_clear_history', 'radio_ajax_clear_history' );
|
||||
function radio_ajax_clear_history() {
|
||||
if ( ! is_user_logged_in() ) { wp_send_json_error( 'Not logged in.', 401 ); }
|
||||
check_ajax_referer( 'radio_history', 'nonce' );
|
||||
radio_clear_history_all();
|
||||
wp_send_json_success();
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.6.0 — Pop-out mini player. Renders a standalone HTML page (no WP
|
||||
* admin chrome) at `admin-post.php?action=radio_popout`, opened by the
|
||||
* JS via `window.open()`. The popup persists across main-tab navigation
|
||||
* so background music keeps playing when the user moves around the
|
||||
* admin. `&play=1` in the URL tells `radio.js` to auto-resume on load.
|
||||
*/
|
||||
add_action( 'admin_post_radio_popout', 'radio_render_popout_page' );
|
||||
function radio_render_popout_page() {
|
||||
if ( ! current_user_can( 'read' ) ) {
|
||||
wp_die( esc_html__( 'You do not have permission to view this page.', 'a-radio' ) );
|
||||
}
|
||||
|
||||
$state = radio_get_state();
|
||||
$station = radio_find_station( $state['station_id'] );
|
||||
$stations = radio_get_stations_grouped();
|
||||
$theme = isset( $state['theme'] ) ? $state['theme'] : 'auto';
|
||||
if ( ! in_array( $theme, array( 'auto', 'light', 'dark' ), true ) ) { $theme = 'auto'; }
|
||||
|
||||
$cfg = array(
|
||||
'state' => $state,
|
||||
'stations' => radio_get_stations_flat(),
|
||||
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
||||
'nonce' => wp_create_nonce( 'radio_save_state' ),
|
||||
'popoutUrl' => '', // already in popout — no further popouts
|
||||
'autoPlay' => isset( $_GET['play'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- query flag only, no state change
|
||||
'strings' => array(
|
||||
'play' => __( 'Play', 'a-radio' ),
|
||||
'pause' => __( 'Pause', 'a-radio' ),
|
||||
'loading' => __( 'Loading…', 'a-radio' ),
|
||||
'error' => __( 'Stream error — try another station.', 'a-radio' ),
|
||||
'saveError' => __( 'Preferences not saved — check your connection.', 'a-radio' ),
|
||||
'mute' => __( 'Mute', 'a-radio' ),
|
||||
'unmute' => __( 'Unmute', 'a-radio' ),
|
||||
'nowPlaying' => __( 'Now Playing', 'a-radio' ),
|
||||
'volume' => __( 'Volume', 'a-radio' ),
|
||||
'station' => __( 'Station', 'a-radio' ),
|
||||
),
|
||||
);
|
||||
|
||||
/*
|
||||
* v0.7.0: Enqueue popup assets via WP so we can emit them with
|
||||
* wp_print_styles() / wp_print_footer_scripts() — passes PCP's
|
||||
* NonEnqueuedStylesheet / NonEnqueuedScript checks (we used raw
|
||||
* <link> / <script> tags before). dashicons is core-registered.
|
||||
*/
|
||||
wp_enqueue_style( 'dashicons' );
|
||||
wp_enqueue_style( 'radio-admin', RADIO_URL . 'assets/css/radio.css', array(), RADIO_VERSION );
|
||||
wp_enqueue_script( 'radio-admin', RADIO_URL . 'assets/js/radio.js', array(), RADIO_VERSION, true );
|
||||
wp_localize_script( 'radio-admin', 'RadioPlugin', $cfg );
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?php echo esc_attr( str_replace( '_', '-', get_bloginfo( 'language' ) ) ); ?>">
|
||||
<head>
|
||||
<meta charset="<?php bloginfo( 'charset' ); ?>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><?php
|
||||
/* translators: %s = currently playing station name */
|
||||
printf( esc_html__( 'Radio — %s', 'a-radio' ), esc_html( $station['name'] ) );
|
||||
?></title>
|
||||
<?php wp_print_styles(); /* dashicons + radio.css; popup-specific overrides scoped under body.radio-popout in radio.css */ ?>
|
||||
</head>
|
||||
<body class="radio-popout radio-theme-<?php echo esc_attr( $theme ); ?>">
|
||||
|
||||
<div class="radio-popout-header">
|
||||
<h1><?php esc_html_e( 'Radio', 'a-radio' ); ?></h1>
|
||||
<button type="button" class="radio-popout-close" onclick="window.close()" title="<?php esc_attr_e( 'Close', 'a-radio' ); ?>">✕</button>
|
||||
</div>
|
||||
|
||||
<div class="radio-popout-wrap">
|
||||
<div class="radio-player" data-radio-surface="popout">
|
||||
|
||||
<div class="radio-player__now">
|
||||
<span class="radio-player__indicator" aria-hidden="true">
|
||||
<span class="radio-player__bars"><span></span><span></span><span></span><span></span></span>
|
||||
<canvas class="radio-player__viz" data-radio-viz hidden></canvas>
|
||||
</span>
|
||||
<span class="radio-player__label"><?php esc_html_e( 'Now Playing', 'a-radio' ); ?></span>
|
||||
<span class="radio-player__station-name" data-radio-name><?php echo esc_html( $station['name'] ); ?></span>
|
||||
<span class="radio-player__station-genre" data-radio-genre><?php echo esc_html( $station['genre'] ); ?></span>
|
||||
<p class="radio-player__station-desc" data-radio-desc><?php echo esc_html( $station['description'] ); ?></p>
|
||||
<p class="radio-player__track" data-radio-track hidden></p>
|
||||
</div>
|
||||
|
||||
<div class="radio-player__controls">
|
||||
<button type="button" class="button button-primary radio-player__play" data-radio-play>
|
||||
<span class="radio-player__play-glyph" data-radio-play-glyph aria-hidden="true">▶</span>
|
||||
<span data-radio-play-label><?php esc_html_e( 'Play', 'a-radio' ); ?></span>
|
||||
</button>
|
||||
<div class="radio-player__volume">
|
||||
<button type="button" class="radio-player__mute" data-radio-mute aria-label="<?php esc_attr_e( 'Mute', 'a-radio' ); ?>">
|
||||
<span class="dashicons dashicons-controls-volumeon" aria-hidden="true"></span>
|
||||
</button>
|
||||
<input type="range" min="0" max="100" value="<?php echo esc_attr( (int) round( $state['volume'] * 100 ) ); ?>" data-radio-volume aria-label="<?php esc_attr_e( 'Volume', 'a-radio' ); ?>">
|
||||
<span class="radio-player__volume-pct" data-radio-volume-pct><?php echo esc_html( (int) round( $state['volume'] * 100 ) ); ?>%</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="radio-player__station-select">
|
||||
<label for="radio-station-popout"><?php esc_html_e( 'Station', 'a-radio' ); ?></label>
|
||||
<select id="radio-station-popout" data-radio-station>
|
||||
<?php foreach ( $stations as $genre => $entries ) :
|
||||
if ( empty( $entries ) ) { continue; }
|
||||
?>
|
||||
<optgroup label="<?php echo esc_attr( $genre ); ?>">
|
||||
<?php foreach ( $entries as $entry ) : ?>
|
||||
<option value="<?php echo esc_attr( $entry['id'] ); ?>" data-url="<?php echo esc_attr( $entry['url'] ); ?>" data-desc="<?php echo esc_attr( $entry['description'] ); ?>" data-genre="<?php echo esc_attr( $entry['genre'] ); ?>" <?php selected( $entry['id'], $state['station_id'] ); ?>>
|
||||
<?php echo esc_html( $entry['name'] ); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</optgroup>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="radio-player__error" data-radio-error hidden></div>
|
||||
<audio data-radio-audio preload="none" crossorigin="anonymous"></audio>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php wp_print_footer_scripts(); /* radio.js + the wp_localize_script-emitted window.RadioPlugin inline blob */ ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Surface the user's theme choice (auto/light/dark) to CSS as a body
|
||||
* class. `radio-theme-dark` forces dark; `radio-theme-auto` lets the
|
||||
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
=== RangerHQ Radio ===
|
||||
Contributors: ir240474
|
||||
Donate link: https://buymeacoffee.com/davidtkeane
|
||||
Tags: radio, music, audio, internet radio, background music
|
||||
Requires at least: 5.3
|
||||
Tested up to: 7.0
|
||||
Stable tag: 0.7.4
|
||||
Requires PHP: 7.4
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
A small, focused internet radio player for your WordPress admin — 44 hand-curated stations, history, favourites, and a pop-out window.
|
||||
|
||||
== Description ==
|
||||
|
||||
**RangerHQ Radio** adds a tiny, focused internet radio player to your WordPress dashboard so you can have background music while you work in the admin — without leaving the page, opening Spotify, or installing a desktop client.
|
||||
|
||||
= What you get =
|
||||
|
||||
* **44 hand-curated stations from [SomaFM](https://somafm.com)** across 10 genres — ambient, electronic, lounge, rock, metal, jazz, world, reggae, holiday and specials. From coding-focus ambient (Groove Salad, Drone Zone) to drive-time electronic (DEF CON Radio, Beat Blender) to mellow lounge (Lush, Secret Agent).
|
||||
* **Now-playing indicator** — small CSS dancing-bars equalizer that pulses while audio is playing. A Web Audio frequency visualizer kicks in automatically when the browser allows it (with a graceful fallback to the CSS bars).
|
||||
* **Track history + favourites** — every track that scrolls past is logged to your personal History page (capped at 500); a star toggle promotes the good ones to a separate Favourites tab that doesn't age out. Each row has four search links (Spotify, YouTube, Apple Music, Bandcamp) so you can find that track on whichever service you use.
|
||||
* **Pop-out mini-player** — a 380×560 standalone window that persists across the main tab's navigation, so background music doesn't cut when you move between Plugins, Posts, Users, etc.
|
||||
* **OS media keys** — F8/headphone buttons/lock-screen widget play and pause the radio (via MediaSession API).
|
||||
* **Mute toggle** — the speaker icon is clickable; remembers prior volume.
|
||||
* **Dark theme** — explicit dark option for the player surface (`Settings → Theme`).
|
||||
* **Per-user state** — your chosen station, volume, theme, history, and favourites all live in `user_meta`, so each WordPress user has their own setup.
|
||||
|
||||
= Third-party service =
|
||||
|
||||
This plugin streams audio from **[SomaFM](https://somafm.com)** — an independent, listener-supported, commercial-free internet radio network broadcasting from San Francisco since 2000. RangerHQ Radio is a small WordPress wrapper around their public streams; the service itself provides all the music. SomaFM's terms of use are at [somafm.com/legal/](https://somafm.com/legal/). If you enjoy the music, please consider [supporting SomaFM directly](https://somafm.com/support/).
|
||||
|
||||
See the dedicated Privacy section below for everything that does and does not leave your site.
|
||||
|
||||
== Privacy ==
|
||||
|
||||
RangerHQ Radio is privacy-respecting by design:
|
||||
|
||||
* **No telemetry from the plugin.** RangerHQ Radio does not phone home, report usage statistics, or contact the plugin author's servers in any way.
|
||||
* **No data leaves your site.** All per-user state — station choice, volume, theme, listening history, favourites — is stored in your own WordPress database (`wp_usermeta`) and never transmitted anywhere.
|
||||
* **Audio streams come from SomaFM directly.** When you press Play, your browser opens an HTTP stream to `https://somafm.com` — the plugin does not proxy, log, or analyse this connection. SomaFM's own privacy practices apply to the stream; see [SomaFM legal](https://somafm.com/legal/).
|
||||
* **Current-track display** polls SomaFM's public songs endpoint (`https://somafm.com/songs/{station}.json`) every 30 seconds **while audio is playing**. The plugin sends no identifying information with this request. Polling stops the moment you pause.
|
||||
* **Search-provider links** (Spotify / YouTube / Apple Music / Bandcamp) are outbound only. Clicking one opens a new tab with a search URL on that service — the plugin sends no data and stores no information about which links you click.
|
||||
* **No third-party JavaScript** is loaded from outside your own server. All scripts ship inside the plugin.
|
||||
* **Updates** come from WordPress.org through the normal WordPress core update process. The plugin does not contact any other update server.
|
||||
|
||||
If you do not want any third-party traffic at all, simply do not press Play.
|
||||
|
||||
== Installation ==
|
||||
|
||||
1. Upload the plugin folder to `/wp-content/plugins/` (or install from the WordPress plugin directory).
|
||||
2. Activate the plugin through the **Plugins** menu in WordPress.
|
||||
3. Open **Radio → My Radio** in the admin sidebar and press Play. Your station and volume choice are saved per user.
|
||||
|
||||
There is no separate configuration step — defaults are sensible (Groove Salad at 60% volume). Settings are at **Radio → Settings**.
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= Does this work on the front-end of my site? =
|
||||
|
||||
No — RangerHQ Radio is admin-only. It adds a player to the WordPress dashboard for you (and your other authenticated admins) to use while working. It does not embed a radio player on the public-facing site.
|
||||
|
||||
= Can I add my own stations? =
|
||||
|
||||
Not via the admin yet. The station list is hard-coded in `inc/stations.php` (44 SomaFM stations). If you'd like to add custom stations or other internet radio sources, please open an issue on the [Gitea repo](https://git.davidtkeane.com/ranger/a-radio).
|
||||
|
||||
= The pop-out window doesn't open. =
|
||||
|
||||
Your browser may be blocking pop-ups. Click the address bar's pop-up icon to allow pop-ups for this site, then try again.
|
||||
|
||||
= Why does Touch ID / a passkey prompt appear when I press Play? =
|
||||
|
||||
It shouldn't. This plugin uses no biometrics or authentication of its own — that's a different plugin in the RangerHQ family.
|
||||
|
||||
= The current-track display says nothing / is hidden. =
|
||||
|
||||
SomaFM's track-info endpoint (`somafm.com/songs/{station}.json`) is fetched best-effort. If it's unreachable or the browser blocks the request, the track display silently hides. The player keeps working regardless.
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Dashboard widget — compact mini-player on the WordPress Dashboard, sits alongside your usual dashboard widgets.
|
||||
2. Settings page — choose default station, default volume, theme; admin-only Updates panel below.
|
||||
3. Track History page — every track that scrolled past, star-to-favourite, with Spotify / YouTube / Apple / Bandcamp deep-link search per row.
|
||||
4. Pop-out mini-player window — 380×560 standalone window that keeps playing while you navigate the rest of the admin.
|
||||
5. About page — what Radio does, who it's for, credits, full version history.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 0.7.4 =
|
||||
* WordPress.org submission cleanup. Removed the self-hosted Gitea updater (`inc/updater.php`) and the `Update URI` header from `radio.php`. WordPress.org explicitly disallows both for hosted plugins (Plugin Check `plugin_updater_detected`), so updates now flow through WordPress.org as the canonical channel. Added a top-level `LICENSE` file with the full GPL v2 text and explicit GPL header blocks to `assets/css/radio.css` and `assets/js/radio.js` so the licensing of every shipped file is unambiguous. The small `Updates` panel that used to sit at the bottom of Radio → Settings is gone; player behaviour is unchanged.
|
||||
|
||||
= 0.7.3 =
|
||||
* WordPress.org guideline 8 compliance + Privacy documentation. Added `Update URI: https://git.davidtkeane.com/ranger/a-radio` header so installs from the author's Gitea continue to receive updates from there, while wp.org-distributed copies (where the build script strips this line) hand update delivery to WordPress.org — the self-hosted updater short-circuits at load time and the Updates panel hides automatically. Added a dedicated `== Privacy ==` section to the readme covering every outbound connection (none from the plugin itself; SomaFM audio + 30-second songs.json poll while playing). Added explicit link to SomaFM's terms of use at https://somafm.com/legal/. No user-visible behaviour changes.
|
||||
|
||||
= 0.7.2 =
|
||||
* Screenshots + correct wp.org contributor handle. Five `screenshot-N.png` files added at plugin root (Dashboard widget, Settings page, History page, Pop-out window, About page). `Contributors` header updated from placeholder to actual wp.org username `ir240474`.
|
||||
|
||||
= 0.7.1 =
|
||||
* Plugin Check follow-up — `Tested up to` bumped from 6.7 to 7.0 (PCP `outdated_tested_upto_header`). Stray `.DS_Store` files re-deleted (macOS Finder regenerated them between PCP runs; they won't be in the submission zip).
|
||||
|
||||
= 0.7.0 =
|
||||
* WordPress.org submission prep — full PCP-clean. Plugin name normalised to **RangerHQ Radio** (SomaFM stays in the description as the data source). Text Domain renamed `radio` → `a-radio` everywhere (134 i18n call sites updated). Six `printf` / `sprintf` calls now carry translator comments. All admin `$_POST` access now `wp_unslash()` + `sanitize_*` at the access point. `Requires at least` bumped to 5.3 (matches `wp_date()` usage). Pop-out window now uses `wp_enqueue_*` + `wp_print_styles()` / `wp_print_footer_scripts()` instead of raw `<link>` / `<script>` tags; popup-specific CSS moved into `radio.css` under `body.radio-popout` scope. `.DS_Store` files removed. Proper `readme.txt`.
|
||||
|
||||
= 0.6.3 =
|
||||
* Discreet "buy me a coffee" support link in the Updates panel and the About-page Credits card. Single `RADIO_SUPPORT_URL` constant; conditional render — silently hidden if the constant is empty.
|
||||
|
||||
= 0.6.2 =
|
||||
* Current version badge on the Settings page — small grey pill follows the H1 reading `v{RADIO_VERSION}`.
|
||||
|
||||
= 0.6.1 =
|
||||
* About page restructure — 3-card top row (What / Who / Credits) + full-width Version history with the latest expanded and earlier releases as one-liners.
|
||||
|
||||
= 0.6.0 =
|
||||
* Pop-out mini-player. `↗ Pop out` button beside Play opens a 380×560 standalone window that persists across the main tab's navigation, so background music keeps playing while you click around Plugins / Posts / Users.
|
||||
|
||||
= 0.5.0 =
|
||||
* Track history + favourites. Every track that scrolls past is logged to a per-user `Radio → History` page (capped at 500). Star toggle promotes tracks to a separate Favourites tab. Four search-provider links per row (Spotify, YouTube, Apple Music, Bandcamp).
|
||||
|
||||
= 0.4.0 =
|
||||
* Now-playing visual indicator. CSS dancing-bars equalizer that pulses while audio is playing. Web Audio frequency visualizer kicks in when the browser allows it (with graceful fallback).
|
||||
|
||||
= 0.3.0 =
|
||||
* Dark theme, mute toggle on the speaker icon, MediaSession API (OS media keys), SomaFM current-track polling under the station description.
|
||||
|
||||
= 0.2.0 =
|
||||
* UI rebuilt to WordPress admin standards — postbox container, native play/pause button with text label, picks up the user's admin colour scheme via `var(--wp-admin-theme-color)`.
|
||||
|
||||
= 0.1.0 =
|
||||
* First release — 44 SomaFM stations across 10 genres, dashboard widget + dedicated admin page, per-user state, self-hosted Gitea updater.
|
||||
|
||||
== Upgrade Notice ==
|
||||
|
||||
= 0.7.4 =
|
||||
WordPress.org submission cleanup — removes the disallowed self-hosted updater + `Update URI` header. Adds LICENSE file + per-asset GPL headers. The `Updates` panel in Settings is gone (WordPress.org handles updates now). No player behaviour changes.
|
||||
|
||||
= 0.7.3 =
|
||||
WordPress.org submission compliance — adds `Update URI` header so the self-hosted updater stays dormant on wp.org installs (guideline 8). Adds Privacy section + SomaFM terms link. No user-visible changes.
|
||||
|
||||
= 0.7.2 =
|
||||
Screenshots + correct wp.org contributor handle. No user-visible changes.
|
||||
|
||||
= 0.7.1 =
|
||||
PCP follow-up — `Tested up to` bumped to 7.0. No user-visible changes.
|
||||
|
||||
= 0.7.0 =
|
||||
WordPress.org submission prep. Plugin name now "RangerHQ Radio". Text Domain renamed `radio` → `a-radio`. No user-visible behaviour changes; settings, history, and favourites all survive the upgrade.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 97 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 268 KiB |
Reference in New Issue
Block a user