Files
AsterionWP2026/wp-content/themes/asterion-bricks/header.php
j.foucher f18a57e83f feat(wpml): refactor to post_content + duplicate site in French via WPML
This commit makes the site editable from WP admin (Gutenberg or Bricks
"Edit with Bricks") and translatable via WPML Translation Editor by
shifting page rendering away from Custom Templates and into post_content.

Architecture change
-------------------
Before: Custom Templates assigned to each page (page-solution-detail.php
etc.) generated the page HTML at runtime by reading from inc/*-data.php
arrays. WPML had nothing to translate, Bricks Builder had nothing to
edit, the client could only modify content by editing PHP.

After:
- Pages now hold their full Gutenberg HTML inside post_content
- The default page.php template renders the_content() — no Custom
  Templates assigned anymore
- Bricks Builder picks up post_content and converts it to its element
  tree when "Edit with Bricks" is clicked
- WPML Translation Editor exposes every block for translation
- The client can edit pages directly in WP admin

What this commit ships
----------------------
- inc/render-blocks.php: data array → Gutenberg HTML payload generator
  with helpers per section type (prose / cards / list / cta) and per
  page archetype (solution / industry / technology / editorial / form
  / overview hub).
- inc/shortcodes.php: [av_form slug="request-demo"] for dynamic form
  blocks (forms can't live as static HTML — they need nonces and
  per-request state).
- inc/i18n.php: av_lang() / av_t() helpers for inline string translation
  in header.php and footer.php (covers ~80 UI strings); switches based
  on WPML's wpml_current_language filter.
- page.php: minimal default template — get_header() + the_content() +
  get_footer().
- header.php: real WPML language switcher driven by
  wpml_active_languages filter (replaces the placeholder EN · FR
  toggle); UI strings now route through av_t().
- footer.php: same UI string treatment.
- Custom Templates retained but no longer assigned (pages were stripped
  by the migration mu-plugin); they remain available if a page wants
  to opt back into the data-file pattern.

Operational migrations (one-shot mu-plugins, not versioned)
-----------------------------------------------------------
1. asterion-migrate-to-blocks.php walked all 26 PHP-templated pages,
   pre-rendered them via the new render-blocks helpers, wrote the
   result to post_content, and stripped _wp_page_template.
2. asterion-duplicate-fr.php cloned all 35 pages into French via WPML
   API, preserved parent/child hierarchy, linked translations through
   the trid table, marked them as duplicates pending refinement.
3. asterion-fix-fr-slugs.php aligned French slugs with English ones
   (WP's wp_unique_post_slug() had appended -2 suffixes; we bypass
   via $wpdb->update so /fr/solutions/ resolves correctly).

Verified
--------
- All 35 EN URLs return HTTP 200
- All 35 FR URLs return HTTP 200 under /fr/<slug>/
- Language switcher in header outputs correct hreflang links
- WPML emits hreflang en / fr / x-default in <head>
- Body class confirms wp-child-theme-asterion-bricks active
- Bricks frontend CSS still enqueued
- Inter Variable still preloaded

Next steps
----------
- French content is currently the duplicated EN copy. Translate via
  WP admin → WPML → Translation Editor (per-block UI), or edit pages
  directly in /fr/<slug>/ via Gutenberg / Bricks
- WPML String Translation can scan the theme to surface av_t() / __()
  strings for UI-level translation overrides

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 13:11:42 +02:00

129 lines
6.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Asterion Bricks — Global header
*
* Sticky header per Design Handoff section 3.5 :
* - 60px on mobile, 72px on desktop
* - Logo left, main nav center (desktop), CTA + lang switch right
* - Hamburger drawer on mobile
*
* @package AsterionBricks
*/
defined('ABSPATH') || exit;
?>
<!doctype html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo('charset'); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#0B1F3A">
<link rel="profile" href="https://gmpg.org/xfn/11">
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php wp_body_open(); ?>
<a class="av-skip-link" href="#main"><?php echo esc_html(av_t('Skip to main content', 'asterion-bricks')); ?></a>
<header class="av-header" role="banner">
<div class="av-container av-header__inner">
<a href="<?php echo esc_url(home_url('/')); ?>" class="av-header__logo" aria-label="Asterion VR — home">
ASTERION&nbsp;VR
</a>
<nav class="av-nav" aria-label="<?php esc_attr_e('Primary', 'asterion-bricks'); ?>">
<ul class="av-nav__list" style="display:flex;gap:var(--space-6);list-style:none;margin:0;padding:0;">
<li class="av-nav__item">
<a href="<?php echo esc_url(home_url('/solutions/')); ?>" class="av-nav__link" aria-haspopup="true" aria-expanded="false">
<?php echo esc_html(av_t('Solutions', 'asterion-bricks')); ?>
</a>
</li>
<li class="av-nav__item">
<a href="<?php echo esc_url(home_url('/industries/')); ?>" class="av-nav__link" aria-haspopup="true" aria-expanded="false">
<?php echo esc_html(av_t('Industries', 'asterion-bricks')); ?>
</a>
</li>
<li class="av-nav__item">
<a href="<?php echo esc_url(home_url('/technology/')); ?>" class="av-nav__link" aria-haspopup="true" aria-expanded="false">
<?php echo esc_html(av_t('Technology', 'asterion-bricks')); ?>
</a>
</li>
<li class="av-nav__item">
<a href="<?php echo esc_url(home_url('/why-asterion/')); ?>" class="av-nav__link">
<?php echo esc_html(av_t('Why Asterion', 'asterion-bricks')); ?>
</a>
</li>
<li class="av-nav__item">
<a href="<?php echo esc_url(home_url('/insights/')); ?>" class="av-nav__link">
<?php echo esc_html(av_t('Insights', 'asterion-bricks')); ?>
</a>
</li>
</ul>
</nav>
<div class="av-header__right">
<?php
// Render WPML language switcher when WPML is active and exposes languages.
$av_languages = apply_filters('wpml_active_languages', null, ['skip_missing' => 0]);
if (! empty($av_languages) && is_array($av_languages) && count($av_languages) > 1) :
?>
<div class="av-lang-switch" aria-label="<?php echo esc_attr(av_t('Language')); ?>">
<?php $av_first = true; foreach ($av_languages as $av_lang_data) :
if (! $av_first) : ?><span aria-hidden="true">·</span><?php endif; $av_first = false;
$av_code = strtoupper($av_lang_data['language_code']);
$av_url = esc_url($av_lang_data['url']);
$av_label = esc_html($av_lang_data['translated_name'] ?? $av_lang_data['native_name'] ?? $av_code);
if (! empty($av_lang_data['active'])) : ?>
<span class="av-lang-switch__current" aria-current="true"><?php echo esc_html($av_code); ?></span>
<?php else : ?>
<a href="<?php echo $av_url; ?>" class="av-lang-switch__other" hreflang="<?php echo esc_attr($av_lang_data['language_code']); ?>" lang="<?php echo esc_attr($av_lang_data['language_code']); ?>" aria-label="<?php echo esc_attr($av_label); ?>"><?php echo esc_html($av_code); ?></a>
<?php endif;
endforeach; ?>
</div>
<?php endif; ?>
<a href="<?php echo esc_url(home_url('/request-demo/')); ?>" class="av-btn av-btn--primary av-btn--md">
<?php echo esc_html(av_t('Request a Demo', 'asterion-bricks')); ?>
</a>
<button type="button" class="av-drawer-toggle" aria-controls="av-drawer" aria-expanded="false" aria-label="<?php esc_attr_e('Open menu', 'asterion-bricks'); ?>">
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<line x1="3" y1="6" x2="21" y2="6"></line>
<line x1="3" y1="12" x2="21" y2="12"></line>
<line x1="3" y1="18" x2="21" y2="18"></line>
</svg>
</button>
</div>
</div>
</header>
<aside id="av-drawer" class="av-drawer" aria-hidden="true">
<button type="button" class="av-drawer__close" aria-label="<?php esc_attr_e('Close menu', 'asterion-bricks'); ?>">×</button>
<nav class="av-drawer__nav" aria-label="<?php esc_attr_e('Mobile primary', 'asterion-bricks'); ?>">
<div class="av-drawer__group">
<a href="<?php echo esc_url(home_url('/solutions/')); ?>" class="av-drawer__group-title"><?php echo esc_html(av_t('Solutions', 'asterion-bricks')); ?></a>
</div>
<div class="av-drawer__group">
<a href="<?php echo esc_url(home_url('/industries/')); ?>" class="av-drawer__group-title"><?php echo esc_html(av_t('Industries', 'asterion-bricks')); ?></a>
</div>
<div class="av-drawer__group">
<a href="<?php echo esc_url(home_url('/technology/')); ?>" class="av-drawer__group-title"><?php echo esc_html(av_t('Technology', 'asterion-bricks')); ?></a>
</div>
<div class="av-drawer__group">
<a href="<?php echo esc_url(home_url('/why-asterion/')); ?>" class="av-drawer__group-title"><?php echo esc_html(av_t('Why Asterion', 'asterion-bricks')); ?></a>
</div>
<div class="av-drawer__group">
<a href="<?php echo esc_url(home_url('/insights/')); ?>" class="av-drawer__group-title"><?php echo esc_html(av_t('Insights', 'asterion-bricks')); ?></a>
</div>
</nav>
<div class="av-drawer__cta-area">
<a href="<?php echo esc_url(home_url('/request-demo/')); ?>" class="av-btn av-btn--primary av-btn--lg" style="width:100%;">
<?php echo esc_html(av_t('Request a Demo', 'asterion-bricks')); ?>
</a>
</div>
</aside>
<main id="main" class="av-main">