'; // Custom logo (falls back to site name if not set). if ( function_exists( 'the_custom_logo' ) && has_custom_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:' . esc_attr( bongoto_logo_max_height() ) . 'px; height:auto; width:auto;', 'loading' => 'eager', 'decoding' => 'async', ) ); $home = esc_url( home_url( '/' ) ); echo '' . wp_kses_post( $logo ) . ''; } else { // Text-only site name as logo fallback. $home = esc_url( home_url( '/' ) ); echo '' . esc_html( get_bloginfo( 'name' ) ) . ''; } // Site title (toggle-able). if ( bongoto_show_site_title() ) { $tag = ( is_front_page() && is_home() ) ? 'h1' : 'p'; echo '<' . $tag . ' class="site-title" style="margin:0;">'; echo '' . esc_html( get_bloginfo( 'name' ) ) . ''; echo '' . $tag . '>'; $desc = get_bloginfo( 'description', 'display' ); if ( $desc ) { echo '
' . esc_html( $desc ) . '
'; } } echo ''; } /** * ------------------------------------------------------------------------- * 2) Menus / Navigation * ------------------------------------------------------------------------- */ /** * Render primary navigation menu. */ 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 { // Simple fallback. echo ''; } } /** * ------------------------------------------------------------------------- * 3) Roles / URLs for Account / Cart / Upload (Woo/Dokan aware) * ------------------------------------------------------------------------- */ /** * Is user logged in? * * @return bool */ function bongoto_is_logged_in() { return is_user_logged_in(); } /** * Is current user a marketplace seller/vendor? * - Dokan aware (prefers dokan helpers if present) * - Otherwise checks product edit capabilities * * @param int $user_id * @return bool */ function bongoto_is_user_seller( $user_id = 0 ) { $user_id = $user_id ? (int) $user_id : get_current_user_id(); // Dokan vendor check (safe). if ( function_exists( 'dokan_is_user_seller' ) ) { if ( dokan_is_user_seller( $user_id ) ) { return true; } } if ( function_exists( 'dokan_is_seller_enabled' ) ) { // For older dokan helpers if available. if ( dokan_is_seller_enabled( $user_id ) ) { return true; } } // Woo/product capability check as fallback. $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; } // Common vendor role slugs (defensive). $maybe_vendor_roles = array( 'seller', 'vendor', 'shop_vendor', 'dokan_seller' ); if ( array_intersect( $maybe_vendor_roles, (array) $u->roles ) ) { return true; } } return false; } /** * My Account URL (Woo aware). * * @return string */ function bongoto_get_account_url() { if ( class_exists( 'WooCommerce' ) ) { $my = wc_get_page_permalink( 'myaccount' ); if ( $my ) { return $my; } } return wp_login_url(); } /** * Cart URL (Woo aware). * * @return string */ function bongoto_get_cart_url() { if ( class_exists( 'WooCommerce' ) ) { return wc_get_cart_url(); } return home_url( '/' ); } /** * Cart count (Woo aware). * * @return int */ function bongoto_get_cart_count() { if ( class_exists( 'WooCommerce' ) && function_exists( 'WC' ) && WC()->cart ) { return (int) WC()->cart->get_cart_contents_count(); } return 0; } /** * Upload URL (Dokan vendor new-product if available). * * @return string */ function bongoto_get_upload_url() { // Dokan frontend product upload. if ( class_exists( 'WeDevs_Dokan' ) && function_exists( 'dokan_get_navigation_url' ) ) { return dokan_get_navigation_url( 'new-product' ); } // If user has capability to create products, send to wp-admin (fallback). if ( current_user_can( 'edit_products' ) ) { return admin_url( 'post-new.php?post_type=product' ); } // Otherwise encourage login / account. return bongoto_get_account_url(); } /** * Start Selling URL for guests/customers. * - If Dokan exists → dashboard (it will route to login/register/wizard) * - Else → Woo My Account with a become_vendor hint (safe fallback) * * @return string */ function bongoto_get_start_selling_url() { // Dokan dashboard/login. if ( function_exists( 'dokan_get_page_url' ) ) { $dash = dokan_get_page_url( 'dashboard', 'dokan' ); if ( $dash ) { return $dash; } } // Woo my account with a gentle hint (non-breaking fallback). $my = bongoto_get_account_url(); return add_query_arg( array( 'become_vendor' => '1' ), $my ); } /** * Header CTA (label + url) based on role/state. * - Seller → Upload * - Guest/Customer → Start Selling * * @return array{label:string,url:string,icon:string} */ 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', // reuse upload icon; can be filtered ); } /** * Filter: allow plugins (Pro) to override CTA. * * @param array $out */ return apply_filters( 'bongoto/header_cta', $out ); } /** * ------------------------------------------------------------------------- * 4) Icons (inline SVG) * ------------------------------------------------------------------------- */ /** * Render a small inline SVG icon. * * @param string $name search|account|cart|upload * @param array $attrs Additional attributes (class, width, height) */ 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 = '