File: /var/www/html/wp-content/themes/thegem-elementor/inc/ethnic-megamenu.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'ethnic_megamenu_should_load' ) ) {
function ethnic_megamenu_should_load() {
return ! is_admin();
}
}
if ( ! function_exists( 'ethnic_megamenu_presets' ) ) {
function ethnic_megamenu_presets() {
return array(
'what-we-do' => array(
'mode' => 'root',
'eyebrow' => 'What We Do',
'heading' => 'Services and industries in one simpler navigation layer.',
'description' => 'Use the service explorer for delivery tracks, and browse industries as a lighter grouped list.',
'card_meta' => 'Open',
'cta_url' => home_url( '/contact-us/' ),
'cta_text' => 'Book a Consultation',
'promo_title' => 'Need a roadmap for the right delivery model?',
'promo_copy' => 'Talk with our team about product scope, tech stack, delivery stages, and what to prioritize first.',
'promo_tags' => array( 'Discovery workshop', 'Architecture input', 'Delivery planning' ),
'section_descriptions' => array(
'services' => 'Choose a delivery track on the left and review the relevant capabilities, platforms, and support areas in the main panel.',
'industries' => 'Browse the sectors where we bring delivery, modernization, platform, and product experience.',
'app-development-services' => 'Launch native and cross-platform apps with the right architecture, delivery plan, and support model for your roadmap.',
'ecommerce-development' => 'Cover storefront builds, platform work, migrations, and growth-focused commerce delivery from one track.',
'ai-ml' => 'Apply automation, intelligence, and data-led workflows where they improve product experience and team efficiency.',
'devops' => 'Strengthen release confidence, observability, infrastructure, and delivery operations with the right engineering foundations.',
'game-development' => 'Support game production with the technical delivery layers needed for launch, scale, and ongoing improvement.',
'blockchain' => 'Focus on practical blockchain initiatives with product fit, security, and maintainability built into the delivery model.',
),
'groups' => array(
'services' => array(
'mode' => 'tabs',
'span' => 'wide',
),
'industries' => array(
'mode' => 'collection',
'span' => 'narrow',
),
),
),
'what-we-think' => array(
'mode' => 'root',
'eyebrow' => 'What We Think',
'heading' => 'News, case studies, and resources without the extra visual noise.',
'description' => 'Quick links stay easy to reach, while deeper collections remain available inside the same panel.',
'card_meta' => 'Open',
'cta_url' => home_url( '/contact-us/' ),
'cta_text' => 'Talk to Our Team',
'promo_title' => 'Want examples closer to your business model?',
'promo_copy' => 'We can point you to the most relevant case studies, delivery examples, and practical insights for your goals.',
'promo_tags' => array( 'Case study guidance', 'Industry context', 'Solution fit' ),
'section_descriptions' => array(
'news' => 'Follow launches, updates, company news, and the latest announcements from our team.',
'case-study' => 'Review delivery examples framed around the challenge, approach, and business outcome.',
'resources' => 'Access practical articles, guides, and reference material for digital product and technology teams.',
),
'groups' => array(
'news' => array(
'mode' => 'quick',
),
'case-study' => array(
'mode' => 'collection',
'span' => 'wide',
),
'resources' => array(
'mode' => 'quick',
),
),
),
'who-we-are' => array(
'mode' => 'root',
'eyebrow' => 'Who We Are',
'heading' => 'Company and contact links organized into a clearer structure.',
'description' => 'About and contact sections keep their existing child links, now grouped under one simpler parent.',
'card_meta' => 'Open',
'cta_url' => home_url( '/contact-us/' ),
'cta_text' => 'Start a Conversation',
'promo_title' => 'Planning a new project or exploring a partnership?',
'promo_copy' => 'Reach out for proposals, discovery calls, or a quick conversation about where your initiative should start.',
'promo_tags' => array( 'Request a proposal', 'Schedule a call', 'Talk to delivery team' ),
'section_descriptions' => array(
'about-us' => 'Learn how we work, what we value, and the teams behind our delivery approach.',
'contact-us' => 'Reach the right team for discovery calls, project discussions, proposals, or partnership conversations.',
),
'groups' => array(
'about-us' => array(
'mode' => 'collection',
'span' => 'half',
),
'contact-us' => array(
'mode' => 'collection',
'span' => 'half',
),
),
),
);
}
}
if ( ! function_exists( 'ethnic_megamenu_build_tree_from_items' ) ) {
function ethnic_megamenu_build_tree_from_items( $items ) {
$tree = array(
'roots' => array(),
'lookup' => array(),
'targets' => array(),
);
if ( empty( $items ) || is_wp_error( $items ) ) {
return $tree;
}
foreach ( $items as $item ) {
$item->ethnic_children = array();
$tree['lookup'][ $item->ID ] = $item;
}
foreach ( $items as $item ) {
$parent_id = (int) $item->menu_item_parent;
if ( $parent_id && isset( $tree['lookup'][ $parent_id ] ) ) {
$tree['lookup'][ $parent_id ]->ethnic_children[] = $item;
} else {
$tree['roots'][ $item->ID ] = $item;
}
}
$presets = ethnic_megamenu_presets();
foreach ( $tree['roots'] as $root ) {
$slug = sanitize_title( $root->title );
if ( isset( $presets[ $slug ] ) && ! empty( $root->ethnic_children ) ) {
$tree['targets'][ (int) $root->ID ] = $slug;
}
}
return $tree;
}
}
if ( ! function_exists( 'ethnic_megamenu_menu_tree' ) ) {
function ethnic_megamenu_menu_tree() {
if ( isset( $GLOBALS['ethnic_megamenu_current_tree'] ) && is_array( $GLOBALS['ethnic_megamenu_current_tree'] ) ) {
return $GLOBALS['ethnic_megamenu_current_tree'];
}
return array(
'roots' => array(),
'lookup' => array(),
'targets' => array(),
);
}
}
if ( ! function_exists( 'ethnic_megamenu_get_target_slug' ) ) {
function ethnic_megamenu_get_target_slug( $item_id ) {
$tree = ethnic_megamenu_menu_tree();
return isset( $tree['targets'][ (int) $item_id ] ) ? $tree['targets'][ (int) $item_id ] : '';
}
}
if ( ! function_exists( 'ethnic_megamenu_get_item' ) ) {
function ethnic_megamenu_get_item( $item_id ) {
$tree = ethnic_megamenu_menu_tree();
return isset( $tree['lookup'][ (int) $item_id ] ) ? $tree['lookup'][ (int) $item_id ] : null;
}
}
if ( ! function_exists( 'ethnic_megamenu_is_clickable' ) ) {
function ethnic_megamenu_is_clickable( $url ) {
return ! empty( $url ) && '#' !== trim( $url );
}
}
if ( ! function_exists( 'ethnic_megamenu_item_url' ) ) {
function ethnic_megamenu_item_url( $item ) {
$url = isset( $item->url ) ? $item->url : '';
if ( function_exists( 'ethnic_case_studies_menu_item_is_archive_link' ) && ethnic_case_studies_menu_item_is_archive_link( $item ) ) {
return function_exists( 'ethnic_case_studies_archive_url' ) ? ethnic_case_studies_archive_url() : home_url( '/case-studies/' );
}
return $url;
}
}
if ( ! function_exists( 'ethnic_megamenu_item_title_text' ) ) {
function ethnic_megamenu_item_title_text( $item ) {
if ( function_exists( 'ethnic_case_studies_menu_item_is_archive_link' ) && ethnic_case_studies_menu_item_is_archive_link( $item ) ) {
return 'Case Studies';
}
return isset( $item->title ) ? $item->title : '';
}
}
if ( ! function_exists( 'ethnic_megamenu_item_description' ) ) {
function ethnic_megamenu_item_description( $item, $preset ) {
$descriptions = isset( $preset['link_descriptions'] ) && is_array( $preset['link_descriptions'] ) ? $preset['link_descriptions'] : array();
$key = sanitize_title( $item->title );
return isset( $descriptions[ $key ] ) ? $descriptions[ $key ] : '';
}
}
if ( ! function_exists( 'ethnic_megamenu_item_summary' ) ) {
function ethnic_megamenu_item_summary( $item, $preset ) {
$native_description = isset( $item->description ) ? trim( wp_strip_all_tags( $item->description ) ) : '';
if ( '' !== $native_description ) {
return $native_description;
}
$descriptions = isset( $preset['section_descriptions'] ) && is_array( $preset['section_descriptions'] ) ? $preset['section_descriptions'] : array();
$key = sanitize_title( isset( $item->title ) ? $item->title : '' );
if ( isset( $descriptions[ $key ] ) ) {
return $descriptions[ $key ];
}
if ( ! empty( $item->ethnic_children ) ) {
return sprintf( 'Explore the links and focus areas available under %s.', $item->title );
}
return '';
}
}
if ( ! function_exists( 'ethnic_megamenu_group_preset' ) ) {
function ethnic_megamenu_group_preset( $item, $preset ) {
$groups = isset( $preset['groups'] ) && is_array( $preset['groups'] ) ? $preset['groups'] : array();
$key = sanitize_title( $item->title );
return isset( $groups[ $key ] ) && is_array( $groups[ $key ] ) ? $groups[ $key ] : array();
}
}
if ( ! function_exists( 'ethnic_megamenu_group_mode' ) ) {
function ethnic_megamenu_group_mode( $item, $preset ) {
$group_preset = ethnic_megamenu_group_preset( $item, $preset );
if ( ! empty( $group_preset['mode'] ) ) {
return $group_preset['mode'];
}
if ( empty( $item->ethnic_children ) ) {
return 'quick';
}
foreach ( $item->ethnic_children as $child_item ) {
if ( ! empty( $child_item->ethnic_children ) ) {
return 'tabs';
}
}
return 'collection';
}
}
if ( ! function_exists( 'ethnic_megamenu_group_span' ) ) {
function ethnic_megamenu_group_span( $item, $preset ) {
$group_preset = ethnic_megamenu_group_preset( $item, $preset );
return ! empty( $group_preset['span'] ) ? $group_preset['span'] : 'wide';
}
}
if ( ! function_exists( 'ethnic_megamenu_render_group_title' ) ) {
function ethnic_megamenu_render_group_title( $item ) {
$title = ethnic_megamenu_item_title_text( $item );
$url = ethnic_megamenu_item_url( $item );
$is_link = ethnic_megamenu_is_clickable( $url );
ob_start();
?>
<div class="ethnic-mega-panel__group-title">
<?php if ( $is_link ) : ?>
<a class="ethnic-mega-panel__group-title-link" href="<?php echo esc_url( $url ); ?>">
<span><?php echo esc_html( $title ); ?></span>
</a>
<?php else : ?>
<span><?php echo esc_html( $title ); ?></span>
<?php endif; ?>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_section_intro' ) ) {
function ethnic_megamenu_render_section_intro( $item, $preset, $kicker = '' ) {
$summary = ethnic_megamenu_item_summary( $item, $preset );
ob_start();
?>
<div class="ethnic-mega-panel__section-copy ethnic-mega-panel__section-copy--feature">
<?php if ( $kicker ) : ?>
<span class="ethnic-mega-panel__section-kicker"><?php echo esc_html( $kicker ); ?></span>
<?php endif; ?>
<?php echo ethnic_megamenu_render_group_title( $item ); ?>
<?php if ( $summary ) : ?>
<p class="ethnic-mega-panel__section-summary"><?php echo esc_html( $summary ); ?></p>
<?php endif; ?>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_quick_link' ) ) {
function ethnic_megamenu_render_quick_link( $item ) {
$title = ethnic_megamenu_item_title_text( $item );
$url = ethnic_megamenu_item_url( $item );
$is_link = ethnic_megamenu_is_clickable( $url );
$tag = $is_link ? 'a' : 'div';
ob_start();
?>
<<?php echo $tag; ?> class="ethnic-mega-panel__quick-link<?php echo $is_link ? '' : ' is-static'; ?>"<?php echo $is_link ? ' href="' . esc_url( $url ) . '"' : ''; ?>>
<span class="ethnic-mega-panel__quick-link-text"><?php echo esc_html( $title ); ?></span>
</<?php echo $tag; ?>>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_item_slug' ) ) {
function ethnic_megamenu_item_slug( $item, $prefix = '' ) {
$title = isset( $item->title ) ? $item->title : '';
$id = isset( $item->ID ) ? (int) $item->ID : 0;
$slug = sanitize_title( $title . '-' . $id );
if ( $prefix ) {
$slug = sanitize_title( $prefix . '-' . $slug );
}
return $slug;
}
}
if ( ! function_exists( 'ethnic_megamenu_render_root_nav_button' ) ) {
function ethnic_megamenu_render_root_nav_button( $item, $is_active = false, $prefix = 'root' ) {
$tab_slug = ethnic_megamenu_item_slug( $item, $prefix );
ob_start();
?>
<button
type="button"
class="ethnic-mega-panel__side-tab<?php echo $is_active ? ' is-active' : ''; ?>"
role="tab"
data-ethnic-tab="<?php echo esc_attr( $tab_slug ); ?>"
aria-selected="<?php echo $is_active ? 'true' : 'false'; ?>"
>
<span class="ethnic-mega-panel__side-tab-copy">
<span class="ethnic-mega-panel__side-tab-title"><?php echo esc_html( ethnic_megamenu_item_title_text( $item ) ); ?></span>
</span>
<span class="ethnic-mega-panel__side-tab-indicator" aria-hidden="true"></span>
</button>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_root_collection_pane' ) ) {
function ethnic_megamenu_render_root_collection_pane( $item, $preset ) {
$children = ! empty( $item->ethnic_children ) ? $item->ethnic_children : array();
$items = ! empty( $children ) ? $children : array( $item );
$modifier = 1 === count( $items ) ? 'ethnic-mega-panel__link-grid--single' : 'ethnic-mega-panel__link-grid--list';
ob_start();
?>
<?php echo ethnic_megamenu_render_section_intro( $item, $preset ); ?>
<?php echo ethnic_megamenu_render_cards_grid( $items, $preset, $modifier ); ?>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_root_tabs_pane' ) ) {
function ethnic_megamenu_render_root_tabs_pane( $item, $preset ) {
$children = ! empty( $item->ethnic_children ) ? $item->ethnic_children : array();
if ( empty( $children ) ) {
return '';
}
ob_start();
?>
<div class="ethnic-mega-panel__nested-layout" data-ethnic-tab-group>
<div class="ethnic-mega-panel__subnav" role="tablist" aria-label="<?php echo esc_attr( $item->title ); ?> categories">
<?php foreach ( $children as $index => $child_item ) : ?>
<?php echo ethnic_megamenu_render_root_nav_button( $child_item, 0 === $index, 'sub' ); ?>
<?php endforeach; ?>
</div>
<div class="ethnic-mega-panel__subcontent">
<?php foreach ( $children as $index => $child_item ) : ?>
<?php
$tab_slug = ethnic_megamenu_item_slug( $child_item, 'sub' );
$links = ! empty( $child_item->ethnic_children ) ? $child_item->ethnic_children : array( $child_item );
?>
<section
class="ethnic-mega-panel__pane<?php echo 0 === $index ? ' is-active' : ''; ?>"
role="tabpanel"
data-ethnic-pane="<?php echo esc_attr( $tab_slug ); ?>"
aria-hidden="<?php echo 0 === $index ? 'false' : 'true'; ?>"
>
<?php echo ethnic_megamenu_render_section_intro( $child_item, $preset ); ?>
<?php echo ethnic_megamenu_render_cards_grid( $links, $preset, 'ethnic-mega-panel__link-grid--list' ); ?>
</section>
<?php endforeach; ?>
</div>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_root_group_pane' ) ) {
function ethnic_megamenu_render_root_group_pane( $item, $preset, $mode, $is_active = false ) {
$tab_slug = ethnic_megamenu_item_slug( $item, 'root' );
ob_start();
?>
<section
class="ethnic-mega-panel__pane ethnic-mega-panel__pane--root<?php echo $is_active ? ' is-active' : ''; ?>"
role="tabpanel"
data-ethnic-pane="<?php echo esc_attr( $tab_slug ); ?>"
aria-hidden="<?php echo $is_active ? 'false' : 'true'; ?>"
>
<?php if ( 'tabs' === $mode ) : ?>
<?php echo ethnic_megamenu_render_root_tabs_pane( $item, $preset ); ?>
<?php else : ?>
<?php echo ethnic_megamenu_render_root_collection_pane( $item, $preset ); ?>
<?php endif; ?>
</section>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_root_panel' ) ) {
function ethnic_megamenu_render_root_panel( $item, $preset, $slug ) {
$children = ! empty( $item->ethnic_children ) ? $item->ethnic_children : array();
$active_index = 0;
if ( empty( $children ) ) {
return '';
}
foreach ( $children as $index => $child_item ) {
if ( 'quick' !== ethnic_megamenu_group_mode( $child_item, $preset ) ) {
$active_index = $index;
break;
}
}
ob_start();
?>
<div class="ethnic-mega-panel ethnic-mega-panel--root ethnic-mega-panel--<?php echo esc_attr( $slug ); ?>" data-ethnic-mega-panel>
<div class="ethnic-mega-panel__shell">
<div class="ethnic-mega-panel__header ethnic-mega-panel__header--simple">
<div class="ethnic-mega-panel__header-copy">
<span class="ethnic-mega-panel__eyebrow"><?php echo esc_html( $preset['eyebrow'] ); ?></span>
<h3><?php echo esc_html( $preset['heading'] ); ?></h3>
<?php if ( ! empty( $preset['description'] ) ) : ?>
<p><?php echo esc_html( $preset['description'] ); ?></p>
<?php endif; ?>
</div>
</div>
<div class="ethnic-mega-panel__layout">
<div class="ethnic-mega-panel__workspace" data-ethnic-tab-group>
<div class="ethnic-mega-panel__primary-nav" role="tablist" aria-label="<?php echo esc_attr( $item->title ); ?> sections">
<?php foreach ( $children as $index => $child_item ) : ?>
<?php echo ethnic_megamenu_render_root_nav_button( $child_item, $index === $active_index, 'root' ); ?>
<?php endforeach; ?>
</div>
<div class="ethnic-mega-panel__primary-content">
<?php foreach ( $children as $index => $child_item ) : ?>
<?php echo ethnic_megamenu_render_root_group_pane( $child_item, $preset, ethnic_megamenu_group_mode( $child_item, $preset ), $index === $active_index ); ?>
<?php endforeach; ?>
</div>
</div>
<?php if ( ! empty( $preset['promo_title'] ) ) : ?>
<?php echo ethnic_megamenu_render_promo( $preset ); ?>
<?php endif; ?>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_card' ) ) {
function ethnic_megamenu_render_card( $item, $preset ) {
$title = ethnic_megamenu_item_title_text( $item );
$url = ethnic_megamenu_item_url( $item );
$description = ethnic_megamenu_item_description( $item, $preset );
$is_link = ethnic_megamenu_is_clickable( $url );
$tag = $is_link ? 'a' : 'div';
$meta = $is_link ? '' : 'Coming soon';
ob_start();
?>
<<?php echo $tag; ?> class="ethnic-mega-panel__link-card<?php echo $is_link ? '' : ' is-static'; ?>"<?php echo $is_link ? ' href="' . esc_url( $url ) . '"' : ''; ?>>
<span class="ethnic-mega-panel__link-title"><?php echo esc_html( $title ); ?></span>
<?php if ( $description ) : ?>
<span class="ethnic-mega-panel__link-description"><?php echo esc_html( $description ); ?></span>
<?php endif; ?>
<?php if ( $meta ) : ?>
<span class="ethnic-mega-panel__link-meta"><?php echo esc_html( $meta ); ?></span>
<?php endif; ?>
</<?php echo $tag; ?>>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_tab_description' ) ) {
function ethnic_megamenu_tab_description( $item, $preset ) {
$descriptions = isset( $preset['tab_descriptions'] ) && is_array( $preset['tab_descriptions'] ) ? $preset['tab_descriptions'] : array();
$key = sanitize_title( $item->title );
return isset( $descriptions[ $key ] ) ? $descriptions[ $key ] : '';
}
}
if ( ! function_exists( 'ethnic_megamenu_render_cards_grid' ) ) {
function ethnic_megamenu_render_cards_grid( $items, $preset, $modifier = '' ) {
if ( empty( $items ) ) {
return '';
}
ob_start();
?>
<div class="ethnic-mega-panel__link-grid<?php echo $modifier ? ' ' . esc_attr( $modifier ) : ''; ?>">
<?php foreach ( $items as $child_item ) : ?>
<?php echo ethnic_megamenu_render_card( $child_item, $preset ); ?>
<?php endforeach; ?>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_promo' ) ) {
function ethnic_megamenu_render_promo( $preset ) {
$promo_tags = isset( $preset['promo_tags'] ) && is_array( $preset['promo_tags'] ) ? $preset['promo_tags'] : array();
$cta_url = isset( $preset['cta_url'] ) ? $preset['cta_url'] : home_url( '/contact-us/' );
$cta_text = isset( $preset['cta_text'] ) ? $preset['cta_text'] : 'Learn more';
ob_start();
?>
<aside class="ethnic-mega-panel__promo" aria-label="Featured callout">
<div class="ethnic-mega-panel__promo-copy">
<span class="ethnic-mega-panel__promo-kicker">Ethnic Infotech</span>
<h4><?php echo esc_html( $preset['promo_title'] ); ?></h4>
<p><?php echo esc_html( $preset['promo_copy'] ); ?></p>
<?php if ( ! empty( $promo_tags ) ) : ?>
<div class="ethnic-mega-panel__promo-tags">
<?php foreach ( $promo_tags as $tag ) : ?>
<span><?php echo esc_html( $tag ); ?></span>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<a class="ethnic-mega-panel__promo-link" href="<?php echo esc_url( $cta_url ); ?>">
<?php echo esc_html( $cta_text ); ?>
</a>
</aside>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_tabs_panel' ) ) {
function ethnic_megamenu_render_tabs_panel( $item, $preset ) {
$children = ! empty( $item->ethnic_children ) ? $item->ethnic_children : array();
if ( empty( $children ) ) {
return '';
}
ob_start();
?>
<div class="ethnic-mega-panel__tab-list" role="tablist" aria-label="<?php echo esc_attr( $item->title ); ?> categories">
<?php foreach ( $children as $index => $child_item ) : ?>
<?php $tab_slug = sanitize_title( $child_item->title ); ?>
<button
type="button"
class="ethnic-mega-panel__tab<?php echo 0 === $index ? ' is-active' : ''; ?>"
data-ethnic-tab="<?php echo esc_attr( $tab_slug ); ?>"
aria-selected="<?php echo 0 === $index ? 'true' : 'false'; ?>"
>
<?php echo esc_html( $child_item->title ); ?>
</button>
<?php endforeach; ?>
</div>
<div class="ethnic-mega-panel__content ethnic-mega-panel__content--tabs">
<div class="ethnic-mega-panel__content-main">
<div class="ethnic-mega-panel__panes">
<?php foreach ( $children as $index => $child_item ) : ?>
<?php
$tab_slug = sanitize_title( $child_item->title );
$description = ethnic_megamenu_tab_description( $child_item, $preset );
$links = ! empty( $child_item->ethnic_children ) ? $child_item->ethnic_children : array();
?>
<section
class="ethnic-mega-panel__pane<?php echo 0 === $index ? ' is-active' : ''; ?>"
role="tabpanel"
data-ethnic-pane="<?php echo esc_attr( $tab_slug ); ?>"
aria-hidden="<?php echo 0 === $index ? 'false' : 'true'; ?>"
>
<div class="ethnic-mega-panel__section-copy">
<span class="ethnic-mega-panel__section-kicker">Service track</span>
<h4><?php echo esc_html( $child_item->title ); ?></h4>
<?php if ( $description ) : ?>
<p><?php echo esc_html( $description ); ?></p>
<?php endif; ?>
</div>
<?php echo ethnic_megamenu_render_cards_grid( $links, $preset, 'ethnic-mega-panel__link-grid--services' ); ?>
</section>
<?php endforeach; ?>
</div>
</div>
<?php echo ethnic_megamenu_render_promo( $preset ); ?>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_simple_panel' ) ) {
function ethnic_megamenu_render_simple_panel( $item, $preset ) {
$children = ! empty( $item->ethnic_children ) ? $item->ethnic_children : array();
ob_start();
?>
<div class="ethnic-mega-panel__content ethnic-mega-panel__content--simple">
<div class="ethnic-mega-panel__content-main">
<?php echo ethnic_megamenu_render_cards_grid( $children, $preset ); ?>
</div>
<?php echo ethnic_megamenu_render_promo( $preset ); ?>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_render_panel' ) ) {
function ethnic_megamenu_render_panel( $item_id, $slug ) {
$presets = ethnic_megamenu_presets();
$item = ethnic_megamenu_get_item( $item_id );
if ( ! $item || empty( $presets[ $slug ] ) ) {
return '';
}
$preset = $presets[ $slug ];
$mode = isset( $preset['mode'] ) ? $preset['mode'] : 'cards';
$cta_url = isset( $preset['cta_url'] ) ? $preset['cta_url'] : home_url( '/contact-us/' );
$cta_text = isset( $preset['cta_text'] ) ? $preset['cta_text'] : 'Learn more';
if ( 'root' === $mode ) {
return ethnic_megamenu_render_root_panel( $item, $preset, $slug );
}
ob_start();
?>
<div class="ethnic-mega-panel ethnic-mega-panel--<?php echo esc_attr( $mode ); ?>" data-ethnic-mega-panel>
<div class="ethnic-mega-panel__shell">
<div class="ethnic-mega-panel__header">
<div class="ethnic-mega-panel__header-copy">
<span class="ethnic-mega-panel__eyebrow"><?php echo esc_html( $preset['eyebrow'] ); ?></span>
<h3><?php echo esc_html( $preset['heading'] ); ?></h3>
<p><?php echo esc_html( $preset['description'] ); ?></p>
</div>
<a class="ethnic-mega-panel__header-link" href="<?php echo esc_url( $cta_url ); ?>">
<?php echo esc_html( $cta_text ); ?>
</a>
</div>
<?php if ( 'tabs' === $mode ) : ?>
<?php echo ethnic_megamenu_render_tabs_panel( $item, $preset ); ?>
<?php else : ?>
<?php echo ethnic_megamenu_render_simple_panel( $item, $preset ); ?>
<?php endif; ?>
</div>
</div>
<?php
return ob_get_clean();
}
}
if ( ! function_exists( 'ethnic_megamenu_enqueue_assets' ) ) {
function ethnic_megamenu_enqueue_assets() {
if ( ! ethnic_megamenu_should_load() ) {
return;
}
$css_relative_path = '/css/ethnic-megamenu.css';
$js_relative_path = '/js/ethnic-megamenu.js';
$css_path = THEGEM_THEME_PATH . $css_relative_path;
$js_path = THEGEM_THEME_PATH . $js_relative_path;
wp_enqueue_style(
'ethnic-megamenu',
THEGEM_THEME_URI . $css_relative_path,
array(),
file_exists( $css_path ) ? filemtime( $css_path ) : THEGEM_THEME_VERSION
);
wp_enqueue_script(
'ethnic-megamenu',
THEGEM_THEME_URI . $js_relative_path,
array(),
file_exists( $js_path ) ? filemtime( $js_path ) : THEGEM_THEME_VERSION,
true
);
}
add_action( 'wp_enqueue_scripts', 'ethnic_megamenu_enqueue_assets', 35 );
}
if ( ! function_exists( 'ethnic_megamenu_capture_menu_tree' ) ) {
function ethnic_megamenu_capture_menu_tree( $items, $args ) {
if ( ! ethnic_megamenu_should_load() ) {
return $items;
}
$GLOBALS['ethnic_megamenu_current_tree'] = ethnic_megamenu_build_tree_from_items( $items );
return $items;
}
add_filter( 'wp_nav_menu_objects', 'ethnic_megamenu_capture_menu_tree', 20, 2 );
}
if ( ! function_exists( 'ethnic_megamenu_add_menu_classes' ) ) {
function ethnic_megamenu_add_menu_classes( $classes, $item, $args, $depth = 0 ) {
if ( 0 !== (int) $depth ) {
return $classes;
}
$slug = ethnic_megamenu_get_target_slug( $item->ID );
if ( ! $slug ) {
return $classes;
}
$classes[] = 'ethnic-mega-enhanced';
$classes[] = 'ethnic-mega--' . sanitize_html_class( $slug );
return $classes;
}
add_filter( 'nav_menu_css_class', 'ethnic_megamenu_add_menu_classes', 20, 4 );
}
if ( ! function_exists( 'ethnic_megamenu_link_attributes' ) ) {
function ethnic_megamenu_link_attributes( $atts, $item, $args, $depth = 0 ) {
if ( 0 !== (int) $depth ) {
return $atts;
}
$slug = ethnic_megamenu_get_target_slug( $item->ID );
if ( ! $slug ) {
return $atts;
}
$atts['data-ethnic-mega-trigger'] = sanitize_html_class( $slug );
$atts['aria-expanded'] = 'false';
$atts['aria-haspopup'] = 'true';
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'ethnic_megamenu_link_attributes', 20, 4 );
}
if ( ! function_exists( 'ethnic_megamenu_append_panel' ) ) {
function ethnic_megamenu_append_panel( $item_output, $item, $depth, $args ) {
if ( 0 !== (int) $depth ) {
return $item_output;
}
$slug = ethnic_megamenu_get_target_slug( $item->ID );
if ( ! $slug ) {
return $item_output;
}
return $item_output . ethnic_megamenu_render_panel( $item->ID, $slug );
}
add_filter( 'walker_nav_menu_start_el', 'ethnic_megamenu_append_panel', 20, 4 );
}