340cbb2487
A third-party AI-driven naming check flagged `a-radio` as too generic for the wp.org Plugin Directory (single common functional word, no distinguishing prefix). The verdict was advisory but defensible — short generic slugs are increasingly rejected as the directory grows past 60K plugins. Fixing it preemptively is cheaper than facing a rejection at submission time. The new slug `rangerhq-radio` matches the public display name "RangerHQ Radio" (unchanged) and lines up with the rest of the RangerHQ plugin family: `rangerhq-spatial`, `rangerhq-glyph`, now `rangerhq-radio`. Changes (packaging only — no player behaviour change): * Text Domain `a-radio` → `rangerhq-radio` across all 125 i18n call sites via in-place sed (esc_html__, _e, __, esc_attr_e and their friends). PHP lint clean post-rename. * `Text Domain:` plugin header in radio.php line 15 → `rangerhq-radio`. * `RADIO_GITEA_URL` constant value → new Gitea repo URL. * README.md install link → new repo URL. * readme.txt FAQ Gitea link → new repo URL. * readme.txt Stable tag → 0.7.5. * inc/about.php — v0.7.5 in "latest" slot; v0.7.4 demoted. Unchanged deliberately (would have been pure churn): * Plugin Name header "RangerHQ Radio" — already correct. * Plugin URI. * Internal constants `RADIO_*` — don't have to match slug. * User-meta keys `radio_state` / `radio_history` / `radio_favourites` — renaming would orphan every existing user's settings on upgrade. * HTML `data-radio-*` attributes — JS controller's element selectors in radio.js, not slug-related. * CSS class names `radio-player`, `radio-about-*` — internal scoping. * Main plugin file name `radio.php`. Migration: existing Gitea-installed copies need their folder renamed on disk (a-radio → rangerhq-radio) + reactivation in WP admin. No data loss because all user-facing state lives in user_meta under unchanged keys. This commit is the file content for v0.7.5; the annotated tag and push will follow the Gitea repo rename (ranger/a-radio → ranger/rangerhq-radio) so the new tag lives in the new URL space from the start.
113 lines
6.2 KiB
PHP
113 lines
6.2 KiB
PHP
<?php
|
|
/**
|
|
* Radio — main admin page (WP Admin → Radio → My Radio).
|
|
*
|
|
* Uses WP-native postbox structure so the player feels like part of
|
|
* WordPress, not a third-party widget. The dashboard widget shares
|
|
* the same internal markup via assets/js/radio.js binding to every
|
|
* .radio-player on the page.
|
|
*/
|
|
|
|
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.', 'rangerhq-radio' ) );
|
|
}
|
|
|
|
$state = radio_get_state();
|
|
$station = radio_find_station( $state['station_id'] );
|
|
$stations = radio_get_stations_grouped();
|
|
$count = count( radio_get_stations_flat() );
|
|
?>
|
|
<div class="wrap radio-wrap">
|
|
<h1><?php esc_html_e( 'Radio', 'rangerhq-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.', 'rangerhq-radio' ),
|
|
(int) $count
|
|
);
|
|
?>
|
|
</p>
|
|
|
|
<div class="postbox">
|
|
<div class="postbox-header">
|
|
<h2 class="hndle"><?php esc_html_e( 'Player', 'rangerhq-radio' ); ?></h2>
|
|
</div>
|
|
<div class="inside">
|
|
<div class="radio-player" data-radio-surface="main">
|
|
|
|
<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', 'rangerhq-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', 'rangerhq-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', 'rangerhq-radio' ); ?>">
|
|
<span aria-hidden="true">↗</span> <?php esc_html_e( 'Pop out', 'rangerhq-radio' ); ?>
|
|
</button>
|
|
|
|
<div class="radio-player__volume">
|
|
<button type="button" class="radio-player__mute" data-radio-mute aria-label="<?php esc_attr_e( 'Mute', 'rangerhq-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', 'rangerhq-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', 'rangerhq-radio' ); ?></label>
|
|
<select id="radio-station-main" 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>
|
|
</div>
|
|
|
|
<p class="radio-player__credit radio-player__credit--main description">
|
|
<?php
|
|
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.', 'rangerhq-radio' ),
|
|
array( 'a' => array( 'href' => true, 'target' => true, 'rel' => true ) )
|
|
),
|
|
'<a href="https://somafm.com/" target="_blank" rel="noopener">SomaFM</a>'
|
|
);
|
|
?>
|
|
</p>
|
|
</div>
|
|
<?php
|
|
}
|