[ 'label' => 'Header — Main', 'items' => [ ['title' => 'Solutions', 'url' => '/solutions/'], ['title' => 'Industries', 'url' => '/industries/'], ['title' => 'Technology', 'url' => '/technology/'], ['title' => 'Why Asterion', 'url' => '/why-asterion/'], ['title' => 'Insights', 'url' => '/insights/'], ], ], 'footer-nav' => [ 'label' => 'Footer — Solutions', 'items' => [ ['title' => 'Solutions', 'url' => '/solutions/'], ['title' => 'Industries', 'url' => '/industries/'], ['title' => 'Technology', 'url' => '/technology/'], ], ], 'footer-co' => [ 'label' => 'Footer — Company', 'items' => [ ['title' => 'About', 'url' => '/about/'], ['title' => 'Customers', 'url' => '/customers/'], ['title' => 'Partners', 'url' => '/partners/'], ['title' => 'Insights', 'url' => '/insights/'], ], ], 'footer-legal' => [ 'label' => 'Footer — Legal', 'items' => [ ['title' => 'Privacy', 'url' => '/privacy/'], ['title' => 'Terms', 'url' => '/terms/'], ['title' => 'Cookies', 'url' => '/cookies/'], ['title' => 'Imprint', 'url' => '/imprint/'], ], ], ]; if (! isset($blueprints[$name])) { wp_die('unknown menu blueprint : ' . esc_html($name) . '. Available : ' . implode(', ', array_keys($blueprints))); } $bp = $blueprints[$name]; $label = $bp['label']; // Idempotent : reuse existing menu if name matches $menu = wp_get_nav_menu_object($label); if (! $menu) { $menu_id = wp_create_nav_menu($label); if (is_wp_error($menu_id)) wp_die('create error : ' . $menu_id->get_error_message()); $menu = wp_get_nav_menu_object($menu_id); } else { // Wipe existing items to repush fresh $existing = wp_get_nav_menu_items($menu->term_id); foreach ($existing as $item) { wp_delete_post($item->ID, true); } } $report = ["Menu \"$label\" (term_id={$menu->term_id})"]; foreach ($bp['items'] as $i => $item) { $item_id = wp_update_nav_menu_item($menu->term_id, 0, [ 'menu-item-title' => $item['title'], 'menu-item-url' => $item['url'], 'menu-item-status' => 'publish', 'menu-item-type' => 'custom', 'menu-item-position' => $i + 1, ]); $report[] = " + {$item['title']} → {$item['url']} (item_id=$item_id)"; } header('Content-Type: text/plain; charset=utf-8'); echo implode("\n", $report); echo "\n\nUSE IN BRICKS : nav-menu element with menu = {$menu->term_id}"; exit; });