Skip to content

Keep nav menu + Ask AI button in single policy view (#24)#32

Merged
r00bbert merged 3 commits into
mainfrom
fix/policy-view-nav
May 21, 2026
Merged

Keep nav menu + Ask AI button in single policy view (#24)#32
r00bbert merged 3 commits into
mainfrom
fix/policy-view-nav

Conversation

@r00bbert
Copy link
Copy Markdown
Collaborator

@r00bbert r00bbert commented May 21, 2026

Supersedes #26, which was branched pre-rename and edits the deleted opentrust.pot with old ot- / data-ot-nav / OPENTRUST_PLUGIN_DIR identifiers, so it can no longer merge. This re-applies the same fix onto the current templates.

Problem (#24)

The single policy view rendered a brand-only nav bar — the section menu (Policies, Certifications, …) and the Ask AI CTA were missing, so visitors lost navigation the moment they opened a policy.

Change

  • Extracted the nav into a shared partial templates/partials/nav.php, used by both the main page and the single policy view.
  • `` is now built once in trust-center.php before the view branch and shared across both views.
  • Main page: same-page #ettic-otc-* anchors, scroll-spy on — no behavior change.
  • Policy page: full menu + Ask AI; section links point back to the main page ({base}#ettic-otc-*); scroll-spy off since those sections don't exist there.

Test plan

  • Main page: nav, scroll-spy highlighting, Ask AI all work as before
  • Policy page: nav menu + Ask AI present; section links jump back to the main page and land on the section
  • AI disabled: Ask AI button absent in both views

Closes #24

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Internationalization

    • Refreshed Dutch translation entries and timestamps; added new accessibility/navigation strings (pending Dutch translations) and updated policy/version/FAQ/footer text.
  • Refactor

    • Navigation rendering unified across trust center pages; anchor-based navigation and scroll behavior standardized.
  • New Features

    • Optional "Ask AI" call-to-action appears in the trust center navigation when enabled.

Review Change Stack

Fixes #24. Extract nav into shared templates/partials/nav.php used by
both the main page and policy view. Policy view renders the full menu +
Ask AI; section links point back to the main page, scroll-spy off there.
Re-applies PR #26 onto post-rename templates.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 21, 2026

📝 Walkthrough

Walkthrough

This PR extracts the trust center navigation into templates/partials/nav.php, updates templates/trust-center.php and templates/partials/policy-single.php to include it, and remaps POT/PO gettext references to the new template layout.

Changes

Navigation Partial Extraction and Template Refactoring

Layer / File(s) Summary
Navigation partial component
templates/partials/nav.php
New partial renders trust center navigation with brand (logo or text), conditional multi-item section links with optional scroll-spy, and conditional Ask AI CTA. Includes strict typing, ABSPATH guard, and proper escaping.
Trust center and policy-single templates refactored to delegate navigation
templates/trust-center.php, templates/partials/policy-single.php
Trust center builds $ot_nav_items once from visible sections and passes it to nav.php with scroll-spy enabled. Policy-single includes nav.php with scroll-spy disabled, replacing inline navigation markup. Both templates now coordinate nav display through the shared partial and expose $ot_nav_items/$ot_ai_enabled from the parent context.
Translation catalog synchronization
languages/open-trust-center-by-ettic.pot, languages/open-trust-center-by-ettic-nl_NL.po
POT timestamp updated and gettext source references remapped for the restructured templates; Dutch catalog updated with new accessibility/navigation msgids and adjusted reference locations for policy/version/footer strings.

Sequence Diagram(s)

sequenceDiagram
  participant TrustCenter as templates/trust-center.php
  participant PolicySingle as templates/partials/policy-single.php
  participant Nav as templates/partials/nav.php
  TrustCenter->>TrustCenter: build $ot_nav_items
  TrustCenter->>Nav: include (ot_nav_scrollspy = true)
  PolicySingle->>PolicySingle: set ot_nav_anchor_base, ot_nav_scrollspy = false
  PolicySingle->>Nav: include shared nav partial
  Nav->>Nav: render brand, nav items, Ask AI CTA
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A partial hops in, tidy and spry,

Menus reunited, no more goodbye.
One nav to rule pages, steady and bright,
AI and brand together, doing right. 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: extracting and reusing the navigation menu and Ask AI button across views to fix their absence in the single policy view.
Linked Issues check ✅ Passed The PR successfully addresses issue #24 by restoring the navigation menu and Ask AI button to the single policy view through extracting a shared nav partial.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the navigation and Ask AI button visibility in policy views; translation file updates are supporting artifacts for the code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/policy-view-nav

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@languages/open-trust-center-by-ettic-nl_NL.po`:
- Around line 2388-2394: Provide Dutch translations for the two empty msgstr
entries by filling the msgstr for msgid "Skip to content" (use a proper Dutch
phrase like "Sla naar inhoud over" or "Ga naar inhoud") and for msgid "Trust
center navigation" (use "Navigatie vertrouwenscentrum" or similar), ensuring the
translations replace the empty strings directly in the PO entries so nl_NL users
see localized ARIA/navigation labels; update the entries where msgid equals
"Skip to content" and "Trust center navigation".

In `@templates/partials/nav.php`:
- Around line 25-30: The brand image can end up with an empty alt when
$ot_company_name is empty, breaking the accessible name for the brand link;
update the rendering logic around $ot_logo_url and $ot_company_name so the image
alt and/or the surrounding brand link always use a non-empty accessible name
(fall back to get_bloginfo('name') when $ot_company_name is empty).
Specifically, ensure the img alt uses esc_attr($ot_company_name ?:
get_bloginfo('name')) and/or add an aria-label on the brand link that uses the
same fallback so the link always has an accessible name (refer to variables
$ot_logo_url, $ot_company_name and the element with class
ettic-otc-nav__brand-logo / ettic-otc-nav__brand-name).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f00a2484-53da-48be-8bdb-d933ccb7eb31

📥 Commits

Reviewing files that changed from the base of the PR and between e4aa0bc and 5bae6de.

📒 Files selected for processing (5)
  • languages/open-trust-center-by-ettic-nl_NL.po
  • languages/open-trust-center-by-ettic.pot
  • templates/partials/nav.php
  • templates/partials/policy-single.php
  • templates/trust-center.php

Comment on lines +2388 to 2394
#: templates/chat.php:100 templates/trust-center.php:111
msgid "Skip to content"
msgstr ""

#: templates/chat.php:102 templates/partials/policy-single.php:36
#: templates/trust-center.php:114
#: templates/chat.php:102 templates/partials/nav.php:22
msgid "Trust center navigation"
msgstr ""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Translate newly added navigation accessibility labels in Dutch.

The new entries for navigation accessibility text are still empty, so nl_NL users will see English strings for these UI/ARIA labels.

Proposed fix
 #: templates/chat.php:100 templates/trust-center.php:111
 msgid "Skip to content"
-msgstr ""
+msgstr "Ga naar inhoud"

 #: templates/chat.php:102 templates/partials/nav.php:22
 msgid "Trust center navigation"
-msgstr ""
+msgstr "Trust center-navigatie"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#: templates/chat.php:100 templates/trust-center.php:111
msgid "Skip to content"
msgstr ""
#: templates/chat.php:102 templates/partials/policy-single.php:36
#: templates/trust-center.php:114
#: templates/chat.php:102 templates/partials/nav.php:22
msgid "Trust center navigation"
msgstr ""
#: templates/chat.php:100 templates/trust-center.php:111
msgid "Skip to content"
msgstr "Ga naar inhoud"
#: templates/chat.php:102 templates/partials/nav.php:22
msgid "Trust center navigation"
msgstr "Trust center-navigatie"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@languages/open-trust-center-by-ettic-nl_NL.po` around lines 2388 - 2394,
Provide Dutch translations for the two empty msgstr entries by filling the
msgstr for msgid "Skip to content" (use a proper Dutch phrase like "Sla naar
inhoud over" or "Ga naar inhoud") and for msgid "Trust center navigation" (use
"Navigatie vertrouwenscentrum" or similar), ensuring the translations replace
the empty strings directly in the PO entries so nl_NL users see localized
ARIA/navigation labels; update the entries where msgid equals "Skip to content"
and "Trust center navigation".

Comment thread templates/partials/nav.php Outdated
r00bbert added 2 commits May 21, 2026 23:54
Fall back to site name for the logo alt so the brand link always has
an accessible label. Addresses CodeRabbit a11y note.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
languages/open-trust-center-by-ettic-nl_NL.po (1)

2388-2394: ⚠️ Potential issue | 🟡 Minor

Translate newly added navigation accessibility labels in Dutch.

The new entries for navigation accessibility text are still empty, so nl_NL users will see English strings for these UI/ARIA labels.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@languages/open-trust-center-by-ettic-nl_NL.po` around lines 2388 - 2394, Add
Dutch translations for the two empty msgstr entries by replacing the empty
msgstr values for the msgid "Skip to content" and "Trust center navigation" with
appropriate Dutch strings (e.g., "Sla naar inhoud over" or "Ga naar inhoud" for
"Skip to content" and "Navigatie vertrouwenscentrum" for "Trust center
navigation") so nl_NL users see localized ARIA/navigation labels; update the
msgstr for those exact msgid entries in the PO file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@languages/open-trust-center-by-ettic-nl_NL.po`:
- Around line 2388-2394: Add Dutch translations for the two empty msgstr entries
by replacing the empty msgstr values for the msgid "Skip to content" and "Trust
center navigation" with appropriate Dutch strings (e.g., "Sla naar inhoud over"
or "Ga naar inhoud" for "Skip to content" and "Navigatie vertrouwenscentrum" for
"Trust center navigation") so nl_NL users see localized ARIA/navigation labels;
update the msgstr for those exact msgid entries in the PO file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 89273217-92d6-47dd-a864-8afbde21e51f

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee7335 and 148f9be.

📒 Files selected for processing (2)
  • languages/open-trust-center-by-ettic-nl_NL.po
  • languages/open-trust-center-by-ettic.pot
✅ Files skipped from review due to trivial changes (1)
  • languages/open-trust-center-by-ettic.pot

@r00bbert r00bbert merged commit c5804cb into main May 21, 2026
11 checks passed
@r00bbert r00bbert deleted the fix/policy-view-nav branch May 21, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Menu items and 'Ask AI' button disappears when in single policy view

1 participant