<?php 
	
/**
 * Custom functions that act independently of the theme templates.
 *
 * Eventually, some of the functionality here could be replaced by core features.
 *
 * @package Hotel 26
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @param array $classes Classes for the body element.
 * @return array
 */
function hotel_26_body_classes( $classes ) {
	// Adds a class of group-blog to blogs with more than 1 published author.
	if ( is_multi_author() ) {
		$classes[] = 'group-blog';
	}

	// Adds a class of hfeed to non-singular pages.
	if ( ! is_singular() ) {
		$classes[] = 'hfeed';
	}

	// Themes
	$hotel_26_theme	=	get_theme_mod('hotel_26_theme','theme-1');
	$classes[] = esc_attr($hotel_26_theme);
	
	return $classes;
}
add_filter( 'body_class', 'hotel_26_body_classes' );

if ( ! function_exists( 'wp_body_open' ) ) {
	/**
	 * Backward compatibility for wp_body_open hook.
	 *
	 * @since 1.0.0
	 */
	function wp_body_open() {
		do_action( 'wp_body_open' );
	}
}

if (!function_exists('hotel_26_str_replace_assoc')) {

    /**
     * hotel_26_str_replace_assoc
     * @param  array $replace
     * @param  array $subject
     * @return array
     */
    function hotel_26_str_replace_assoc(array $replace, $subject) {
        return str_replace(array_keys($replace), array_values($replace), $subject);
    }
}

/**
 * Display Sidebars
 */
if ( ! function_exists( 'hotel26_get_sidebars' ) ) {
	/**
	 * Get Sidebar
	 *
	 * @since 1.0
	 * @param  string $sidebar_id   Sidebar Id.
	 * @return void
	 */
	function hotel26_get_sidebars( $sidebar_id ) {
		if ( is_active_sidebar( $sidebar_id ) ) {
			dynamic_sidebar( $sidebar_id );
		} elseif ( current_user_can( 'edit_theme_options' ) ) {
			?>
			<aside class="widget col">
				<p class='no-widget-text'>
					<a href='<?php echo esc_url( admin_url( 'widgets.php' ) ); ?>'>
						<?php esc_html_e( 'Add Widget', 'hotel-26' ); ?>
					</a>
				</p>
			</aside>
			<?php
		}
	}
}

function menu_toggle_bar() { ?>
<li class="hamburger hamburger-menu d-lg-none">
	<button type="button" class="toggle-lines menu-toggle" data-target="#stMenu">
		<span class="top-bun"></span>
		<span class="meat"></span>
		<span class="bottom-bun"></span>
	</button>
	<div class="menu-close fade-overlay"></div>
</li>
<?php }

// Logo Content
if ( ! function_exists( 'hotel_26_logo_content' ) ) :
function hotel_26_logo_content() {
		if(has_custom_logo())
			{	
				the_custom_logo();
			}
			$theme_title = get_bloginfo( 'name');
			if ($theme_title) :
			?>
			
			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" >
				<h4 class="site-title m-0">
					<?php 
						echo esc_html(get_bloginfo('name'));
					?>
				</h4>
			</a>	
		<?php 						
			endif;
	
			$hotel_26_description = get_bloginfo( 'description');
			if ($hotel_26_description) : ?>
				<p class="site-description"><?php echo esc_html($hotel_26_description); ?></p>
		<?php endif;
	} 
endif;
add_action( 'hotel_26_logo_content', 'hotel_26_logo_content' );

// Hotel 26 Navigation
if ( ! function_exists( 'hotel26_primary_navigation' ) ) :
function hotel26_primary_navigation() {
	wp_nav_menu( 
		array(  
			'theme_location' => 'primary_menu',
			'container'  => '',
			'menu_class' => 'menu-wrap nav',
			'fallback_cb' => 'WP_Bootstrap_Navwalker::fallback',
			'walker' => new WP_Bootstrap_Navwalker()
			 ) 
		);
	} 
endif;
add_action( 'hotel26_primary_navigation', 'hotel26_primary_navigation' );

