Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions templates/partials/nav.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Shared trust center navigation.
*
* Variables expected from parent:
* $ot_base_url, $ot_logo_url, $ot_company_name, $ot_ai_enabled, $ot_nav_items
* $ot_nav_anchor_base — prefix for section links ('' on the main page so they
* stay same-page anchors; the trust center URL on the
* single policy page so they jump back home).
* $ot_nav_scrollspy — whether to wire links into the JS scroll-spy.
*/

declare(strict_types=1);

defined('ABSPATH') || exit;

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template variables are local scope via include()

$ot_nav_anchor_base = $ot_nav_anchor_base ?? '';
$ot_nav_scrollspy = $ot_nav_scrollspy ?? false;
?>
<nav class="ot-nav" aria-label="<?php esc_attr_e('Trust center navigation', 'opentrust'); ?>">
<div class="ot-container ot-nav__inner">
<a href="<?php echo esc_url($ot_base_url); ?>" class="ot-nav__brand">
<?php if ($ot_logo_url): ?>
<img class="ot-nav__brand-logo"
src="<?php echo esc_url($ot_logo_url); ?>"
alt="<?php echo esc_attr($ot_company_name); ?>">
<?php else: ?>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
<span class="ot-nav__brand-name"><?php echo esc_html($ot_company_name ?: get_bloginfo('name')); ?></span>
<?php endif; ?>
</a>
<?php if (count($ot_nav_items) > 1): ?>
<div class="ot-nav__links">
<?php foreach ($ot_nav_items as $ot_id => $ot_label): ?>
<a href="<?php echo esc_url($ot_nav_anchor_base . '#ot-' . $ot_id); ?>"
class="ot-nav__link"<?php echo $ot_nav_scrollspy ? ' data-ot-nav' : ''; ?>>
<?php echo esc_html($ot_label); ?>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($ot_ai_enabled): ?>
<div class="ot-nav__cta">
<a href="<?php echo esc_url(trailingslashit($ot_base_url) . 'ask/'); ?>" class="ot-nav__ask">
<svg class="ot-nav__ask-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>
<path d="M20 3v4"/>
<path d="M22 5h-4"/>
<path d="M4 17v2"/>
<path d="M5 18H3"/>
</svg>
<span class="ot-nav__ask-label"><?php esc_html_e('Ask AI', 'opentrust'); ?></span>
</a>
</div>
<?php endif; ?>
</div>
</nav>
20 changes: 6 additions & 14 deletions templates/partials/policy-single.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,13 @@
$ot_modified_date = wp_date(get_option('date_format'), strtotime($ot_policy->post_modified));

$ot_current_url = trailingslashit($ot_base_url) . 'policy/' . $ot_policy->post_name . '/';
?>

<nav class="ot-nav" aria-label="<?php esc_attr_e('Trust center navigation', 'opentrust'); ?>">
<div class="ot-container ot-nav__inner">
<a href="<?php echo esc_url($ot_base_url); ?>" class="ot-nav__brand">
<?php if ($ot_logo_url): ?>
<img class="ot-nav__brand-logo"
src="<?php echo esc_url($ot_logo_url); ?>"
alt="<?php echo esc_attr($ot_company_name); ?>">
<?php else: ?>
<span class="ot-nav__brand-name"><?php echo esc_html($ot_company_name ?: get_bloginfo('name')); ?></span>
<?php endif; ?>
</a>
</div>
</nav>
// Section links jump back to the main trust center page; scroll-spy is off
// since those sections don't exist on this page.
$ot_nav_anchor_base = $ot_base_url;
$ot_nav_scrollspy = false;
include OPENTRUST_PLUGIN_DIR . 'templates/partials/nav.php';
?>

<main id="ot-main" class="ot-policy-single">
<div class="ot-container ot-container--narrow">
Expand Down
59 changes: 14 additions & 45 deletions templates/trust-center.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
$ot_accent_l_safe = !empty($ot_settings['accent_force_exact'])
? (int) $ot_hsl['l']
: OpenTrust::accent_safe_lightness((string) ($ot_settings['accent_color'] ?? '#2563EB'));

