Current File : /home/kelaby89/babyl0n.restaurant/wp-content/plugins/restar-core/addons/header/header2.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 Restar_Header2 extends Widget_Base {

	public function get_name() {
		return 'restarheader2';
	}
	public function get_title() {
		return __( 'Header Two', 'restar' );
	}
	public function get_icon() {
		return 'th-icon';
    }
	public function get_categories() {
		return [ 'restar_header_elements' ];
	}

	protected function register_controls() {

		$this->start_controls_section(
			'layout_section',
			[
				'label' 	=> __( 'Header', 'restar' ),
				'tab' 		=> Controls_Manager::TAB_CONTENT,
			]
        );

		restar_select_field( $this, 'layout_style', 'Layout Style', ['Style One'] );

		$this->add_control(
			'show_top_bar',
			[
				'label' 		=> __( 'Show Top Bar?', 'restar' ),
				'type' 			=> Controls_Manager::SWITCHER,
				'label_on' 		=> __( 'Show', 'restar' ),
				'label_off' 	=> __( 'Hide', 'restar' ),
				'return_value' 	=> 'yes',
				'default' 		=> 'yes',
			]
		);

		$this->add_control(
			'phone_icon',
			[
				'label' 		=> __( 'Phone Icon', 'restar' ),
				'type' 			=> Controls_Manager::TEXT,
				'label_block' 	=> true,
				'default' 		=> '<i class="fas fa-phone"></i>',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'],
					'layout_style' => [ '1', '2']
				],
			]
		);
		$this->add_control(
			'phone',
			[
				'label' 	=> __( 'Phone Number', 'restar' ),
				'type' 		=> Controls_Manager::TEXT,
				'default' 	=> __( '+163-654-3569', 'restar' ),
				'label_block' => true,
				'separator'		=> 'after',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'], 
				],
			]
		);
		$this->add_control(
			'email_icon',
			[
				'label' 		=> __( 'Email Icon', 'restar' ),
				'type' 			=> Controls_Manager::TEXT,
				'label_block' 	=> true,
				'default' 		=> '<i class="fas fa-envelope"></i>',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'],
					'layout_style' => [ '1', '2']
				],
			]
		);
		$this->add_control(
			'email',
			[
				'label' 	=> __( 'Email Address', 'restar' ),
				'type' 		=> Controls_Manager::TEXT,
				'default' 	=> __( '[email protected]', 'restar' ),
				'label_block' => true,
				'separator'		=> 'after',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'],
				],
			]
		);
		$this->add_control(
			'address_icon',
			[
				'label' 		=> __( 'Address Icon', 'restar' ),
				'type' 			=> Controls_Manager::TEXT,
				'label_block' 	=> true,
				'default' 		=> '<i class="fas fa-location-dot"></i>',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'],
					'layout_style' => [ '1']
				],
			]
		);	
		$this->add_control(
			'address',
			[
				'label' 	=> __( 'Address', 'restar' ),
				'type' 		=> Controls_Manager::TEXT,
				'default' 	=> __( '138 MacArthur Ave, United States', 'restar' ),
				'label_block' => true,
				'separator'		=> 'after',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'],
					'layout_style' => [ '1', '3']
				],
			]
		);
		$this->add_control(
			'address_link',
			[
				'label' 		=> esc_html__( 'Address Link', 'restar' ),
				'type' 			=> Controls_Manager::URL,
				'placeholder' 	=> esc_html__( 'https://your-link.com', 'restar' ),
				'show_external' => true,
				'default' 		=> [
					'url' 			=> '#',
					'is_external' 	=> false,
					'nofollow' 		=> false,
				],
			]
		);

		$this->add_control(
			'opening_time',
			[
				'label' 	=> __( 'Opening Time', 'restar' ),
				'type' 		=> Controls_Manager::TEXTAREA,
				'default' 	=> __( '<b>Mondat to Friday:</b> 9:00am - 22:00pm', 'restar' ),
				'label_block' => true,
				'separator'		=> 'after',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'],
					'layout_style' => [ '1']
				],
			]
		);
		$this->add_control(
			'opening_icon',
			[
				'label' 		=> __( 'Opening Icon', 'restar' ),
				'type' 			=> Controls_Manager::TEXT,
				'label_block' 	=> true,
				'default' 		=> '<i class="fas fa-clock"></i>',
				'condition'		=> [ 
					'show_top_bar'  => ['yes'],
					'layout_style' => [ '1']
				],
			]
		);

		//Language 
		// $this->add_control(
		// 	'show_lang',
		// 	[
		// 		'label' 		=> __( 'Show Language?', 'restar' ),
		// 		'type' 			=> Controls_Manager::SWITCHER,
		// 		'label_on' 		=> __( 'Show', 'restar' ),
		// 		'label_off' 	=> __( 'Hide', 'restar' ),
		// 		'return_value' 	=> 'yes',
		// 		'default' 		=> 'yes',
		// 		'separator'		=> 'before',
		// 		'condition'		=> [ 
		// 			'show_top_bar'  => ['yes'],
		// 			'layout_style' => [ '1', '2'],
		// 		],
		// 	]
		// );

		//Social 
		// $this->add_control(
		// 	'show_social',
		// 	[
		// 		'label' 		=> __( 'Show Social?', 'restar' ),
		// 		'type' 			=> Controls_Manager::SWITCHER,
		// 		'label_on' 		=> __( 'Show', 'restar' ),
		// 		'label_off' 	=> __( 'Hide', 'restar' ),
		// 		'return_value' 	=> 'yes',
		// 		'default' 		=> 'yes',
		// 		'separator'		=> 'before',
		// 		'condition'		=> [ 
		// 			'show_top_bar'  => ['yes'],
		// 			'layout_style' => [ '1', '2'],
		// 		],
		// 	]
		// );

		// $this->add_control(
		// 	'social_text',
		// 	[
		// 		'label' 	=> __( 'Social Text', 'restar' ),
		// 		'type' 		=> Controls_Manager::TEXT,
		// 		'default' 	=> __( 'Follow Us:', 'restar' ),
		// 		'label_block' => true,
		// 		'condition'		=> [ 
		// 			'show_top_bar'  => ['yes'], 
		// 			'show_social'  => ['yes'], 
		// 			'layout_style' => [ '1', '2'],
		// 		],
		// 	]
		// );

		// restar_social_fields($this, 'social_lists', 'Social Lists', ['1', '2']);

		$this->add_control(
			'logo_image',

			[
				'label' 		=> __( 'Upload Logo', 'restar' ),
				'type' 			=> Controls_Manager::MEDIA,
			]
		);				

		$menus = $this->restar_menu_select();

		if( !empty( $menus ) ){
	        $this->add_control(
				'restar_menu_select',
				[
					'label'     	=> __( 'Select restar Menu', 'restar' ),
					'type'      	=> Controls_Manager::SELECT,
					'options'   	=> $menus,
					'description' 	=> sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to manage your menus.', 'restar' ), 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.', 'restar' ) . '</strong><br>' . sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to create one.', 'restar' ), 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?', 'restar' ),
				'type' 			=> Controls_Manager::SWITCHER,
				'label_on' 		=> __( 'Show', 'restar' ),
				'label_off' 	=> __( 'Hide', 'restar' ),
				'return_value' 	=> 'yes',
				'default' 		=> 'yes',
			]
		);		

		$this->add_control(
			'show_cart_btn',
			[
				'label' 		=> __( 'Show Cart Button?', 'restar' ),
				'type' 			=> Controls_Manager::SWITCHER,
				'label_on' 		=> __( 'Show', 'restar' ),
				'label_off' 	=> __( 'Hide', 'restar' ),
				'return_value' 	=> 'yes',
				'default' 		=> 'yes',
			]
		);
		$this->add_control(
			'button_text',
			[
				'label' 		=> __( 'Button Text', 'restar' ),
				'type' 			=> Controls_Manager::TEXT,
				'label_block' 	=> true,
				'default' 	=> __( 'Contact Us', 'restar' ),
			]
		);

		$this->add_control(
			'button_url',
			[
				'label' 		=> esc_html__( 'Button Link', 'restar' ),
				'type' 			=> Controls_Manager::URL,
				'placeholder' 	=> esc_html__( 'https://your-link.com', 'restar' ),
				'show_external' => true,
				'default' 		=> [
					'url' 			=> '#',
					'is_external' 	=> false,
					'nofollow' 		=> false,
				],
			]
		);

        $this->end_controls_section();

		//---------------------------------------
			//Style Section Start
		//---------------------------------------

		//-------General Style-------
		 $this->start_controls_section(
			'general_styling',
			[
				'label'     => __( 'Background Styling', 'restar' ),
				'tab'       => Controls_Manager::TAB_STYLE,
			]
        );

		restar_color_fields( $this, 'topbar_bg', 'Topbar Background', 'background', '{{WRAPPER}} .header-top', ['1', '2'] );
		restar_color_fields( $this, 'menu_bg', 'Background', 'background', '{{WRAPPER}} .menu-area', ['1', '2'] );                  
		// restar_color_fields( $this, 'logo_bg', 'Logo Background', 'background', '{{WRAPPER}} .header-logo:before', ['1'] );         

		$this->end_controls_section();

		//------Menu Bar Style-------
        $this->start_controls_section(
			'menubar_styling2',
			[
				'label'     => __( 'Menu Styling', 'restar' ),
				'tab'       => Controls_Manager::TAB_STYLE,
			]
        );

		restar_color_fields( $this, 'menu_color1', 'Color', 'color', '{{WRAPPER}} .main-menu>ul>li>a', ['1'] );
		restar_color_fields( $this, 'menu_color2', 'Hover Color', 'color', '{{WRAPPER}} .main-menu>ul>li>a:hover', ['1'] );
		restar_color_fields( $this, 'menu_color3', 'Dropdown Color', 'color', '{{WRAPPER}} .main-menu ul.sub-menu li a' );
		restar_color_fields( $this, 'menu_color4', 'Dropdown Hover Color', 'color', '{{WRAPPER}} .main-menu ul.sub-menu li a:hover' );
		restar_color_fields( $this, 'menu_color5', 'Menu Icon Color', 'color', '{{WRAPPER}} .main-menu ul.sub-menu li a:before, {{WRAPPER}} .main-menu ul li.menu-item-has-children > a:after' );

		restar_typography_fields( $this, 'menu_font', 'Menu Trpography', '{{WRAPPER}} .main-menu>ul>li>a, {{WRAPPER}} .main-menu ul.sub-menu li a' );

		restar_dimensions_fields( $this, 'menu_margin', 'Menu Margin', 'margin', '{{WRAPPER}} .main-menu>ul>li>a' );
		restar_dimensions_fields( $this, 'menu_padding', 'Menu Padding', 'padding', '{{WRAPPER}} .main-menu>ul>li>a' );

		$this->end_controls_section();

		//------Button Style-------
		restar_button_style_fields( $this, '12', 'Button Styling', '{{WRAPPER}} .th_btn' );

    }

    public function restar_menu_select(){
	    $restar_menu = wp_get_nav_menus();
	    $menu_array  = array();
		$menu_array[''] = __( 'Select A Menu', 'restar' );
	    foreach( $restar_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
        $restar_avaiable_menu   = $this->restar_menu_select();
		if( ! $restar_avaiable_menu ){
			return;
		}
		$args = [
			'menu' 			=> $settings['restar_menu_select'],
			'menu_class' 	=> 'restar-menu',
			'container' 	=> '',
		];

		//Mobile menu, Offcanvas, Search
        echo restar_mobile_menu();
		echo restar_header_cart_offcanvas();
		if(!empty( $settings['show_offcanvas_btn'])){
			echo restar_header_offcanvas();
		}
		if(!empty( $settings['show_search_btn'])){
			echo restar_search_box();
		}
		// Header sub-menu icon
		if( class_exists( 'ReduxFramework' ) ){ 
			if(restar_opt('restar_header_sticky')){
                $sticky = '';
            }else{
                $sticky = '-no';
            }

			if(restar_opt('restar_menu_icon')){
				$menu_icon = '';
			}else{
				$menu_icon = 'hide-icon';
			}
		}

		if( $settings['layout_style'] == '1' ){
			$email = $settings['email'] ? $settings['email'] : '';   
			$phone = $settings['phone'] ? $settings['phone'] : '';     
			$email = is_email( $email );
			$replace        = array(' ','-',' - ');
			$replace_phone  = array(' ','-',' - ', '(', ')');
			$with           = array('','','');
			$emailurl       = str_replace( $replace, $with, $email );
			$phoneurl       = str_replace( $replace_phone, $with, $phone );	

			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">';
							echo '<div class="col-auto d-none d-lg-block">';
								echo '<div class="header-links">';
									echo '<ul>';
										if(!empty($settings['address'])){
											echo '<li class="d-none d-xxl-inline-block">';
												if(!empty($settings['address_icon'])){
													echo wp_kses_post( $settings['address_icon'] ); 
												}
												echo '<a href="'.esc_url($settings['address_link']['url']).'">'.wp_kses_post($settings['address']).'</a>';
											echo '</li>';
										}
										if(!empty($phone)){
											echo '<li>';
												if(!empty($settings['phone_icon'])){
													echo wp_kses_post( $settings['phone_icon'] );
												}
												echo '<a href="'.esc_attr('tel:' . $phoneurl).'">'.esc_html($phone).'</a>';
											echo '</li>';
										}
										if(!empty($email)){
											echo '<li>';
												if(!empty($settings['email_icon'])){
													echo wp_kses_post( $settings['email_icon'] );
												}
												echo ' <a href="'.esc_attr('mailto:' . $emailurl).'">'.esc_html($email).'</a>';
											echo '</li>';
										}
										
									echo '</ul>';
								echo '</div>';
							echo '</div>';
							echo '<div class="col-auto">';
								echo '<div class="header-links">';
									echo '<ul>';
										echo '<div class="shape1"></div>';
										if(!empty($settings['opening_time'])){
											echo '<li>';
												if(!empty($settings['opening_icon'])){
													echo wp_kses_post( $settings['opening_icon'] );
												}
												echo wp_kses_post( $settings['opening_time'] );
											echo '</li>';
										}
									echo '</ul>';
								echo '</div>';
							echo '</div>';
						echo '</div>';
					echo '</div>';
				echo '</div>';
				}
				echo '<div class="sticky-wrapper'.esc_attr($sticky).'">';
					echo '<!-- Main Menu Area -->';
					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 restar_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 '.esc_attr($menu_icon).'">';
										if( ! empty( $settings['restar_menu_select'] ) ){
											wp_nav_menu( $args );
										} else {
											wp_nav_menu( array(
												"theme_location"    => 'primary-menu',
												"container"         => '',
												"menu_class"        => ''
											) );
										}
									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-xl-block"><i class="fal fa-search"></i></button>';
										}
										if(!empty( $settings['show_cart_btn'])){
											if( class_exists( 'woocommerce' ) ){
												global $woocommerce;
												if( ! empty( $woocommerce->cart->cart_contents_count ) ){
													$count = $woocommerce->cart->cart_contents_count;
												}else{
													$count = "0";
												}
												echo '<button type="button" class="simple-icon sideMenuToggler">';
													echo '<span class="badge cart_badge">'.esc_html( $count ).'</span>';
													echo '<i class="fal fa-cart-shopping"></i>';
												echo '</button>'; 
											}
										}
										if(!empty( $settings['button_text'])){
											echo '<a href="'.esc_url($settings['button_url']['url']).'" class="th-btn style4 d-none d-xl-block th_btn">'.wp_kses_post($settings['button_text']).'</a>';
										}
										echo '<button type="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>';
			echo '</div>';
			
		}elseif( $settings['layout_style'] == '2' ){
		

		}elseif( $settings['layout_style'] == '3' ){
			

		}


	}
}
Page not found – Hello World !