// Hotel 26 Navigation Button
if ( ! function_exists( 'hotel26_navigation_button' ) ) :
function hotel26_navigation_button() {
	$hotel26_hdr_nav_btn_hs 			= get_theme_mod( 'hdr_nav_btn_hs','1');
	$hotel26_hdr_nav_btn_lbl 			= get_theme_mod( 'hdr_nav_btn_lbl');
	$hotel26_hdr_nav_btn_link 			= get_theme_mod( 'nav_nav_btn_link','#');
	$hotel26_hdr_nav_btn_newtab 		= get_theme_mod( 'hdr_nav_btn_newtab','1');
	$hotel26_hdr_nav_btn_nofollow 		= get_theme_mod( 'hdr_nav_btn_nofollow','1');
	if( $hotel26_hdr_nav_btn_hs == '1' && !empty($hotel26_hdr_nav_btn_lbl) ) { ?>
	<a href="<?php echo esc_url($hotel26_hdr_nav_btn_link); ?>" class="btn booking-btn py-2" <?php if($hotel26_hdr_nav_btn_newtab =='1') {echo 'target="_blank"'; } ?> rel="<?php if($hotel26_hdr_nav_btn_newtab =='1') {echo 'noreferrer noopener';} ?> <?php if($hotel26_hdr_nav_btn_nofollow =='1') {echo 'nofollow';} ?>"><?php echo esc_html($hotel26_hdr_nav_btn_lbl); ?></a>
	<?php }
} 
endif;
add_action( 'hotel26_navigation_button', 'hotel26_navigation_button' );

// Hotel 26 Navigation Search
if ( ! function_exists( 'hotel26_navigation_search' ) ) :
function hotel26_navigation_search() {
	$hide_show_search 	= get_theme_mod( 'hide_show_search','1'); 
	if($hide_show_search=='1'):	get_search_form(array( 'layout' => 'default' )); endif;
	} 
endif;
add_action( 'hotel26_navigation_search', 'hotel26_navigation_search' );

	
if ( ! function_exists( 'hotel_26_get_allowed_html_tags' ) ) {
	/**
	 * Array of allowed HTML Tags.
	 *
	 * @since 1.0.0
	 * @param string $type predefined HTML tags group name.
	 * @return array, allowed HTML tags.
	 */
	function hotel_26_get_allowed_html_tags( $type = 'basic' ) {

		$tags = array();

		switch ( $type ) {

			case 'basic':
				$tags = array(
					'strong' => array(),
					'em'     => array(),
					'b'      => array(),
					'br'     => array(),
					'p'     => array(),
					'i'      => array(
						'class' => array(),
					),
					'img'    => array(
						'src'    => array(),
						'alt'    => array(),
						'width'  => array(),
						'height' => array(),
						'class'  => array(),
						'id'     => array(),
					),
					'span'   => array(
						'class' => array(),
					),
					'a'      => array(
						'href'   => array(),
						'rel'    => array(),
						'target' => array(),
						'class'  => array(),
						'role'   => array(),
						'id'     => array(),
					),
				);
				break;

			case 'button':
				$tags = array(
					'strong' => array(),
					'em'     => array(),
					'span'   => array(
						'class' => array(),
					),
					'i'      => array(
						'class' => array(),
					),
				);
				break;

			case 'span':
				$tags = array(
					'span' => array(
						'class' => array(),
					),
				);
				break;

			case 'icon':
				$tags = array(
					'i'    => array(),
					'span' => array(),
					'img'  => array(),
				);
				break;

			default:
				$tags = array(
					'strong' => array(),
					'em'     => array(),
					'b'      => array(),
					'i'      => array(),
					'img'    => array(
						'src'    => array(),
						'alt'    => array(),
						'width'  => array(),
						'height' => array(),
						'class'  => array(),
						'id'     => array(),
					),
					'span'   => array(),
					'p'   => array(),
					'a'      => array(
						'href'   => array(),
						'rel'    => array(),
						'target' => array(),
						'class'  => array(),
						'role'   => array(),
						'id'     => array(),
					),
				);
				break;
		}

		return apply_filters( 'hotel_26_allowed_html_tags', $tags, $type );
	}
}

/*********************
	Default Functions 
**********************/

function hotel26_award2_default() {
	return apply_filters(
		'hotel26_award2_default', json_encode(
				 array(
				array(
					'image_url'		=> esc_url(get_template_directory_uri() . '/assets/images/footer/1.png'),					
					'id'            => 'customizer_repeater_award2_001',
				),
				array(
					'image_url'		=> esc_url(get_template_directory_uri() . '/assets/images/footer/2.png'),
					'id'            => 'customizer_repeater_award2_002',
				),
				array(
					'image_url'		=> esc_url(get_template_directory_uri() . '/assets/images/footer/3.png'),
					'id'            => 'customizer_repeater_award2_003',
				),
				array(
					'image_url'		=> esc_url(get_template_directory_uri() . '/assets/images/footer/4.png'),
					'id'            => 'customizer_repeater_award2_004',
				),
			)								
		)

	);
}

