'; // 1) Logo. if ( $has_logo ) { $custom_logo_id = (int) get_theme_mod( 'custom_logo' ); $logo = wp_get_attachment_image( $custom_logo_id, 'full', false, array( 'class' => 'site-logo', 'style' => 'max-height:var(--bt-logo-h);height:auto;width:auto;', 'loading' => 'eager', 'decoding' => 'async', ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo ''; } // 2) Title. if ( $show_title ) { $tag = ( is_front_page() && is_home() ) ? 'h1' : 'p'; echo '
'; echo '<' . esc_attr( $tag ) . ' class="bt-text-logo site-title" style="margin:0;font-weight:800;font-size:1.15rem;line-height:1.2;">'; echo ''; echo esc_html( get_bloginfo( 'name' ) ); echo ''; echo ''; echo '
'; } // 3) Tagline. if ( $show_tagline ) { $desc = get_bloginfo( 'description', 'display' ); if ( $desc ) { echo '
'; echo '

' . esc_html( $desc ) . '

'; echo '
'; } } echo ''; // .site-branding.bt-brand-grid } /** * Document title: append tagline with an em dash for context. */ add_filter( 'pre_get_document_title', function ( $title ) { $desc = trim( get_bloginfo( 'description', 'display' ) ); if ( $desc === '' ) { return $title; } if ( is_front_page() || is_home() ) { return get_bloginfo( 'name' ) . ' — ' . $desc; } return $title . ' — ' . $desc; } ); /* ------------------------------------------------------------------------- * Navigation * ------------------------------------------------------------------------- */ /** * Primary menu with fallback link to Menus screen. */ function bongoto_woocommerce_primary_menu() { if ( has_nav_menu( 'primary' ) ) { wp_nav_menu( array( 'theme_location' => 'primary', 'container' => 'nav', 'container_class' => 'primary-nav', 'menu_class' => 'menu', 'depth' => 3, 'fallback_cb' => false, 'link_before' => '', 'link_after' => '', ) ); } else { echo ''; } } /* ------------------------------------------------------------------------- * WooCommerce / account helpers * ------------------------------------------------------------------------- */ function bongoto_woocommerce_is_logged_in() { return is_user_logged_in(); } /** * Get My Account URL or login URL. */ function bongoto_woocommerce_get_account_url() { if ( class_exists( 'WooCommerce' ) ) { $my = wc_get_page_permalink( 'myaccount' ); if ( $my ) { return $my; } } return wp_login_url(); } /** * Get cart URL. */ function bongoto_woocommerce_get_cart_url() { if ( class_exists( 'WooCommerce' ) ) { return wc_get_cart_url(); } return home_url( '/' ); } /** * Get cart item count. */ function bongoto_woocommerce_get_cart_count() { if ( class_exists( 'WooCommerce' ) && function_exists( 'WC' ) && WC()->cart ) { return (int) WC()->cart->get_cart_contents_count(); } return 0; } /** * Header CTA payload based on user state. * * Single store focus: * - Logged-in users → "My Account" * - Guests → "Sign In" */ function bongoto_woocommerce_get_header_cta() { if ( bongoto_woocommerce_is_logged_in() ) { $out = array( 'label' => __( 'My Account', 'bongoto-woocommerce' ), 'url' => bongoto_woocommerce_get_account_url(), 'icon' => 'account', ); } else { $out = array( 'label' => __( 'Sign In', 'bongoto-woocommerce' ), 'url' => bongoto_woocommerce_get_account_url(), 'icon' => 'account', ); } /** * Filter: bongoto_woocommerce/header_cta * * @param array $out { * @type string $label Button label. * @type string $url Target URL. * @type string $icon Icon key. * } */ return (array) apply_filters( 'bongoto_woocommerce/header_cta', $out ); } /* ------------------------------------------------------------------------- * Icons (inline SVG) * ------------------------------------------------------------------------- */ function bongoto_woocommerce_icon( $name, $attrs = array() ) { $defaults = array( 'width' => 20, 'height' => 20, 'class' => 'bt-icon', 'aria-hidden' => 'true', 'focusable' => 'false', ); $attrs = wp_parse_args( $attrs, $defaults ); $attr_html = ''; foreach ( $attrs as $k => $v ) { $attr_html .= ' ' . esc_attr( $k ) . '="' . esc_attr( $v ) . '"'; } $path = ''; switch ( $name ) { case 'search': $path = ''; break; case 'account': $path = ''; break; case 'cart': $path = ''; break; case 'upload': $path = ''; break; default: $path = ''; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo '' . $path . ''; } /* ------------------------------------------------------------------------- * Header components loader * ------------------------------------------------------------------------- */ function bongoto_woocommerce_header_component( $slug, $args = array() ) { $allowed = array( 'logo', 'site-title', 'tagline', 'primary-menu', 'search', 'cta-button', 'account', 'cart', 'upload' ); if ( ! in_array( $slug, $allowed, true ) ) { return; } if ( ! empty( $args ) ) { set_query_var( 'bongoto_component_args', $args ); } get_template_part( 'template-parts/headers/components/' . $slug ); if ( isset( $GLOBALS['bongoto_component_args'] ) ) { unset( $GLOBALS['bongoto_component_args'] ); } } /* ------------------------------------------------------------------------- * Breadcrumbs (very lightweight) * ------------------------------------------------------------------------- */ function bongoto_woocommerce_breadcrumbs() { if ( is_front_page() ) { return; } echo ''; } /* ------------------------------------------------------------------------- * Elementor presence helper * ------------------------------------------------------------------------- */ function bongoto_woocommerce_is_elementor_active() { return (bool) did_action( 'elementor/loaded' ); }