-data.php into a
* Gutenberg block payload (`post_content`) so that :
*
* - Pages are editable in the WP admin block editor
* - Bricks Builder can pick them up via « Edit with Bricks » (Bricks reads
* post_content and converts core blocks → Bricks elements on save)
* - WPML's Translation Editor exposes every block for translation
*
* Strategy
* --------
* We generate Gutenberg-valid HTML using a mix of native blocks
* (`core/heading`, `core/paragraph`, `core/list`, `core/buttons`,
* `core/columns`) wrapped in `core/group` containers carrying our
* `av-*` classes. Visually-heavy items (hero, conversion banner,
* complex cards) fall back to `core/html` blocks so the rendering
* stays pixel-identical to the Custom Template version, while still
* being individually translatable in WPML.
*
* Public API
* ----------
* av_render_solution_blocks($data) → string (post_content)
* av_render_industry_blocks($data) → string
* av_render_technology_blocks($data) → string (alias of industry)
* av_render_editorial_blocks($data) → string (alias of industry)
* av_render_form_blocks($data, $slug) → string
* av_render_overview_blocks($cards, $hero, $bg) → string (hubs)
* av_render_home_blocks() → string
*
* @package AsterionBricks
*/
defined('ABSPATH') || exit;
/* =================================================================== */
/* Block helpers */
/* =================================================================== */
function av_block_html($html) {
$html = trim($html);
return "\n{$html}\n\n\n";
}
function av_block_heading($text, $level = 2, $class = '') {
$tag = 'h' . max(1, min(6, (int) $level));
$class = $class ? ' ' . esc_attr($class) : '';
$args = json_encode(['level' => (int) $level, 'className' => trim($class)]);
return "\n<{$tag} class=\"wp-block-heading{$class}\">" . esc_html($text) . "{$tag}>\n\n\n";
}
function av_block_paragraph($text, $class = '') {
$args = $class ? json_encode(['className' => $class]) . ' ' : '';
$cls = $class ? ' class="' . esc_attr($class) . '"' : '';
return "\n
" . esc_html($text) . "
\n\n\n";
}
function av_block_list($items) {
$out = "\n\n";
foreach ($items as $item) {
$out .= "\n- " . esc_html($item) . "
\n\n";
}
$out .= "
\n\n\n";
return $out;
}
function av_block_button($label, $href, $variant = 'primary', $on_dark = false) {
$href = esc_url($href);
$label = esc_html($label);
$cls = 'av-btn av-btn--' . $variant . ($on_dark ? ' av-btn--on-dark' : '') . ' av-btn--lg';
return "\n{$label}\n\n\n";
}
function av_block_buttons_row($ctas, $on_dark = false, $home_url = '') {
if (empty($ctas)) return '';
$out = "\n\n";
foreach ($ctas as $cta) {
$href = $home_url . ltrim($cta['href'], '/');
$variant = ($cta['variant'] === 'primary') ? 'av-btn--primary' : ($on_dark ? 'av-btn--on-dark av-btn--secondary' : 'av-btn--secondary');
$out .= '
' . esc_html($cta['label']) . "\n";
}
$out .= "
\n\n\n";
return $out;
}
/* =================================================================== */
/* Hero blocks */
/* =================================================================== */
function av_render_solution_hero($data, $home_url) {
$eyebrow = esc_html($data['eyebrow']);
$title = esc_html($data['title']);
$tagline = esc_html($data['tagline']);
$lead = esc_html($data['hero_lead']);
$ctas = '';
foreach ($data['ctas'] as $cta) {
$href = $home_url . ltrim($cta['href'], '/');
$variant = ($cta['variant'] === 'primary') ? 'av-btn--primary' : 'av-btn--secondary av-btn--on-dark';
$ctas .= '' . esc_html($cta['label']) . "\n";
}
$html = <<
{$eyebrow}
{$title}™ — {$tagline}
{$lead}
{$ctas}
HTML;
return av_block_html($html);
}
function av_render_industry_hero($data, $home_url) {
$eyebrow = esc_html($data['eyebrow']);
$tagline = esc_html($data['tagline']);
$lead = esc_html($data['hero_lead']);
$ctas = '';
foreach ($data['ctas'] as $cta) {
$href = $home_url . ltrim($cta['href'], '/');
$variant = ($cta['variant'] === 'primary') ? 'av-btn--primary' : 'av-btn--secondary av-btn--on-dark';
$ctas .= '' . esc_html($cta['label']) . "\n";
}
$html = <<
{$eyebrow}
{$tagline}
{$lead}
{$ctas}
HTML;
return av_block_html($html);
}
/* =================================================================== */
/* Section renderer (shared by solution / industry / technology / */
/* editorial detail pages) */
/* =================================================================== */
function av_render_data_section($section, $is_dark, $home_url) {
$section_class = 'av-section' . ($is_dark ? ' av-section--dark' : '');
$eye_class = 'av-eyebrow' . ($is_dark ? ' av-eyebrow--gold' : '');
$eyebrow = esc_html($section['eyebrow'] ?? '');
$title = esc_html($section['title'] ?? '');
$lead = ! empty($section['lead']) ? '' . esc_html($section['lead']) . '
' : '';
$head_html = <<
{$eyebrow}
{$title}
{$lead}
HTML;
$body = '';
switch ($section['type']) {
case 'prose':
$body = '
' . esc_html($section['body'] ?? '') . '
';
break;
case 'cards':
$body = '
';
foreach ($section['items'] as $card) {
$card_class = 'av-card' . ($is_dark ? ' is-on-dark' : '') . ' av-card--feature';
$body .= '
';
$body .= '
' . esc_html($card['title']) . '
';
$body .= '
' . esc_html($card['body']) . '
';
$body .= '
';
}
$body .= '
';
break;
case 'list':
$color = $is_dark ? 'color:var(--color-text-on-dark-muted);' : 'color:var(--color-text-secondary);';
$body = '
';
foreach ($section['items'] as $item) {
$body .= '- ' . esc_html($item) . '
';
}
$body .= '
';
if (! empty($section['cta'])) {
$href = $home_url . ltrim($section['cta']['href'], '/');
$linkcls = 'av-link' . ($is_dark ? ' av-link--on-dark' : '') . ' av-link--with-arrow';
$body .= '
' . esc_html($section['cta']['label']) . '
';
}
break;
case 'cta':
$body = '
' . esc_html($section['body'] ?? '') . '
';
if (! empty($section['ctas'])) {
$body .= '
';
foreach ($section['ctas'] as $cta) {
$href = $home_url . ltrim($cta['href'], '/');
$variant = ($cta['variant'] === 'primary') ? 'av-btn--primary' : ($is_dark ? 'av-btn--on-dark av-btn--secondary' : 'av-btn--secondary');
$body .= '
' . esc_html($cta['label']) . "";
}
$body .= '
';
}
break;
}
$foot_html = "
";
return av_block_html($head_html . $body . $foot_html);
}
/* =================================================================== */
/* Conversion banner (shared) */
/* =================================================================== */
function av_render_conversion_banner($home_url) {
$html = <<
Train like the threat is now.
Three paths into the platform — pick the one that fits where you are.
Request a T&E Kit
A PROSERVE case on loan at your facility for 5 to 10 days.
Request the kit
Request a Quote
A detailed quote and deployment plan within 5 working days.
Get a quote
HTML;
return av_block_html($html);
}
/* =================================================================== */
/* Top-level renderers */
/* =================================================================== */
function av_render_solution_blocks($data) {
$home_url = home_url('/');
$out = av_render_solution_hero($data, $home_url);
foreach ($data['sections'] as $idx => $section) {
$out .= av_render_data_section($section, ($idx % 2 === 1), $home_url);
}
if (! empty($data['upsell'])) {
$upsell_html = '';
$upsell_html .= '
';
$upsell_html .= '
Comparison and upgrade';
$upsell_html .= '
' . esc_html($data['upsell']['title']) . '
';
$upsell_html .= '
' . esc_html($data['upsell']['body']) . '
';
$upsell_html .= '
';
$out .= av_block_html($upsell_html);
}
$out .= av_render_conversion_banner($home_url);
return $out;
}
function av_render_industry_blocks($data) {
$home_url = home_url('/');
$out = av_render_industry_hero($data, $home_url);
foreach ($data['sections'] as $idx => $section) {
$out .= av_render_data_section($section, ($idx % 2 === 1), $home_url);
}
$out .= av_render_conversion_banner($home_url);
return $out;
}
function av_render_technology_blocks($data) {
return av_render_industry_blocks($data); // identical schema
}
function av_render_editorial_blocks($data) {
return av_render_industry_blocks($data);
}
function av_render_form_blocks($data, $slug) {
$home_url = home_url('/');
// Hero
$eyebrow = esc_html($data['eyebrow']);
$tagline = esc_html($data['tagline']);
$lead = esc_html($data['hero_lead']);
$shortcuts_html = '';
if (! empty($data['shortcuts'])) {
$shortcuts_html .= '';
foreach ($data['shortcuts'] as $sc) {
$variant = ($sc['variant'] === 'primary') ? 'av-btn--primary' : 'av-btn--on-dark av-btn--secondary';
$shortcuts_html .= '
' . esc_html($sc['label']) . '';
}
$shortcuts_html .= '
';
}
$hero_html = <<
{$eyebrow}
{$tagline}
{$lead}
{$shortcuts_html}
HTML;
$out = av_block_html($hero_html);
// The form itself stays a shortcode — added by template wrapper instead.
// To keep the page editable, we drop a placeholder shortcode that the
// child theme's `av_form` shortcode handler renders on the front-end.
$out .= av_block_html('[av_form slug="' . esc_attr($slug) . '"]
');
return $out;
}
function av_render_overview_blocks($cards, $hero_eyebrow, $hero_title, $hero_sub) {
$home_url = home_url('/');
$hero_html = <<
{$hero_eyebrow}
{$hero_title}
{$hero_sub}
HTML;
$out = av_block_html($hero_html);
$cards_html = '';
foreach ($cards as $c) {
$href = $home_url . ltrim($c['href'], '/');
$cards_html .= '
';
$cards_html .= '';
$cards_html .= '
' . esc_html($c['eyebrow'] ?? '') . '';
$cards_html .= '
';
$cards_html .= '
' . esc_html($c['excerpt']) . '
';
$cards_html .= '
';
$cards_html .= '
';
}
$cards_html .= '
';
$out .= av_block_html($cards_html);
return $out;
}