/*
*
* Trust Default
**
*/
 function hotel26_trust_default() {
	return apply_filters(
		'hotel26_trust_default', json_encode(
				 array(
				array(
					'title'			=> wp_kses_post(__('<span>100%</span> Trust','hotel-26')),
					'icon_value'	=> 'fa-shield-alt',					
					'id'            => 'customizer_repeater_trust_001',
				),
				array(
					'title'			=> wp_kses_post(__('<span>100%</span> Support','hotel-26')),
					'icon_value'	=> 'fa-headphones',					
					'id'            => 'customizer_repeater_trust_002',
				),
				array(
					'title'			=> wp_kses_post(__('<span>100%</span> Value For Money','hotel-26')),
					'icon_value'	=> 'fa-wallet',					
					'id'            => 'customizer_repeater_trust_003',
				),
				array(
					'title'			=> wp_kses_post(__('<span>100%</span> Online Security','hotel-26')),
					'icon_value'	=> 'fa-usd',					
					'id'            => 'customizer_repeater_trust_004',
				),
			)								
		)

	);
}

/*
 *
 * Social Icon
 */
function hotel26_social_icon_default() {
	return apply_filters(
		'hotel26_social_icon_default', json_encode(
				 array(
				array(
					'icon_value'	=>  esc_html__( 'fa-facebook', 'hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_social_001',
				),
				array(
					'icon_value'	=>  esc_html__( 'fa-instagram', 'hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_social_002',
				),
				array(
					'icon_value'	=>  esc_html__( 'fa-twitter', 'hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_social_003',
				),
				array(
					'icon_value'	=>  esc_html__( 'fa-youtube', 'hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_social_004',
				),
				array(
					'icon_value'	=>  esc_html__( 'fa-pinterest-p', 'hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_social_005',
				)
			)
		)
	);
}


/*
 *
 * Payment Default
 */
function hotel26_payment_default() {
	return apply_filters(
		'hotel26_payment_default', json_encode(
				 array(
				array(
					'image_url'	=>  esc_url( get_template_directory_uri(). '/assets/images/footer/visa.png' ),
					'title'	=>  esc_html__( 'Visa','hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_payment_001',
				),
				array(
					'image_url'	=>  esc_url( get_template_directory_uri(). '/assets/images/footer/mastercard.png' ),
					'title'	=>  esc_html__( 'Mastercard','hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_payment_002',
				),
				array(
					'image_url'	=>  esc_url( get_template_directory_uri(). '/assets/images/footer/discover.png' ),
					'title'	=>  esc_html__( 'Discover','hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_payment_003',
				),
				array(
					'image_url'	=>  esc_url( get_template_directory_uri(). '/assets/images/footer/g-pay.png' ),
					'title'	=>  esc_html__( 'G-Pay','hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_payment_004',
				),
				array(
					'image_url'	=>  esc_url( get_template_directory_uri(). '/assets/images/footer/paypal.png' ),
					'title'	=>  esc_html__( 'Paypal','hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_payment_005',
				),
				array(
					'image_url'	=>  esc_url( get_template_directory_uri(). '/assets/images/footer/upi.png' ),
					'title'	=>  esc_html__( 'UPI','hotel-26' ),
					'link'	  		=>  '',
					'id'            => 'customizer_repeater_payment_006',
				),
			)
		)
	);
}

/*
 *
 * Service 3 Default
 */
function hotel26_get_service_three_default() {
	return apply_filters(
		'hotel26_get_service_three_default', json_encode(
				 array(
				array(
					'title'           => esc_html__( 'Airport Pickup', 'hotel-26' ),
					'image_url2'       => get_template_directory_uri() . '/assets/images/footer/footer-s1.png',
					'icon_value' => 'fa-plane',
					'id'              => 'customizer_repeater_service_three_001',
				),
				array(
					'title'           => esc_html__( 'Room Service', 'hotel-26' ),
					'image_url2'       => get_template_directory_uri() . '/assets/images/footer/footer-s2.png',
					'icon_value' => 'fa-person-booth',
					'id'              => 'customizer_repeater_service_three_002',
				),
				array(
					'title'           => esc_html__( 'Gym Facilities', 'hotel-26' ),
					'image_url2'       => get_template_directory_uri() . '/assets/images/footer/footer-s3.png',
					'icon_value' => 'fa-dumbbell',
					'id'              => 'customizer_repeater_service_three_003',
				),
				array(
					'title'           => esc_html__( 'Dining Table', 'hotel-26' ),
					'image_url2'       => get_template_directory_uri() . '/assets/images/footer/footer-s4.png',
					'icon_value' => 'fa-utensils',
					'id'              => 'customizer_repeater_service_three_004',
				),
				array(
					'title'           => esc_html__( 'Private Parking', 'hotel-26' ),
					'image_url2'       => get_template_directory_uri() . '/assets/images/footer/footer-s5.png',
					'icon_value' => 'fa-parking',
					'id'              => 'customizer_repeater_service_three_005',
				),			
			)
		)
	);
}