// Navigation items — shared by the main page and the single policy view so
// the menu stays put when a visitor drills into a policy.
$ot_nav_items = [];
if (!empty($ot_visible['policies']) && $ot_policy_count) $ot_nav_items['policies'] = __('Policies', 'opentrust');
if (!empty($ot_visible['certifications']) && $ot_cert_count) $ot_nav_items['certifications'] = __('Certifications', 'opentrust');
if (!empty($ot_visible['subprocessors']) && $ot_sub_count) $ot_nav_items['subprocessors'] = __('Subprocessors', 'opentrust');
if (!empty($ot_visible['data_practices']) && count($ot_data['data_practices'] ?? [])) $ot_nav_items['data-practices'] = __('Data Practices', 'opentrust');
if (!empty($ot_visible['contact']) && $ot_contact_has_content) $ot_nav_items['contact'] = __('Contact', 'opentrust');
if (!empty($ot_visible['faqs']) && $ot_faq_count) $ot_nav_items['faqs'] = __('FAQ', 'opentrust');
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
Expand Down Expand Up @@ -103,51 +113,10 @@
<?php
if ($ot_view === 'main') {
// ── Navigation (above hero) ──
$ot_nav_items = [];
if (!empty($ot_visible['policies']) && $ot_policy_count) $ot_nav_items['policies'] = __('Policies', 'opentrust');
if (!empty($ot_visible['certifications']) && $ot_cert_count) $ot_nav_items['certifications'] = __('Certifications', 'opentrust');
if (!empty($ot_visible['subprocessors']) && $ot_sub_count) $ot_nav_items['subprocessors'] = __('Subprocessors', 'opentrust');
if (!empty($ot_visible['data_practices']) && count($ot_data['data_practices'] ?? [])) $ot_nav_items['data-practices'] = __('Data Practices', 'opentrust');
if (!empty($ot_visible['contact']) && $ot_contact_has_content) $ot_nav_items['contact'] = __('Contact', 'opentrust');
if (!empty($ot_visible['faqs']) && $ot_faq_count) $ot_nav_items['faqs'] = __('FAQ', 'opentrust');
?>
<nav class="ot-nav" aria-label="<?php esc_attr_e('Trust center navigation', 'opentrust'); ?>">
<div class="ot-container ot-nav__inner">
<a href="<?php echo esc_url($ot_base_url); ?>" class="ot-nav__brand">
<?php if ($ot_logo_url): ?>
<img class="ot-nav__brand-logo"
src="<?php echo esc_url($ot_logo_url); ?>"
alt="<?php echo esc_attr($ot_company_name); ?>">
<?php else: ?>
<span class="ot-nav__brand-name"><?php echo esc_html($ot_company_name ?: get_bloginfo('name')); ?></span>
<?php endif; ?>
</a>
<?php if (count($ot_nav_items) > 1): ?>
<div class="ot-nav__links">
<?php foreach ($ot_nav_items as $ot_id => $ot_label): ?>
<a href="#ot-<?php echo esc_attr($ot_id); ?>" class="ot-nav__link" data-ot-nav>
<?php echo esc_html($ot_label); ?>
</a>
<?php endforeach; ?>
</div>
<?php endif; ?>
<?php if ($ot_ai_enabled): ?>
<div class="ot-nav__cta">
<a href="<?php echo esc_url(trailingslashit($ot_base_url) . 'ask/'); ?>" class="ot-nav__ask">
<svg class="ot-nav__ask-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<path d="M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"/>
<path d="M20 3v4"/>
<path d="M22 5h-4"/>
<path d="M4 17v2"/>
<path d="M5 18H3"/>
</svg>
<span class="ot-nav__ask-label"><?php esc_html_e('Ask AI', 'opentrust'); ?></span>
</a>
</div>
<?php endif; ?>
</div>
</nav>
<?php
$ot_nav_anchor_base = '';
$ot_nav_scrollspy = true;
include OPENTRUST_PLUGIN_DIR . 'templates/partials/nav.php';

// ── Hero ──
include OPENTRUST_PLUGIN_DIR . 'templates/partials/hero.php';
?>
Expand Down
Loading