Files
rangerhq-radio/inc/settings.php
T
ranger de93aa50ca v0.7.4 — wp.org submission cleanup: remove updater + add LICENSE
Walks back v0.7.3's Update URI guard pattern. Plugin Check raised
`plugin_updater_detected` on the v0.7.3 build:

    "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 v0.7.3
build-time `sed` strip never had a chance to run before the scan.
The simpler correct answer is to delete the custom updater entirely
and rely on wp.org as the canonical update channel once accepted.

Removed:
* `inc/updater.php` — recoverable from git history at tag v0.7.3 if
  ever needed for a non-wp.org distribution.
* `Update URI:` header line in `radio.php` (plus the NOTE block).
* `require_once RADIO_PATH . 'inc/updater.php';` in `radio.php`.
* Updates panel render + `function_exists()` guard in `inc/settings.php`.
* "Self-hosted update checker" line in `README.md`.
* "Self-hosted updater" bullet in `readme.txt` Privacy section.

Added (GPL declaration loop closed):
* `LICENSE` — verbatim canonical GPL v2 text (338 lines from
  gnu.org/licenses/gpl-2.0.txt).
* GPL header block in `assets/css/radio.css`.
* GPL header block in `assets/js/radio.js` (original module overview
  preserved verbatim below the license header).
* GPL header block in `radio.php` docblock alongside the existing
  `License:` / `License URI:` fields.

Migration: existing Gitea-installed copies of v0.7.3 or earlier
become orphaned of auto-updates after this lands on them (the
updater code is gone, so nothing advertises newer versions back).
Recommended path is to uninstall + reinstall from wp.org once the
plugin is accepted. No data loss — station + volume + theme +
history + favourites all live in user_meta.

No user-visible behaviour changes for the player itself. Only the
small `Updates` panel that sat at the bottom of Radio → Settings
is gone.
2026-05-30 04:43:16 +01:00

126 lines
5.7 KiB
PHP

<?php
/**
* Radio — Settings page.
*
* Lets the user pick default station + volume + theme + dashboard
* 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.', 'a-radio' ) );
}
// Handle form submission.
if ( isset( $_POST['radio_settings_submit'] )
&& check_admin_referer( 'radio_save_settings', 'radio_settings_nonce' ) ) {
$patch = array();
if ( isset( $_POST['default_station'] ) ) {
$patch['station_id'] = sanitize_key( wp_unslash( $_POST['default_station'] ) );
}
if ( isset( $_POST['default_volume'] ) ) {
$patch['volume'] = max( 0.0, min( 1.0, ( (float) $_POST['default_volume'] ) / 100.0 ) );
}
if ( isset( $_POST['theme'] ) ) {
$patch['theme'] = sanitize_key( wp_unslash( $_POST['theme'] ) );
}
radio_update_state( $patch );
// Dashboard-widget opt-out is stored in state too (extra key).
$hide_widget = ! empty( $_POST['hide_dashboard_widget'] );
$user_id = get_current_user_id();
$state = radio_get_state( $user_id );
$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.', 'a-radio' ) . '</p></div>';
}
$state = radio_get_state();
$stations = radio_get_stations_grouped();
$hide_widget = ! empty( $state['hide_dashboard_widget'] );
?>
<div class="wrap radio-settings-wrap">
<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' ); ?>
<table class="form-table" role="presentation">
<tr>
<th scope="row">
<label for="default_station"><?php esc_html_e( 'Default station', 'a-radio' ); ?></label>
</th>
<td>
<select id="default_station" name="default_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'] ); ?>" <?php selected( $entry['id'], $state['station_id'] ); ?>>
<?php echo esc_html( $entry['name'] ); ?>
</option>
<?php endforeach; ?>
</optgroup>
<?php endforeach; ?>
</select>
<p class="description">
<?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', '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">
<span id="default_volume_label"><?php echo esc_html( (int) round( $state['volume'] * 100 ) ); ?>%</span>
</td>
</tr>
<tr>
<th scope="row">
<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)', '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', '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', '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).', 'a-radio' ); ?>
</p>
</td>
</tr>
</table>
<?php submit_button( __( 'Save Changes', 'a-radio' ), 'primary', 'radio_settings_submit' ); ?>
</form>
</div>
<?php
}