Fix specialty keytags showing by default when the setting is off (#24)#28
Merged
Merged
Conversation
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 <noreply@anthropic.com>
pjaudiomv
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #24
Problem
On a fresh install, the specialty (over-2-years) keytags render on the frontend even though Settings → NACC → Show Special Keytags is unchecked and the label says "Default is false."
The settings UI and the frontend disagreed on the default:
DEFAULT_SHOW_SPECIALwas the string'true', and both render paths readget_option( 'nacc_special', self::DEFAULT_SHOW_SPECIAL ). The 2ndget_option()arg only applies when the option row is absent (any install where the form was never saved), so the JS constructor received a truthy"true"and specialty tags rendered.register_settings()registerednacc_specialwithout a'default'key (unlikenacc_theme/nacc_language/nacc_layout), soget_option('nacc_special')indraw_settings()returnedfalseand the checkbox rendered unchecked.Net: checkbox off, frontend on.
Fix (scoped to the default-state bug)
DEFAULT_SHOW_SPECIAL→ booleanfalse.'default' => falseon thenacc_specialsetting sodraw_settings()and the frontendget_optionfallback agree.wp_json_encode( (bool) $args['special'] )inrender_keytags()(shared by both the shortcode and legacynacc_content()paths). This also removes the stringified"0"/"true"truthiness trap flagged in the ticket — the JS side does a truthy check (nacc2/src/nacc.js:59), and a real JSONfalserenders no specialty tags.No JS source change was needed (the constructor already treats the 4th arg as a boolean/truthy check), so the shipped bundle is unchanged.
Verification
nacc_specialrow):get_option('nacc_special', false)→ registered defaultfalse→wp_json_encode( (bool) '' )→ JSfalse→ no specialty tags, and the checkbox reads the samefalsedefault → unchecked. Consistent.true→ JStrue→ tags show; checkbox checked.php -lclean;phpcs(.phpcs.xml) passes with no findings.Shared version / readme bump (see #24/#25/#26)
This is the base of the #24/#25/#26 release set. Per the ticket comment, the version bump and
readme.txtchangelog are meant to be managed once for the combined set. Since #25/#26 aren't merged yet, this PR makes the smallest correct change: version6.0.1 → 6.0.2(plugin header +Stable tag) and a single changelog entry. Reviewer/mergers: please treat the version + changelog as shared with #25/#26 and avoid double-bumping when those land — fold their notes into the same 6.0.2 entry rather than adding another bump.