From f06db67e594286cede4e6e8bcfdbe4c47cf1516a Mon Sep 17 00:00:00 2001 From: Danny Gershman Date: Thu, 16 Jul 2026 20:22:43 -0400 Subject: [PATCH] Fix specialty keytags showing by default when setting is off (#24) The settings UI and frontend disagreed on the default for 'Show Special Keytags': - DEFAULT_SHOW_SPECIAL was the string 'true', so on any install where the settings form was never saved, get_option('nacc_special', self::DEFAULT_SHOW_SPECIAL) fell back to 'true' and specialty tags rendered. - register_settings() registered nacc_special without a 'default', so draw_settings() rendered the checkbox unchecked. Result: the box showed off while the frontend behaved as on. Fixes: - Set DEFAULT_SHOW_SPECIAL to boolean false and register 'default' => false on nacc_special so both code paths agree. - Normalize the value handed to the JS constructor to a real JSON boolean via wp_json_encode( (bool) $args['special'] ), removing the stringified '0'/'true' truthiness trap on the JS side. Bumps plugin version to 6.0.2 and adds a readme.txt changelog entry (shared with #25/#26). Closes #24 Crow-Session: ED282F8A-4220-4B42-8842-460C56B4C61E Co-Authored-By: Claude --- nacc-wordpress-plugin.php | 7 ++++--- readme.txt | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/nacc-wordpress-plugin.php b/nacc-wordpress-plugin.php index 2648118..f5cb440 100644 --- a/nacc-wordpress-plugin.php +++ b/nacc-wordpress-plugin.php @@ -6,7 +6,7 @@ * Install: Drop this directory in the "wp-content/plugins/" directory and activate it. You need to specify "[NACC]" in the code section of a page or a post. * Contributors: BMLTGuy, pjaudiomv, bmltenabled * Authors: bmltenabled - * Version: 6.0.1 + * Version: 6.0.2 * Requires PHP: 8.0 * Requires at least: 5.3 * License: GPL v2 or later @@ -29,7 +29,7 @@ class NACC { private const DEFAULT_THEME = 'NACC-Instance'; private const DEFAULT_LANGUAGE = 'en'; private const DEFAULT_LAYOUT = 'linear'; - private const DEFAULT_SHOW_SPECIAL = 'true'; + private const DEFAULT_SHOW_SPECIAL = false; private $plugin_dir; /** @@ -140,7 +140,7 @@ private static function render_keytags( array $args ): void { wp_json_encode( esc_attr( $args['theme'] ) ), wp_json_encode( esc_attr( $args['language'] ) ), wp_json_encode( esc_attr( $args['layout'] ) ), - wp_json_encode( esc_attr( $args['special'] ) ), + wp_json_encode( (bool) $args['special'] ), wp_json_encode( esc_attr( $args['siteURI'] ) ) ) ); @@ -316,6 +316,7 @@ public static function register_settings(): void { 'nacc_special', [ 'type' => 'boolean', + 'default' => self::DEFAULT_SHOW_SPECIAL, 'sanitize_callback' => 'wp_validate_boolean', ] ); diff --git a/readme.txt b/readme.txt index 336afd4..26b23b2 100644 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Plugin URI: https://wordpress.org/plugins/nacc-wordpress-plugin/ Tags: na, cleantime calculator, nacc, recovery, addiction Requires PHP: 8.0 Tested up to: 7.0 -Stable tag: 6.0.1 +Stable tag: 6.0.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -30,6 +30,10 @@ That text will be replaced with this cleantime calculator. == Changelog == += 6.0.2 = + +* Fixed the "Show Special Keytags" default so that specialty (over 2 years) tags stay hidden until the setting is explicitly enabled, matching the unchecked checkbox and "Default is false." label. + = 6.0.1 = * Added a "Lantern" theme matching the Lantern WordPress theme (warm parchment paper, deep ink navy, terracotta ember accents, Fraunces display serif for the cleantime number). Selectable from Settings → NACC → Theme.