File: /var/www/pausfood/wp-content/plugins/frutin-core/addons/header/header.php
<?php
use \Elementor\Widget_Base;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Typography;
use \Elementor\Repeater;
use \Elementor\Utils;
use \Elementor\Group_Control_Background;
use \Elementor\Group_Control_Text_Shadow;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
/**
*
* Header Widget .
*
*/
class Frutin_Header extends Widget_Base {
public function get_name() {
return 'frutinheader';
}
public function get_title() {
return __( 'Header', 'frutin' );
}
public function get_icon() {
return 'th-icon';
}
public function get_categories() {
return [ 'frutin_header_elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'layout_section',
[
'label' => __( 'Header', 'frutin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'layout_style',
[
'label' => __( 'Layout Style', 'frutin' ),
'type' => Controls_Manager::SELECT,
'options' => [
'1' => __( 'Style One', 'frutin' ),
'2' => __( 'Style Two', 'frutin' ),
'3' => __( 'Style Three', 'frutin' ),
'4' => __( 'Style Four', 'frutin' ),
],
'default' => '1',
]
);
$this->add_control(
'show_top_bar',
[
'label' => __( 'Show Top Bar?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'layout_style' => ['1', '2', '3']
],
]
);
$this->add_control(
'topbar_slogan',
[
'label' => __( 'Topbar Slogan', 'frutin' ),
'type' => Controls_Manager::TEXTAREA,
'rows' => 2,
'default' => __( 'Orders of $50 or more qualify for free shipping!', 'frutin' ),
'condition' => [
'show_top_bar' => [ 'yes' ] ,
'layout_style' => ['1', '2', '3']
],
]
);
$this->add_control(
'topbar_phone_label',
[
'label' => __( 'Phone Label', 'frutin' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Call Us 24/7', 'frutin' ),
'label_block' => true,
'condition' => [
'show_top_bar' => ['yes'],
'layout_style' => ['3']
],
]
);
$this->add_control(
'topbar_phone',
[
'label' => __( 'Phone Number', 'frutin' ),
'type' => Controls_Manager::TEXT,
'default' => __( '((+163)-254-3654', 'frutin' ),
'label_block' => true,
'separator' => 'after',
'condition' => [
'show_top_bar' => ['yes'],
'layout_style' => ['3']
],
]
);
$this->add_control(
'topbar_extra_text',
[
'label' => __( 'Topbar Extra Text', 'frutin' ),
'type' => Controls_Manager::TEXTAREA,
'rows' => 2,
'default' => __( 'Track Your Order', 'frutin' ),
'condition' => [
'show_top_bar' => [ 'yes' ] ,
'layout_style' => ['3']
],
]
);
$this->add_control(
'topbar_extra_link',
[
'label' => __( 'Topbar Extra Link', 'frutin' ),
'type' => Controls_Manager::URL,
'placeholder' => __( 'https://your-link.com', 'frutin' ),
'show_external' => true,
'default' => [
'url' => '#',
'is_external' => false,
'nofollow' => true,
],
'condition' => [
'show_top_bar' => [ 'yes' ] ,
'layout_style' => ['3']
],
]
);
$this->add_control(
'topbar_address_icon',
[
'label' => __( 'Address Iocn', 'frutin' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => '<i class="fal fa-location-dot"></i>',
'condition' => [
'show_top_bar' => ['yes'],
'layout_style' => ['1', '2']
],
]
);
$this->add_control(
'topbar_address',
[
'label' => __( 'Address', 'frutin' ),
'type' => Controls_Manager::TEXT,
'default' => __( '8502 Preston Rd. Inglewood, Maine 98380', 'frutin' ),
'label_block' => true,
'separator' => 'after',
'condition' => [
'show_top_bar' => ['yes'],
'layout_style' => ['1', '2']
],
]
);
//Language
$this->add_control(
'show_lang',
[
'label' => __( 'Show Language?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'show_top_bar' => ['yes'],
'layout_style' => ['3']
],
]
);
$this->add_control(
'show_currency',
[
'label' => __( 'Show Currency Switcher?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'show_top_bar' => ['yes'],
'layout_style' => ['3']
],
]
);
//Social
$this->add_control(
'show_social',
[
'label' => __( 'Show Social?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
'separator' => 'before',
'condition' => [
'show_top_bar' => ['yes'],
'layout_style' => ['1', '2', '3']
],
]
);
$this->add_control(
'social_text',
[
'label' => __( 'Social Text', 'frutin' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'condition' => [
'show_social' => 'yes',
'show_top_bar' => ['yes'],
'layout_style' => ['1', '2', '3']
],
]
);
$repeater = new Repeater();
$repeater->add_control(
'social_icon',
[
'label' => __( 'Social Icon', 'frutin' ),
'type' => Controls_Manager::ICONS,
'default' => [
'value' => 'fab fa-facebook-f',
'library' => 'solid',
],
]
);
$repeater->add_control(
'icon_link',
[
'label' => __( 'Link', 'frutin' ),
'type' => Controls_Manager::URL,
'placeholder' => __( 'https://your-link.com', 'frutin' ),
'show_external' => true,
'default' => [
'url' => '#',
'is_external' => false,
'nofollow' => true,
],
]
);
$this->add_control(
'social_icon_list',
[
'label' => __( 'Social Icon', 'frutin' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'social_icon' => ['value' => 'fab fa-facebook-f', 'library' => 'solid'],
'icon_link' => ['url' => 'https://www.facebook.com', 'is_external' => false, 'nofollow' => true],
],
[
'social_icon' => ['value' => 'fab fa-twitter', 'library' => 'solid'],
'icon_link' => ['url' => 'https://www.twitter.com', 'is_external' => false, 'nofollow' => true],
],
[
'social_icon' => ['value' => 'fab fa-instagram', 'library' => 'solid'],
'icon_link' => ['url' => 'https://www.instagram.com', 'is_external' => false, 'nofollow' => true],
],
[
'social_icon' => ['value' => 'fab fa-linkedin-in', 'library' => 'solid'],
'icon_link' => ['url' => 'https://www.linkedin.com', 'is_external' => false, 'nofollow' => true],
],
[
'social_icon' => ['value' => 'fab fa-pinterest-p', 'library' => 'solid'],
'icon_link' => ['url' => 'https://pinterest.com', 'is_external' => false, 'nofollow' => true],
],
],
'condition' => [
'show_social' => 'yes',
'show_top_bar' => ['yes'],
'layout_style' => ['1', '2', '3']
],
]
);
$this->add_control(
'logo_image',
[
'label' => __( 'Upload Logo', 'frutin' ),
'type' => Controls_Manager::MEDIA,
]
);
$menus = $this->frutin_menu_select();
if( !empty( $menus ) ){
$this->add_control(
'frutin_menu_select',
[
'label' => __( 'Select Frutin Menu', 'frutin' ),
'type' => Controls_Manager::SELECT,
'options' => $menus,
'description' => sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to manage your menus.', 'frutin' ), admin_url( 'nav-menus.php' ) ),
]
);
}else {
$this->add_control(
'no_menu',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => '<strong>' . __( 'There are no menus in your site.', 'frutin' ) . '</strong><br>' . sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to create one.', 'frutin' ), admin_url( 'nav-menus.php?action=edit&menu=0' ) ),
'separator' => 'after',
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
]
);
}
$this->add_control(
'show_search_btn',
[
'label' => __( 'Show Search Button?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'show_offcanvas_btn',
[
'label' => __( 'Show Offcanvas Button?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'layout_style' => ['3'],
],
]
);
$this->add_control(
'show_wishlist_btn',
[
'label' => __( 'Show Wishlist Button?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
'condition' => [
'layout_style' => ['3'],
],
]
);
$this->add_control(
'show_cart_btn',
[
'label' => __( 'Show Cart Button?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'show_user_btn',
[
'label' => __( 'Show User Button?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'button_text',
[
'label' => __( 'Button Text', 'frutin' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => __( 'Shop Now', 'frutin' ),
'condition' => [
'layout_style' => ['1', '2', '4'],
],
]
);
$this->add_control(
'button_url',
[
'label' => esc_html__( 'Button Link', 'frutin' ),
'type' => Controls_Manager::URL,
'placeholder' => esc_html__( 'https://your-link.com', 'frutin' ),
'show_external' => true,
'default' => [
'url' => '#',
'is_external' => false,
'nofollow' => false,
],
'condition' => [
'layout_style' => ['1', '2', '4'],
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'header_categories',
[
'label' => __( 'Category Mega Menu', 'frutin' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'show_mega_menu',
[
'label' => __( 'Show this menu?', 'frutin' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'frutin' ),
'label_off' => __( 'Hide', 'frutin' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'category_text',
[
'label' => __( 'Category Text', 'frutin' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'default' => __( 'Browse by Categories', 'frutin' ),
]
);
$repeater = new Repeater();
$repeater->add_control(
'product_cats',
[
'label' => __( 'Product Categories', 'frutin' ),
'type' => Controls_Manager::SELECT,
'multiple' => true,
'label_block' => true,
'options' => $this->product_cats_get(),
]
);
$repeater->add_control(
'icon',
[
'label' => esc_html__('Use Custom Icon ?', 'frutin'),
'type' => Controls_Manager::MEDIA,
'dynamic' => [
'active' => true,
],
'Description' => esc_html__('If you want to use custom image for the category select here. Otherwise it will get the default image of the category', 'frutin'),
]
);
$repeater->add_control(
'mega_menu_builder_option',
[
'label' => __( 'Select Template', 'frutin' ),
'type' => Controls_Manager::SELECT,
'options' => $this->mega_menu_builder_choose_option(),
'label_block' => true,
'default' => ''
]
);
$this->add_control(
'category_list',
[
'label' => __( 'Category', 'frutin' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
]
);
$this->end_controls_section();
//---------------------------------------
//Style Section Start
//---------------------------------------
//-------General Style-------
$this->start_controls_section(
'general_styling',
[
'label' => __( 'Background Styling', 'frutin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
frutin_color_fields($this, 'topbar_bg', 'Topbar BG', '{{WRAPPER}} .header-top', 'background');
frutin_color_fields($this, 'topbar_text', 'Topbar Text Color', '{{WRAPPER}} .header-top', '--body-color');
frutin_color_fields($this, 'middle_bg', 'Middle BG', '{{WRAPPER}} .th-header', 'background', ['3']);
frutin_color_fields($this, 'menu_bg', 'Menu BG', '{{WRAPPER}} .menu-area', 'background');
frutin_color_fields($this, 'logo_bg', 'Logo BG', '{{WRAPPER}} .logo-bg:after', 'background', ['2']);
$this->end_controls_section();
//------Menu Bar Style-------
$this->start_controls_section(
'menubar_styling3',
[
'label' => __( 'Menu Styling', 'frutin' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
frutin_color_fields($this, 'menu_color', 'Color', '{{WRAPPER}} .main-menu>ul>li>a');
frutin_color_fields($this, 'menu_color2', 'Hover Color', '{{WRAPPER}} .main-menu>ul>li>a:hover');
frutin_color_fields($this, 'menu_color3', 'Dropdown Color', '{{WRAPPER}} .main-menu ul.sub-menu li a');
frutin_color_fields($this, 'menu_color4', 'Dropdown Hover Color', '{{WRAPPER}} .main-menu ul.sub-menu li a:hover');
frutin_color_fields($this, 'menu_color5', 'Menu Icon Color', '{{WRAPPER}} .main-menu ul.sub-menu li a:before');
frutin_typography_fields($this, 'menu_font', 'Menu Trpography', '{{WRAPPER}} .main-menu>ul>li>a, {{WRAPPER}} .main-menu ul.sub-menu li a');
frutin_dimensions_fields($this, 'menu_margin', 'Menu Margin', 'margin', '{{WRAPPER}} .main-menu>ul>li>a');
frutin_dimensions_fields($this, 'menu_padding', 'Menu Padding', 'padding', '{{WRAPPER}} .main-menu>ul>li>a');
$this->end_controls_section();
//------Button Style-------
frutin_button_style_fields($this, '12', 'Button Styling', '{{WRAPPER}} .th-btn');
}
public function mega_menu_builder_choose_option(){
$frutin_post_query = new WP_Query( array(
'post_type' => 'mega_menu_builder',
'posts_per_page' => -1,
) );
$frutin_mega_menu_builder_title = array();
$frutin_mega_menu_builder_title[''] = __( 'Select a Mega Menu','frutin');
while( $frutin_post_query->have_posts() ) {
$frutin_post_query->the_post();
$frutin_mega_menu_builder_title[ get_the_ID() ] = get_the_title();
}
wp_reset_postdata();
return $frutin_mega_menu_builder_title;
}
protected function product_cats_get() {
$terms = get_terms( array( 'taxonomy' => 'product_cat' ) );
$term_array = array();
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
$term_array[$term->slug] = $term->name;
}
}
return $term_array;
}
public function frutin_menu_select(){
$frutin_menu = wp_get_nav_menus();
$menu_array = array();
$menu_array[''] = __( 'Select A Menu', 'frutin' );
foreach( $frutin_menu as $menu ){
$menu_array[ $menu->slug ] = $menu->name;
}
return $menu_array;
}
protected function render() {
$settings = $this->get_settings_for_display();
global $woocommerce;
//Menu by menu select
$frutin_avaiable_menu = $this->frutin_menu_select();
if( ! $frutin_avaiable_menu ){
return;
}
$args = [
'menu' => $settings['frutin_menu_select'],
'menu_class' => 'frutin-menu',
'container' => '',
];
//Mobile menu, Offcanvas, Search
echo frutin_mobile_menu();
if(!empty( $settings['show_cart_btn'])){
echo frutin_header_cart_offcanvas();
}
if(!empty( $settings['show_offcanvas_btn'])){
echo frutin_header_offcanvas();
}
if(!empty( $settings['show_search_btn'])){
echo frutin_search_box();
}
global $woocommerce;
if( ! empty( $woocommerce->cart->cart_contents_count ) ){
$count = $woocommerce->cart->cart_contents_count;
}else{
$count = "0";
}
if ( $settings['layout_style'] == '1' ) {
echo '<div class="th-header header-layout1">';
if (!empty($settings['show_top_bar'])){
echo '<div class="header-top">';
echo '<div class="container">';
echo '<div class="row justify-content-center justify-content-lg-between align-items-center gy-2">';
if(!empty($settings['topbar_slogan'])){
echo '<div class="col-auto d-none d-lg-block">';
echo '<p class="header-notice">'.wp_kses_post($settings['topbar_slogan']).'</p>';
echo '</div>';
}
echo '<div class="col-auto">';
echo '<div class="header-links">';
echo '<ul>';
if(!empty($settings['topbar_address'])){
echo '<li class="d-none d-sm-inline-block">'.wp_kses_post($settings['topbar_address_icon'] . $settings['topbar_address']).'</li>';
}
if (!empty( $settings['show_social'])) {
echo '<li>';
echo '<div class="social-links">';
if(!empty($settings['social_text'])){
echo '<span class="social-title">'.esc_html($settings['social_text']).'</span>';
}
foreach( $settings['social_icon_list'] as $social_icon ){
$social_target = $social_icon['icon_link']['is_external'] ? ' target="_blank"' : '';
$social_nofollow = $social_icon['icon_link']['nofollow'] ? ' rel="nofollow"' : '';
echo '<a '.wp_kses_post( $social_target.$social_nofollow ).' href="'.esc_url( $social_icon['icon_link']['url'] ).'">';
\Elementor\Icons_Manager::render_icon( $social_icon['social_icon'], [ 'aria-hidden' => 'true' ] );
echo '</a> ';
}
echo '</div>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '<!-- Main Menu -->';
echo '<div class="sticky-wrapper">';
echo '<div class="menu-area">';
echo '<div class="container">';
echo '<div class="row align-items-center justify-content-between">';
echo '<div class="col-auto">';
echo '<div class="header-logo">';
echo '<a href="'.esc_url( home_url( '/' ) ).'">';
echo frutin_img_tag( array(
'url' => esc_url( $settings['logo_image']['url'] ),
));
echo '</a>';
echo '</div>';
echo '</div>';
echo '<div class="col-auto">';
echo '<nav class="main-menu d-none d-lg-inline-block">';
if( ! empty( $settings['frutin_menu_select'] ) ){
wp_nav_menu( $args );
}
echo '</nav>';
echo '<button class="th-menu-toggle d-block d-lg-none"><i class="far fa-bars"></i></button>';
echo '</div>';
echo '<div class="col-auto d-none d-xl-block">';
echo '<div class="header-button">';
if(!empty( $settings['show_search_btn'])){
echo '<button type="button" class="simple-icon searchBoxToggler"><i class="far fa-search"></i></i></button>';
}
if(!empty( $settings['show_cart_btn'])){
echo '<button type="button" class="simple-icon sideMenuCart">';
echo '<span class="badge">'.esc_html( $count ).'</span>';
echo '<i class="far fa-cart-shopping"></i>';
echo '</button>';
}
if(!empty( $settings['button_text'])){
echo '<a href="'.esc_url($settings['button_url']['url']).'" class="th-btn style4">'.wp_kses_post($settings['button_text']).'<i class="fas fa-chevrons-right ms-2"></i></a>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
} elseif ( $settings['layout_style'] == '2' ) {
echo '<div class="th-header header-layout2">';
echo '<div class="sticky-wrapper">';
echo '<div class="container">';
echo '<div class="z-index-common">';
if(!empty($settings['show_top_bar'])){
echo '<div class="header-top">';
echo '<div class="row justify-content-center justify-content-lg-between align-items-center gy-2">';
if(!empty($settings['topbar_slogan'])){
echo '<div class="col-auto d-none d-lg-block">';
echo '<p class="header-notice">'.wp_kses_post($settings['topbar_slogan']).'</p>';
echo '</div>';
}
echo '<div class="col-auto">';
echo '<div class="header-links">';
echo '<ul>';
if(!empty($settings['topbar_address'])){
echo '<li class="d-none d-xxl-inline-block">'.wp_kses_post($settings['topbar_address_icon'] . $settings['topbar_address']).'</li>';
}
if (!empty( $settings['show_social'])) {
echo '<li>';
echo '<div class="social-links">';
if(!empty($settings['social_text'])){
echo '<span class="social-title">'.esc_html($settings['social_text']).'</span>';
}
foreach( $settings['social_icon_list'] as $social_icon ){
$social_target = $social_icon['icon_link']['is_external'] ? ' target="_blank"' : '';
$social_nofollow = $social_icon['icon_link']['nofollow'] ? ' rel="nofollow"' : '';
echo '<a '.wp_kses_post( $social_target.$social_nofollow ).' href="'.esc_url( $social_icon['icon_link']['url'] ).'">';
\Elementor\Icons_Manager::render_icon( $social_icon['social_icon'], [ 'aria-hidden' => 'true' ] );
echo '</a> ';
}
echo '</div>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '<div class="menu-area">';
echo '<div class="logo-bg"></div>';
echo '<div class="row align-items-center justify-content-between">';
echo '<div class="col-auto">';
echo '<div class="header-logo">';
echo '<a href="'.esc_url( home_url( '/' ) ).'">';
echo frutin_img_tag( array(
'url' => esc_url( $settings['logo_image']['url'] ),
));
echo '</a>';
echo '</div>';
echo '</div>';
echo '<div class="col-auto">';
echo '<nav class="main-menu d-none d-lg-inline-block">';
if( ! empty( $settings['frutin_menu_select'] ) ){
wp_nav_menu( $args );
}
echo '</nav>';
echo '<button class="th-menu-toggle d-block d-lg-none"><i class="far fa-bars"></i></button>';
echo '</div>';
echo '<div class="col-auto d-none d-xl-block ms-auto">';
echo '<div class="header-button">';
if(!empty( $settings['show_search_btn'])){
echo '<button type="button" class="simple-icon searchBoxToggler"><i class="far fa-search"></i></i></button>';
}
if(!empty( $settings['show_cart_btn'])){
echo '<button type="button" class="simple-icon sideMenuCart">';
echo '<span class="badge">'.esc_html( $count ).'</span>';
echo '<i class="far fa-cart-shopping"></i>';
echo '</button>';
}
if(!empty( $settings['button_text'])){
echo '<a href="'.esc_url($settings['button_url']['url']).'" class="th-btn style4">'.wp_kses_post($settings['button_text']).'<i class="fas fa-chevrons-right ms-2"></i></a>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
} elseif ( $settings['layout_style'] == '3' ) {
$phone = $settings['topbar_phone'] ? $settings['topbar_phone'] : '';
$replace = array(' ','-',' - ');
$replace_phone = array(' ','-',' - ', '(', ')');
$with = array('','','');
$phoneurl = str_replace( $replace_phone, $with, $phone );
echo '<div class="th-header header-layout3">';
if(!empty($settings['show_top_bar'])){
echo '<div class="header-top">';
echo '<div class="container">';
echo '<div class="row justify-content-center justify-content-lg-between align-items-center gy-2">';
if(!empty($settings['topbar_slogan'])){
echo '<div class="col-auto d-none d-lg-block">';
echo '<p class="header-notice">'.wp_kses_post($settings['topbar_slogan']).'</p>';
echo '</div>';
}
echo '<div class="col-auto">';
echo '<div class="header-links">';
echo '<ul>';
if(!empty($settings['topbar_extra_text'])){
echo '<li class="d-none d-md-inline-block"><a href="'.esc_attr($settings['topbar_extra_link']['url']).'">'.wp_kses_post($settings['topbar_extra_text']).'</a></li>';
}
if (!empty( $settings['show_lang'])) {
echo '<li class="d-none d-md-inline-block">';
echo '<div class="dropdown-link">';
echo '<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink1" data-bs-toggle="dropdown" aria-expanded="true">Language</a>';
echo '<ul class="dropdown-menu" aria-labelledby="dropdownMenuLink1">';
echo do_shortcode( '[gtranslate]' );
echo '</ul>';
echo '</div>';
echo '</li>';
}
if (!empty( $settings['show_currency'])) {
echo '<li>';
echo do_shortcode('[woocommerce_currency_switcher_drop_down_box]');
echo '</li>';
}
if (!empty( $settings['show_social'])) {
echo '<li>';
echo '<div class="social-links">';
if(!empty($settings['social_text'])){
echo '<span class="social-title">'.esc_html($settings['social_text']).'</span>';
}
foreach( $settings['social_icon_list'] as $social_icon ){
$social_target = $social_icon['icon_link']['is_external'] ? ' target="_blank"' : '';
$social_nofollow = $social_icon['icon_link']['nofollow'] ? ' rel="nofollow"' : '';
echo '<a '.wp_kses_post( $social_target.$social_nofollow ).' href="'.esc_url( $social_icon['icon_link']['url'] ).'">';
\Elementor\Icons_Manager::render_icon( $social_icon['social_icon'], [ 'aria-hidden' => 'true' ] );
echo '</a> ';
}
echo '</div>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '<div class="menu-top">
<div class="container">
<div class="row align-items-center justify-content-between">
<div class="col-auto">
<div class="header-logo">';
echo '<a href="'.esc_url( home_url( '/' ) ).'">';
echo frutin_img_tag( array(
'url' => esc_url( $settings['logo_image']['url'] ),
));
echo '</a>';
echo '</div>
</div>
<div class="col-auto d-none d-lg-block">';
if(!empty( $settings['show_search_btn'])){ ?>
<form role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" class="header-search">
<input name="s" required value="<?php echo esc_html( get_search_query() ); ?>" type="search" placeholder="<?php echo esc_attr__( 'Enter Keyword', 'frutin' ); ?>">
<button type="submit"><i class="far fa-search"></i></button>
</form>
<?php } ?>
</div>
<div class="col-auto">
<div class="header-icons">
<?php
if(!empty( $settings['show_user_btn'])) {
echo '<a href="'.esc_url( home_url( '/my-account' ) ).'" class="icon-btn d-none d-sm-block"><i class="far fa-user"></i></a>';
}
if( $settings['show_wishlist_btn'] == 'yes' ){
if( class_exists( 'TInvWL_Admin_TInvWL' ) ){
echo do_shortcode('[ti_wishlist_products_counter]');
}
}
if(!empty( $settings['show_cart_btn'])){
echo '<button type="button" class="icon-btn sideMenuCart">';
echo '<span class="badge">'.esc_html( $count ).'</span>';
echo '<i class="far fa-cart-shopping"></i>';
echo '</button>';
}
if(!empty( $settings['show_offcanvas_btn'])){
echo '<button type="button" class="icon-btn sideMenuInfo d-none d-lg-block"><i class="fal fa-grid"></i></button>';
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
echo '<!-- Main Menu -->';
echo '<div class="sticky-wrapper">';
echo '<div class="menu-area">';
echo '<div class="container">';
echo '<div class="row align-items-center justify-content-between">';
if(!empty( $settings['show_mega_menu'])){
echo '<div class="col-3 d-none d-xl-block">
<div class="category-menu-wrap">
<a class="menu-expand" href="#"><i class="far fa-bars"></i>'.esc_html__($settings['category_text']).'</a>
<nav class="category-menu">
<ul>';
foreach ($settings['category_list'] as $data) {
$category_slug = $data['product_cats'];
$category = get_term_by('slug', $category_slug, 'product_cat');
if (!is_wp_error($category) && !empty($category)) {
$category_url = get_term_link($category);
if ( ! empty( $data['mega_menu_builder_option'] ) ) {
$parent_class = 'menu-item-has-children';
} else {
$parent_class = 'menu-item-no-children';
}
echo '<li class="' . esc_attr__($parent_class) . '">';
echo '<a href="' . esc_url($category_url) . '">';
if (!empty($data['icon']['url'])) {
echo frutin_img_tag(array(
'url' => esc_url($data['icon']['url']),
));
} else {
$thumbnail_id = get_term_meta($category->term_id, 'thumbnail_id', true);
$thumbnail_url = wp_get_attachment_image_url($thumbnail_id, 'thumbnail');
echo frutin_img_tag(array(
'url' => esc_url($thumbnail_url),
'class' => 'original-icon',
));
}
echo esc_html($category->name);
echo '</a>';
$elementor = \Elementor\Plugin::instance();
if( ! empty( $data['mega_menu_builder_option'] ) ){
echo '<ul class="sub-menu">';
echo $elementor->frontend->get_builder_content_for_display( $data['mega_menu_builder_option'] );
echo '</ul>';
}
echo '</li>';
}
} ?>
</ul>
</nav>
</div>
</div>
<?php }
echo '<div class="col-auto">';
echo '<nav class="main-menu menu-style1 d-none d-lg-inline-block">';
if( ! empty( $settings['frutin_menu_select'] ) ){
wp_nav_menu( $args );
}
echo '</nav>';
echo '<button class="th-menu-toggle d-block d-lg-none"><i class="far fa-bars"></i></button>';
echo '</div>';
echo '<div class="col-auto">';
echo '<div class="call-btn">
<div class="box-icon">
<i class="far fa-headphones"></i>
</div>
<div class="media-body">
<p class="box-subtitle">'.wp_kses_post($settings['topbar_phone_label']).'</p>';
echo '<h3 class="box-title"><a href="tel:'.wp_kses_post($phoneurl).'">'.wp_kses_post($phone).'</a></h3>
</div>
</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
} elseif ( $settings['layout_style'] == '4' ) {
echo '<div class="th-header header-layout4">';
echo '<div class="sticky-wrapper">';
echo '<div class="menu-area">';
echo '<div class="row align-items-center justify-content-between">';
echo '<div class="col-auto">';
echo '<div class="header-logo">';
echo '<a href="'.esc_url( home_url( '/' ) ).'">';
echo frutin_img_tag( array(
'url' => esc_url( $settings['logo_image']['url'] ),
));
echo '</a>';
echo '</div>';
echo '</div>';
echo '<div class="col-auto">';
echo '<nav class="main-menu d-none d-lg-inline-block">';
if( ! empty( $settings['frutin_menu_select'] ) ){
wp_nav_menu( $args );
}
echo '</nav>';
echo '</div>';
echo '<div class="col-auto">';
echo '<div class="header-button">';
if(!empty( $settings['show_search_btn'])){
echo '<button type="button" class="simple-icon searchBoxToggler d-none d-lg-inline-block"><i class="far fa-search"></i></i></button>';
}
if(!empty( $settings['show_cart_btn'])){
echo '<button type="button" class="simple-icon sideMenuCart">';
echo '<span class="badge">'.esc_html( $count ).'</span>';
echo '<i class="far fa-cart-shopping"></i>';
echo '</button>';
}
if(!empty( $settings['button_text'])){
echo '<a href="'.esc_url($settings['button_url']['url']).'" class="th-btn style6 d-none d-xl-inline-block">'.wp_kses_post($settings['button_text']).'<i class="fas fa-chevrons-right ms-2"></i></a>';
}
echo '<button class="th-menu-toggle d-block d-lg-none"><i class="far fa-bars"></i></button>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
}
}
}