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>
This commit is contained in:
@@ -23,7 +23,7 @@ defined('ABSPATH') || exit;
|
||||
<body <?php body_class(); ?>>
|
||||
<?php wp_body_open(); ?>
|
||||
|
||||
<a class="av-skip-link" href="#main"><?php esc_html_e('Skip to main content', 'asterion-bricks'); ?></a>
|
||||
<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">
|
||||
@@ -36,41 +36,55 @@ defined('ABSPATH') || exit;
|
||||
<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 esc_html_e('Solutions', 'asterion-bricks'); ?>
|
||||
<?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 esc_html_e('Industries', 'asterion-bricks'); ?>
|
||||
<?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 esc_html_e('Technology', 'asterion-bricks'); ?>
|
||||
<?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 esc_html_e('Why Asterion', 'asterion-bricks'); ?>
|
||||
<?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 esc_html_e('Insights', 'asterion-bricks'); ?>
|
||||
<?php echo esc_html(av_t('Insights', 'asterion-bricks')); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="av-header__right">
|
||||
<div class="av-lang-switch" aria-label="<?php esc_attr_e('Language', 'asterion-bricks'); ?>">
|
||||
<span class="av-lang-switch__current">EN</span>
|
||||
<span aria-hidden="true">·</span>
|
||||
<a href="#" class="av-lang-switch__other" aria-label="<?php esc_attr_e('Switch to French', 'asterion-bricks'); ?>">FR</a>
|
||||
</div>
|
||||
<?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 esc_html_e('Request a Demo', 'asterion-bricks'); ?>
|
||||
<?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'); ?>">
|
||||
@@ -89,24 +103,24 @@ defined('ABSPATH') || exit;
|
||||
<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 esc_html_e('Solutions', 'asterion-bricks'); ?></a>
|
||||
<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 esc_html_e('Industries', 'asterion-bricks'); ?></a>
|
||||
<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 esc_html_e('Technology', 'asterion-bricks'); ?></a>
|
||||
<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 esc_html_e('Why Asterion', 'asterion-bricks'); ?></a>
|
||||
<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 esc_html_e('Insights', 'asterion-bricks'); ?></a>
|
||||
<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 esc_html_e('Request a Demo', 'asterion-bricks'); ?>
|
||||
<?php echo esc_html(av_t('Request a Demo', 'asterion-bricks')); ?>
|
||||
</a>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
Reference in New Issue
Block a user