';
/* 1) Logo (grid: col 1, rows 1–2) */
if ( $has_logo ) {
$custom_logo_id = 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 '' . $logo . '';
}
/* 2) Title (grid: has-logo => col 2/row 1 (center); no-logo => col 1/row 1) */
if ( $show_title ) {
$tag = ( is_front_page() && is_home() ) ? 'h1' : 'p';
echo '
';
}
/* 3) Tagline (grid: has-logo => start under logo, span to right; no-logo => row 2, full width) */
if ( $show_tagline ) {
$desc = get_bloginfo( 'description', 'display' );
if ( $desc ) {
echo '';
echo '
';
echo esc_html( $desc );
echo '
';
echo '
';
}
}
echo ''; // .site-branding.bt-brand-grid
}
/* Browser tab: append tagline so hover shows full text */
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 ---------------- */
function bongoto_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 '';
}
}
/* ---------------- Woo/Dokan aware helpers ---------------- */
function bongoto_is_logged_in() { return is_user_logged_in(); }
function bongoto_is_user_seller( $user_id = 0 ) {
$user_id = $user_id ? (int) $user_id : get_current_user_id();
if ( function_exists( 'dokan_is_user_seller' ) && dokan_is_user_seller( $user_id ) ) return true;
if ( function_exists( 'dokan_is_seller_enabled' ) && dokan_is_seller_enabled( $user_id ) ) return true;
$u = get_user_by( 'id', $user_id );
if ( $u instanceof WP_User ) {
if ( user_can( $u, 'edit_products' ) || user_can( $u, 'publish_products' ) ) return true;
$maybe = array( 'seller','vendor','shop_vendor','dokan_seller' );
if ( array_intersect( $maybe, (array) $u->roles ) ) return true;
}
return false;
}
function bongoto_get_account_url() {
if ( class_exists( 'WooCommerce' ) ) {
$my = wc_get_page_permalink( 'myaccount' );
if ( $my ) return $my;
}
return wp_login_url();
}
function bongoto_get_cart_url() {
if ( class_exists( 'WooCommerce' ) ) return wc_get_cart_url();
return home_url( '/' );
}
function bongoto_get_cart_count() {
if ( class_exists( 'WooCommerce' ) && function_exists( 'WC' ) && WC()->cart ) {
return (int) WC()->cart->get_cart_contents_count();
}
return 0;
}
function bongoto_get_upload_url() {
if ( class_exists( 'WeDevs_Dokan' ) && function_exists( 'dokan_get_navigation_url' ) ) {
return dokan_get_navigation_url( 'new-product' );
}
if ( current_user_can( 'edit_products' ) ) {
return admin_url( 'post-new.php?post_type=product' );
}
return bongoto_get_account_url();
}
function bongoto_get_start_selling_url() {
if ( function_exists( 'dokan_get_page_url' ) ) {
$dash = dokan_get_page_url( 'dashboard', 'dokan' );
if ( $dash ) return $dash;
}
$my = bongoto_get_account_url();
return add_query_arg( array( 'become_vendor' => '1' ), $my );
}
function bongoto_get_header_cta() {
if ( bongoto_is_logged_in() && bongoto_is_user_seller() ) {
$out = array( 'label' => __( 'Upload', 'bongoto' ), 'url' => bongoto_get_upload_url(), 'icon' => 'upload' );
} else {
$out = array( 'label' => __( 'Start Selling', 'bongoto' ), 'url' => bongoto_get_start_selling_url(), 'icon' => 'upload' );
}
return apply_filters( 'bongoto/header_cta', $out );
}
/* ---------------- Icons ---------------- */
function bongoto_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 '';
}
/* ---------------- Header components loader ---------------- */
function bongoto_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 ---------------- */
function bongoto_breadcrumbs() {
if ( is_front_page() ) return;
echo '';
}
/* ---------------- Elementor presence helper ---------------- */
function bongoto_is_elementor_active() { return did_action( 'elementor/loaded' ); }