From 9f392b5af565d5e4cd75a5bdce4513cdf50d068e Mon Sep 17 00:00:00 2001 From: Ray Tiley Date: Fri, 2 Jan 2026 20:03:29 -0500 Subject: [PATCH 1/6] Fix 6 bugs from tester feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG-1: Timezone 8-hours-ahead issue - Add run_timestamp to schedule data for timezone-safe comparisons instead of using strtotime() on already converted time strings BUG-2: Weekly Guide channel switcher - Remove inline onchange handler, let JavaScript handle URL building properly with URL API BUG-3: Settings checkbox won't disable - Add sanitization callback to explicitly handle unchecked checkboxes BUG-4: Cablecast Home channel buttons - Add JavaScript click handlers and URL parameter support for channel tabs BUG-5: Categories grid breaks with long names - Add CSS overflow handling with word-break and hyphens BUG-6: Cablecast Home browse links - Fix undefined $shows_archive variable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- assets/css/shortcodes.css | 6 +++++ assets/js/shortcodes.js | 21 ++++++++++++++++ includes/settings.php | 43 ++++++++++++++++++++++++++++--- includes/shortcodes.php | 53 ++++++++++++++++++++++++++------------- theme-functions.php | 2 ++ 5 files changed, 104 insertions(+), 21 deletions(-) diff --git a/assets/css/shortcodes.css b/assets/css/shortcodes.css index 9759220..cafa0f8 100644 --- a/assets/css/shortcodes.css +++ b/assets/css/shortcodes.css @@ -671,6 +671,8 @@ a.cablecast-shows__title:hover { border-radius: 0.375rem; padding: 0.75rem 1rem; border-left: 3px solid #e5e7eb; + min-width: 0; + overflow: hidden; } .cablecast-categories__color { @@ -682,6 +684,10 @@ a.cablecast-shows__title:hover { .cablecast-categories__name { flex: 1; + min-width: 0; + overflow-wrap: break-word; + word-break: break-word; + hyphens: auto; } .cablecast-categories__count { diff --git a/assets/js/shortcodes.js b/assets/js/shortcodes.js index ea93d42..8f89433 100644 --- a/assets/js/shortcodes.js +++ b/assets/js/shortcodes.js @@ -13,6 +13,7 @@ document.addEventListener('DOMContentLoaded', function() { initWeeklyGuide(); initNowPlayingProgress(); + initCablecastHome(); }); /** @@ -87,4 +88,24 @@ }, 30000); } + /** + * Initialize Cablecast Home functionality. + */ + function initCablecastHome() { + var homeContainers = document.querySelectorAll('.cablecast-home'); + + homeContainers.forEach(function(container) { + var tabs = container.querySelectorAll('.cablecast-home__channel-tab'); + + tabs.forEach(function(tab) { + tab.addEventListener('click', function() { + var channelId = this.dataset.channel; + var url = new URL(window.location.href); + url.searchParams.set('channel', channelId); + window.location.href = url.toString(); + }); + }); + }); + } + })(); diff --git a/includes/settings.php b/includes/settings.php index 8873bd5..17e3323 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -107,13 +107,49 @@ function cablecast_get_custom_taxonomies() { return $custom_taxonomies; } +/** + * Sanitize the cablecast options. + * Ensures checkbox fields are properly saved as false when unchecked. + */ +function cablecast_sanitize_options($input) { + $current_options = get_option('cablecast_options', []); + + // Define checkbox fields that need explicit false handling + $checkbox_fields = [ + 'shortcode_styles', + 'delete_local_thumbnails', + 'enable_category_colors', + ]; + + // If input is not an array, return current options + if (!is_array($input)) { + return $current_options; + } + + // Merge with current options + $output = array_merge($current_options, $input); + + // Handle checkbox fields - if not present in input, set to false + foreach ($checkbox_fields as $field) { + if (!isset($input[$field])) { + $output[$field] = false; + } else { + $output[$field] = (bool) $input[$field]; + } + } + + return $output; +} + /** * custom option and settings */ function cablecast_settings_init() { - // register a new setting for "cablecast" page - register_setting('cablecast', 'cablecast_options'); + // register a new setting for "cablecast" page with sanitization callback + register_setting('cablecast', 'cablecast_options', [ + 'sanitize_callback' => 'cablecast_sanitize_options', + ]); // register a new section in the "cablecast" page add_settings_section( @@ -579,7 +615,8 @@ function cablecast_section_shortcodes_cb($args) function cablecast_field_shortcode_styles_cb($args) { $options = get_option('cablecast_options'); - $styles_enabled = !isset($options['shortcode_styles']) || $options['shortcode_styles']; + // Default to true if never saved, otherwise use the saved value + $styles_enabled = !isset($options['shortcode_styles']) ? true : (bool) $options['shortcode_styles']; ?>