string, // unique, via Bricks\Helpers::generate_random_id(false) * 'name' => 'section' | 'container' | 'block' | 'heading' | 'text-basic' | 'button' | …, * 'parent' => 0 | string, // 0 = page root, else parent's id * 'children' => [string, …], // optional, for nestable elements * 'settings' => [ * 'text' => 'Hello', * 'tag' => 'h1' | 'h2' | …, * 'link' => ['type' => 'external', 'url' => 'https://…'], * '_cssClasses' => 'av-hero', * … * ], * ], * … * ] * * Once stored, opening the page in WP admin and clicking "Edit with Bricks" * surfaces every element in the Bricks builder canvas, fully editable. * * Frontend rendering is handled by Bricks itself — our `page.php` simply * lets Bricks take over via its `template_include` filter. * * @package AsterionBricks */ defined('ABSPATH') || exit; /** * Generate a Bricks-compatible random element ID. * Falls back to a local md5 prefix if the Bricks namespace isn't loaded yet. */ function av_brx_id() { if (class_exists('\\Bricks\\Helpers') && method_exists('\\Bricks\\Helpers', 'generate_random_id')) { return \Bricks\Helpers::generate_random_id(false); } return substr(md5(uniqid((string) mt_rand(), true)), 0, 6); } /** * Tiny element factory. */ function av_brx_el($name, $parent, $settings = [], $children = null) { $el = [ 'id' => av_brx_id(), 'name' => $name, 'parent' => $parent, 'settings' => $settings, ]; if ($children !== null) { $el['children'] = $children; } return $el; } /* =================================================================== */ /* Industries overview — proof of concept */ /* =================================================================== */ function av_brx_render_industries_overview() { $home_url = home_url('/'); /* ---- pre-allocate IDs so we can hand them to parents/children ---- */ $hero_section_id = av_brx_id(); $hero_container_id = av_brx_id(); $hero_eyebrow_id = av_brx_id(); $hero_h1_id = av_brx_id(); $hero_sub_id = av_brx_id(); $cards_section_id = av_brx_id(); $cards_container_id = av_brx_id(); $cards_grid_id = av_brx_id(); $industries = [ [ 'eyebrow' => 'National & Municipal', 'title' => 'Police', 'excerpt' => 'Vehicle stops, identity checks, urban CQB, de-escalation, riot containment. Built for the realities of contemporary policing.', 'href' => '/industries/police/', 'cta' => 'Police training', ], [ 'eyebrow' => 'Tactical units', 'title' => 'Special Forces', 'excerpt' => 'Hostage rescue, dynamic entries, hostile crowd extraction, sniper-spotter coordination. Built for the units where every error has a name.', 'href' => '/industries/special-forces/', 'cta' => 'Special forces training', ], [ 'eyebrow' => 'Armed forces', 'title' => 'Military', 'excerpt' => 'MOUT, convoy escort, FOB defense, IED awareness, joint operation drills. Built for armed forces that deploy fast and adapt faster.', 'href' => '/industries/military/', 'cta' => 'Military training', ], [ 'eyebrow' => 'Emergency services', 'title' => 'Firefighters', 'excerpt' => "Structure fires, hazmat, multi-casualty triage, confined-space rescue, industrial accidents. Built for first responders who can't rehearse the worst day at full scale.", 'href' => '/industries/firefighters/', 'cta' => 'Firefighter training', ], ]; $card_ids = []; foreach ($industries as $i => $_) { $card_ids[$i] = [ 'card' => av_brx_id(), 'eyebrow' => av_brx_id(), 'title' => av_brx_id(), 'excerpt' => av_brx_id(), 'btn' => av_brx_id(), ]; } $cards_children = array_map(fn($ids) => $ids['card'], $card_ids); /* ---- assemble flat element array ---- */ $elements = []; // 1. Hero section ---------------------------------------------------- $elements[] = [ 'id' => $hero_section_id, 'name' => 'section', 'parent' => 0, 'children' => [$hero_container_id], 'settings' => ['_cssClasses' => 'av-hero'], 'label' => 'Hero', ]; $elements[] = [ 'id' => $hero_container_id, 'name' => 'container', 'parent' => $hero_section_id, 'children' => [$hero_eyebrow_id, $hero_h1_id, $hero_sub_id], 'settings' => ['_cssClasses' => 'av-container av-hero__inner'], ]; $elements[] = [ 'id' => $hero_eyebrow_id, 'name' => 'text-basic', 'parent' => $hero_container_id, 'settings' => [ 'text' => 'Industries', 'tag' => 'p', '_cssClasses' => 'av-hero__eyebrow', ], ]; $elements[] = [ 'id' => $hero_h1_id, 'name' => 'heading', 'parent' => $hero_container_id, 'settings' => [ 'tag' => 'h1', 'text' => 'Built with operators, for operators.', '_cssClasses' => 'av-hero__headline', ], ]; $elements[] = [ 'id' => $hero_sub_id, 'name' => 'text-basic', 'parent' => $hero_container_id, 'settings' => [ 'text' => 'PROSERVE™ is not a generic VR platform repackaged for the public sector. Every scenario, every weapon profile, every instructor metric was specified by serving and former operators in close partnership with our engineering team.', 'tag' => 'p', '_cssClasses' => 'av-hero__sub', ], ]; // 2. Cards section --------------------------------------------------- $elements[] = [ 'id' => $cards_section_id, 'name' => 'section', 'parent' => 0, 'children' => [$cards_container_id], 'settings' => ['_cssClasses' => 'av-section'], 'label' => 'Industries grid', ]; $elements[] = [ 'id' => $cards_container_id, 'name' => 'container', 'parent' => $cards_section_id, 'children' => [$cards_grid_id], 'settings' => ['_cssClasses' => 'av-container'], ]; $elements[] = [ 'id' => $cards_grid_id, 'name' => 'block', 'parent' => $cards_container_id, 'children' => $cards_children, 'settings' => ['_cssClasses' => 'av-grid-4'], ]; foreach ($industries as $i => $ind) { $ids = $card_ids[$i]; $elements[] = [ 'id' => $ids['card'], 'name' => 'block', 'parent' => $cards_grid_id, 'children' => [$ids['eyebrow'], $ids['title'], $ids['excerpt'], $ids['btn']], 'settings' => ['_cssClasses' => 'av-card'], 'label' => $ind['title'], ]; $elements[] = [ 'id' => $ids['eyebrow'], 'name' => 'text-basic', 'parent' => $ids['card'], 'settings' => [ 'text' => $ind['eyebrow'], 'tag' => 'p', '_cssClasses' => 'av-card__eyebrow', ], ]; $elements[] = [ 'id' => $ids['title'], 'name' => 'heading', 'parent' => $ids['card'], 'settings' => [ 'tag' => 'h2', 'text' => $ind['title'], '_cssClasses' => 'av-card__title', ], ]; $elements[] = [ 'id' => $ids['excerpt'], 'name' => 'text-basic', 'parent' => $ids['card'], 'settings' => [ 'text' => $ind['excerpt'], 'tag' => 'p', '_cssClasses' => 'av-card__excerpt', ], ]; $elements[] = [ 'id' => $ids['btn'], 'name' => 'button', 'parent' => $ids['card'], 'settings' => [ 'text' => $ind['cta'], 'tag' => 'a', 'link' => [ 'type' => 'external', 'url' => $home_url . ltrim($ind['href'], '/'), ], '_cssClasses' => 'av-btn av-btn--secondary av-btn--md', ], ]; } return $elements; }