Viewing File: /home/maglabs/2vsa/wp-content/themes/cargohub/inc/frontend/header.php

<?php
/**
 * Hooks for template header
 *
 * @package CargoHub
 */

/**
 * Enqueue scripts and styles.
 *
 * @since 1.0
 */
function cargohub_enqueue_scripts() {
	/**
	 * Register and enqueue styles
	 */
	wp_register_style( 'cargohub-fonts', cargohub_fonts_url(), array(), '20161025' );
	wp_register_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.7' );
	wp_register_style( 'fancybox', get_template_directory_uri() . '/css/jquery.fancybox.css', array(), '2.1.5' );
	wp_register_style( 'fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css', array(), '4.6.3' );
	wp_register_style( 'fontawesome-5', get_template_directory_uri() . '/css/font-awesome-5.min.css', array(), '5.15.3' );
	wp_register_style( 'factoryplus-icons', get_template_directory_uri() . '/css/factoryplus-icons.css', array(), '20161025' );
	wp_register_style( 'flaticon', get_template_directory_uri() . '/css/flaticon.css', array(), '20170425' );

	wp_enqueue_style( 'cargohub', get_template_directory_uri() . '/style.css',
		array(
			'cargohub-fonts',
			'factoryplus-icons',
			'flaticon',
			'bootstrap',
			'fancybox',
			'fontawesome',
			'fontawesome-5'
		), '20161025'
	);

	wp_add_inline_style('cargohub', cargohub_customize_css());

	/**
	 * Register and enqueue scripts
	 */
	$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';

	wp_enqueue_script( 'html5shiv', get_template_directory_uri() . '/js/html5shiv.min.js', array(), '3.7.2' );
	wp_script_add_data( 'html5shiv', 'conditional', 'lt IE 9' );

	wp_enqueue_script( 'respond', get_template_directory_uri() . '/js/respond.min.js', array(), '1.4.2' );
	wp_script_add_data( 'respond', 'conditional', 'lt IE 9' );

	wp_register_script( 'isotope', get_template_directory_uri() . '/js/plugins/isotope.pkgd.min.js', array(), '2.2.2', true );
	wp_register_script( 'fancybox', get_template_directory_uri() . '/js/plugins/jquery.fancybox.min.js', array(), '3.5.7', true );
	wp_register_script( 'mousewheel', get_template_directory_uri() . '/js/plugins/jquery.mousewheel.pack.js', array(), '3.1.3', true );
	wp_register_script( 'parallax', get_template_directory_uri() . '/js/plugins/jquery.parallax.min.js', array(), '1.0', true );
	wp_register_script( 'tabs', get_template_directory_uri() . '/js/plugins/jquery.tabs.js', array(), '1.0', true );
	wp_register_script( 'owlcarousel', get_template_directory_uri() . '/js/plugins/owl.carousel.js', array(), '2.2.0', true );

	wp_enqueue_script( 'cargohub', get_template_directory_uri() . "/js/scripts$min.js", array(

		'jquery',
		'imagesloaded',
		'isotope',
		'fancybox',
		'mousewheel',
		'parallax',
		'tabs',
		'owlcarousel',

	), '20170801', true );

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}

	wp_localize_script(
		'cargohub', 'cargohub', array(
			'cargohub_back'      => esc_html__('Back', 'cargohub'),
			'direction' 			=> is_rtl() ? 'rtl' : '',
		)
	);
}

add_action('wp_enqueue_scripts', 'cargohub_enqueue_scripts');

/**
 * Enqueues front-end CSS for theme customization
 */
function cargohub_customize_css() {
	$css = '';

	// Logo
	$logo_size_width = intval( cargohub_get_option( 'logo_width' ) );
	$logo_css        = $logo_size_width ? 'width:' . $logo_size_width . 'px; ' : '';

	$logo_size_height = intval( cargohub_get_option( 'logo_height' ) );
	$logo_css .= $logo_size_height ? 'height:' . $logo_size_height . 'px; ' : '';

	$logo_margin = cargohub_get_option( 'logo_position' );
	$logo_css .= $logo_margin['top'] ? 'margin-top:' . $logo_margin['top'] . '; ' : '';
	$logo_css .= $logo_margin['right'] ? 'margin-right:' . $logo_margin['right'] . '; ' : '';
	$logo_css .= $logo_margin['bottom'] ? 'margin-bottom:' . $logo_margin['bottom'] . '; ' : '';
	$logo_css .= $logo_margin['left'] ? 'margin-left:' . $logo_margin['left'] . '; ' : '';

	if ( ! empty( $logo_css ) ) {
		$css .= '.site-header .logo img ' . ' {' . $logo_css . '}';
	}

	// Topbar background color
	$topbar_bg_color = cargohub_get_option( 'topbar_bg_color' );
	if ( $topbar_bg_color ) {
		$css .= '.topbar { background-color: ' . $topbar_bg_color . ' !important; }';
	}

	// Page header image
	if ( $image = cargohub_get_page_header_image() ) {
		$css .= '.header-title { background-image: url(' . esc_url( $image ) . '); }';
	}

	/* Footer background */

	$footer_image = cargohub_get_option( 'footer_widget_bg' );
	$footer_bg_color = cargohub_get_option( 'footer_bg_color' );
	$footerwidget_bg_color = cargohub_get_option( 'footer_widget_bg_color' );

	$footer_bg_color = str_replace( '#', '',$footer_bg_color);
	$footer_bg_color = '#' . $footer_bg_color;

	$footer_css = ! empty( $footer_bg_color ) ? "background-color: {$footer_bg_color};" : '';
	$css .= '.site-footer {' . $footer_css . '}';

	$footerwidget_bg_color = str_replace( '#', '',$footerwidget_bg_color);
	$footerwidget_bg_color = '#' . $footerwidget_bg_color;

	$footerwidget_css = ! empty( $footerwidget_bg_color ) ? "background-color: {$footerwidget_bg_color};" : '';
	if ( ! empty( $footer_image ) ) {
		$footerwidget_css .= "background-image: url({$footer_image});";
	}
	$css .= '.footer-widgets {' . $footerwidget_css . '}';

	/* 404 background */

	if ( is_404() ) {
		$banner = cargohub_get_option( '404_bg' );

		if ( $banner ) {
			$css .= '.error404 .site-content { background-image: url( ' . esc_url( $banner ) . '); }';
		}
	}

	$color_scheme_option = cargohub_get_option( 'color_scheme' );
	if ( $color_scheme_option ) {
		$color = explode( '|', $color_scheme_option );

		$main_color = isset( $color[0] ) ? $color[0] : '0';
		$sub_color  = isset( $color[1] ) ? $color[1] : '0';

		if ( intval( cargohub_get_option( 'custom_color_scheme' ) ) ) {
			$main_color = cargohub_get_option( 'custom_color_1' );
			$sub_color  = cargohub_get_option( 'custom_color_2' );
		}

		if ( $main_color != '0' && $sub_color != '0' ) {
			$css .= cargohub_get_color_scheme_css( $main_color, $sub_color );
		}
	}

	$cursor = get_template_directory_uri() . '/img/cursor.png';
	$cursor2 = get_template_directory_uri() . '/img/cursor2.png';

	$css .= cargohub_cursor_css( $cursor );
	$css .= cargohub_cursor_css_2( $cursor2 );

	$css .= cargohub_typography_css();

	$css .= cargohub_get_heading_typography_css();

	return $css;

}

/**
 * Display header
 */
function cargohub_show_header() {
	get_template_part( 'parts/headers/header', cargohub_get_option( 'header_layout' ) );
}

add_action( 'cargohub_header', 'cargohub_show_header' );

/**
 * Display topbar on top of site
 *
 * @since 1.0.0
 */
function cargohub_show_topbar() {
	if ( ! cargohub_get_option( 'topbar_enable' ) ) {
		return;
	}

	?>
	<div id="topbar" class="topbar">
		<div class="container">
			<?php if ( is_active_sidebar( 'topbar-left' ) ) : ?>

			<div class="topbar-left topbar-widgets text-left">
				<?php dynamic_sidebar("topbar-left"); ?>
			</div>

			<?php endif; ?>
			<?php if ( is_active_sidebar( 'topbar-right' ) ) : ?>

			<div class="topbar-right topbar-widgets text-right">
				<?php dynamic_sidebar("topbar-right"); ?>
			</div>

			<?php endif; ?>
		</div>
	</div>
	<?php
}
add_action( 'cargohub_before_header', 'cargohub_show_topbar', 20 );

/**
 * Display Empty Space after topbar
 *
 * @since 1.0.0
 */
function cargohub_empty_space() {
	if ( cargohub_get_option( 'header_layout' ) != 'v4' ) {
		return;
	}

	?>
	<div class="ch-empty-space"></div>
	<?php
}
add_action( 'cargohub_before_header', 'cargohub_empty_space', 30 );

/**
 * Display page header
 */
function cargohub_page_header() {
	if ( ! cargohub_has_page_header() ) {
		return;
	}

	get_template_part( 'parts/page-headers/page-header' );
}

add_action( 'cargohub_after_header', 'cargohub_page_header' );

/**
 * Display the main breadcrumb
 */
function cargohub_site_breadcrumb() {

	if ( ! intval(cargohub_get_option( 'show_breadcrumb' ) ) ) {
		return;
	}

	if ( is_singular() && get_post_meta( get_the_ID(), 'hide_breadcrumb', true ) ) {
		return;
	}

	cargohub_breadcrumbs();
}

/**
 * Display the main breadcrumb
 */
function cargohub_title_page_header() {
	$hide_title = get_post_meta( get_the_ID(), 'hide_title_page_header', true );

	if ( cargohub_get_option( 'show_title' ) == false ) {
		return;
	}

	if ( $hide_title == '1' ) {
		return;
	}

	the_archive_title( '<h1 class="page-title">', '</h1>' );
}

/**
 * Filter to archive title and add page title for singular pages
 *
 * @param string $title
 *
 * @return string
 */
function cargohub_the_archive_title( $title ) {
	if ( is_search() ) {
		$title = sprintf( esc_html__( 'Search Results', 'cargohub' ) );
	} elseif ( is_404() ) {
		$title = sprintf( esc_html__( 'Page Not Found', 'cargohub' ) );
	} elseif ( is_page() ) {
		$title = get_the_title();
	} elseif ( is_home() && is_front_page() ) {
		$title = esc_html__( 'The Latest Posts', 'cargohub' );
	} elseif ( is_home() && ! is_front_page() ) {
		$title = get_the_title( get_option( 'page_for_posts' ) );
	} elseif ( is_single() ) {
		$title = get_the_title();
	} elseif ( is_post_type_archive( 'project' ) ) {

		$customize_title = cargohub_get_option('project_archive_title');
		$portfolio_page_id = get_option( 'sth_project_page_id' );

		if ( $portfolio_page_id && get_post( $portfolio_page_id ) ) {
			$title = get_the_title( $portfolio_page_id );
		} elseif( !empty( $customize_title) ){
			$title = wp_kses( $customize_title, wp_kses_allowed_html( 'post' )  ) ;
		} else {
			$title = _x( 'Project', 'Project post type title', 'cargohub' );
		}

	} elseif ( is_post_type_archive( 'service' ) ) {

		$customize_title = cargohub_get_option('service_archive_title');
		$service_page_id = get_option( 'sth_service_page_id' );

		if ( $service_page_id && get_post( $service_page_id ) ) {
			$title = get_the_title( $service_page_id );
		} elseif( !empty( $customize_title) ){
			$title = wp_kses( $customize_title, wp_kses_allowed_html( 'post' )  ) ;
		} else {
			$title = _x( 'Service', 'Service post type title', 'cargohub' );
		}

	} elseif ( is_post_type_archive( 'testimonial' ) ) {

		$customize_title = cargohub_get_option('testimonial_archive_title');
		$testimonial_page_id = get_option( 'sth_testimonial_page_id' );

		if ( $testimonial_page_id && get_post( $testimonial_page_id ) ) {
			$title = get_the_title( $testimonial_page_id );
		} elseif( !empty( $customize_title) ){
			$title = wp_kses( $customize_title, wp_kses_allowed_html( 'post' )  ) ;
		} else {
			$title = _x( 'Testimonial', 'Testimonial post type title', 'cargohub' );
		}

	} elseif ( is_tax() ) {
		$title = single_term_title( '', false );
	}

	return $title;
}

add_filter( 'get_the_archive_title', 'cargohub_the_archive_title' );

/**
 * Display the header minimized
 *
 * @since 1.0.0
 */
function cargohub_header_minimized() {

	if ( ! intval( cargohub_get_option( 'header_sticky' ) ) ) {
		return;
	}

	$css_class = 'fh-header-' . cargohub_get_option( 'header_layout' );

	printf( '<div id="fh-header-minimized" class="fh-header-minimized %s"></div>', esc_attr( $css_class ) );

}

add_action( 'cargohub_before_header', 'cargohub_header_minimized' );

/**
 * Returns CSS for the color schemes.
 *
 *
 * @param array $main_color, $sub_color - Color scheme colors.
 *
 * @return string Color scheme CSS.
 */
function cargohub_get_color_scheme_css( $main_color, $sub_color ) {
	return <<<CSS
	/* ------------------- Primary color -------------------- */
	/*Background Color: */

	.main-background-color,
	.header-v4 .nav ul.menu > li > a:after,
	.numeric-navigation .page-numbers:hover,.numeric-navigation .page-numbers.current,
	.project-nav-ajax nav.numeric-navigation .page-numbers.next:hover,.project-nav-ajax nav.numeric-navigation .page-numbers.next:focus,
	.primary-mobile-nav .menu-item-button-link a,
	.fh-btn,
	.fh-btn:hover,.fh-btn:focus,
	.entry-time,
	.post-author .box-title:after,
	.socials-share a:hover,
	.single-service blockquote:before,
	.single-project .single-project-title:before,
	.project-wrapper .project-thumbnail .project-button .button-link:hover,
	.comments-title:after,.comment-reply-title:after,
	.comment-respond .form-submit .submit,
	.comment-respond .form-submit .submit:hover,.comment-respond .form-submit .submit:focus,
	.widget .widget-title:after,
	.widget_tag_cloud a:hover,
	.tabs-widget .tabs-nav li a.active,
	.download .item-download:hover,
	.service-sidebar .services-menu-widget ul li:hover,.service-sidebar .services-menu-widget ul li.current-menu-item,
	.cargohub-social-links-widget .style-2 a:hover,
	.latest-project-widget .widget-thumb:before,
	.footer-widgets .fh-form-field .subscribe input[type="submit"],
	.fh-section-title h2:before,
	.fh-icon-box.style-2:hover .fh-icon,
	.fh-contact-box ul li:hover,
	.fh-latest-post.carousel .owl-nav div:hover,
	.fh-counter h4,
	.fh-testimonials-carousel .owl-dots .owl-dot:hover span,.fh-testimonials-carousel .owl-dots .owl-dot.active span,
	.fh-price-table.promoted .table-header,.fh-price-table:hover .table-header,
	.fh-price-table.promoted .table-content a,.fh-price-table:hover .table-content a,
	.fh-service .entry-thumbnail .icon,
	.fh-service.style-flat .entry-title:after,
	.fh-team .team-member ul li,
	.fh-team .owl-nav div:hover,
	.fh-team .owl-dots .owl-dot:hover span,.fh-team .owl-dots .owl-dot.active span,
	.custom-quote.quote-project blockquote:after,
	.cargo-arrow:hover,
	.fh-service-box-2.box-style-2 .box-thumb:before,
	.fh-icon-box.version-light:hover:before,
	.services-menu-widget ul li:hover,
	.services-menu-widget ul li.current-menu-item
	{background-color: $main_color}

	.ch_button:hover,
	.tp-caption.ch_button:hover
	{background-color: $main_color !important;}

	/*Border Color: */

	.numeric-navigation .page-numbers:hover,.numeric-navigation .page-numbers.current,
	.project-nav-ajax nav.numeric-navigation .page-numbers.next:hover,.project-nav-ajax nav.numeric-navigation .page-numbers.next:focus,
	.service:hover .service-inner,
	.single-project .entry-thumbnail .owl-dots .owl-dot:hover span,.single-project .entry-thumbnail .owl-dots .owl-dot.active span,
	.project-wrapper .project-thumbnail .project-button .button-link:hover,
	.download .item-download:hover,
	.service-sidebar .services-menu-widget ul li:hover,.service-sidebar .services-menu-widget ul li.current-menu-item,
	.cargohub-social-links-widget .style-2 a:hover,
	.fh-icon-box.style-2:hover .fh-icon,
	.fh-service-box.style-1:hover,
	.fh-latest-post.carousel .owl-nav div:hover,
	.fh-testimonials-carousel .owl-dots .owl-dot:hover span,.fh-testimonials-carousel .owl-dots .owl-dot.active span,
	.fh-testimonials-carousel .owl-nav div:hover,
	.fh-price-table.promoted .table-content,.fh-price-table:hover .table-content,
	.fh-price-table.promoted .table-content a,.fh-price-table:hover .table-content a,
	.fh-team .owl-dots .owl-dot:hover span,.fh-team .owl-dots .owl-dot.active span,
	.service-tabs .vc_tta-tabs-list li:hover a,.service-tabs .vc_tta-tabs-list li.vc_active a,
	.backtotop,
	.services-menu-widget ul li:hover,
	.services-menu-widget ul li.current-menu-item
	{border-color: $main_color}

	.ch_button:hover,
	.tp-caption.ch_button:hover
	{border-color: $main_color !important;}

	blockquote
	{border-left-color: $main_color !important;}

	/*Color: */

	.socials a:hover,
	.main-color,
	.fh-form span.require,
	.track-form span.start:after,.track-form span.end:after,
	.topbar .widget .topbar-contact i,
	.topbar .topbar-socials li:hover a,
	.topbar .cargohub-social-links-widget a:hover,
	.header-v3 .site-header-widget .widget h4,.header-v4 .site-header-widget .widget h4,
	.nav ul.menu > li:hover > a,.nav ul.menu > li.current-menu-item > a,.nav ul.menu > li.current-menu-parent > a,.nav ul.menu > li.current_page_item > a,
	.nav div.menu > ul > li.current-menu-item > a,.nav div.menu > ul > li.current-menu-parent > a,.nav div.menu > ul > li.current_page_item > a,.nav div.menu > ul > li.current_page_parent > a,.nav div.menu > ul > li:hover > a,
	.nav .menu li.extra-menu-item.menu-item-search .toggle-search,
	.header-sticky .site-header.minimized .nav .menu > li:hover > a,.header-sticky .site-header.minimized .nav .menu > li.current-menu-item > a,.header-sticky .site-header.minimized .nav .menu > li.current-menu-parent > a,
	.header-sticky.header-v3 .site-header.minimized .nav .menu > li:hover > a,.header-sticky.header-v4 .site-header.minimized .nav .menu > li:hover > a,.header-sticky.header-v3 .site-header.minimized .nav .menu > li.current-menu-item > a,.header-sticky.header-v4 .site-header.minimized .nav .menu > li.current-menu-item > a,.header-sticky.header-v3 .site-header.minimized .nav .menu > li.current-menu-parent > a,.header-sticky.header-v4 .site-header.minimized .nav .menu > li.current-menu-parent > a,
	.post-navigation a:hover,
	.portfolio-navigation .nav-previous a:hover,.portfolio-navigation .nav-next a:hover,
	.project-nav-ajax nav.numeric-navigation .page-numbers.next,
	.project-nav-ajax nav.numeric-navigation .page-numbers.next span,
	.primary-mobile-nav ul.menu li.current-menu-item > a,
	.entry-meta a:hover,
	.entry-meta .meta.views:hover,
	.entry-meta .fa,
	.blog-wrapper .entry-footer a,
	.service:hover .service-title a,
	.single-service cite span,
	.metas i,
	.all-project ul.filter li.active,.all-project ul.filter li:hover,
	.all-project ul.filter li.active a,.all-project ul.filter li:hover a,
	.backtotop,
	.backtotop .fa,
	.backtotop:hover,
	.backtotop:hover .fa,
	.comment .comment-reply-link:hover,
	.widget_recent_comments li:hover > a,.widget_rss li:hover > a,
	.widget_categories li:hover,.widget_pages li:hover,.widget_archive li:hover,.widget_nav_menu li:hover,.widget_recent_entries li:hover,.widget_meta li:hover
	.widget_categories li:hover:after,.widget_pages li:hover:after,.widget_archive li:hover:after,.widget_nav_menu li:hover:after,.widget_recent_entries li:hover:after,.widget_meta li:hover:after,
	.widget_categories li:hover > a,.widget_pages li:hover > a,.widget_archive li:hover > a,.widget_nav_menu li:hover > a,.widget_recent_entries li:hover > a,.widget_meta li:hover > a,
	.widget_categories li:hover > a:before,.widget_pages li:hover > a:before,.widget_archive li:hover > a:before,.widget_nav_menu li:hover > a:before,.widget_recent_entries li:hover > a:before,.widget_meta li:hover > a:before,
	.popular-posts-widget i,
	.widget-about a:hover,
	.recent-post .icon,
	.popular-post .post-text .post-date i,
	.service-sidebar .side-contact i,
	.cargohub-social-links-widget a:hover,
	.site-footer .footer-copyright a,
	.footer-widgets .menu li:hover a,
	.latest-post .post-date,
	.footer-menu ul li a:hover,
	.contact-widget .contact i,
	.footer-contact .ft-contact i,
	.fh-icon-box:hover h4 a,.fh-icon-box:hover .fh-icon,
	.fh-icon-box.style-3 .fh-icon,.fh-icon-box.style-3 .img-icon,
	.fh-feature-box .chars,
	.fh-service-box.style-1:hover .fh-icon,.fh-service-box.style-1:hover .img-icon,
	.fh-service-box.style-1:hover i,
	.fh-service-box.style-2:hover h4,.fh-service-box.style-2:hover h4 a,.fh-service-box.style-2:hover .fh-icon,.fh-service-box.style-2:hover i,
	.fh-service-box-2 .fh-icon,
	.fh-contact-box i,
	.fh-project .item-project .project-summary .project-cat,
	.fh-project .item-project .project-summary .project-cat a,
	.fh-project.style-2 ul.filter li.active,.fh-project.style-2 ul.filter li:hover,
	.fh-project.style-3 ul.filter li.active,.fh-project.style-3 ul.filter li:hover,
	.fh-latest-post .item-latest-post .entry-footer a,
	.fh-testimonials .testi-job,
	.fh-testimonials-carousel .owl-nav div:hover,
	.fh-service .read-more,
	.fh-service .service-content:hover h2,.fh-service .service-content:hover h2 a,
	.fh-team .team-member .job,
	.custom-quote blockquote:before,
	.custom-quote blockquote a,
	.cargo-office-location-widget .current-office:after,
	.cargo-office-location-widget .topbar-office li i,
	.blog-wrapper.sticky .entry-title:before,
	.cargo-contact-widget i
	{color: $main_color}

	.fh-accordion.style-2.vc_tta-accordion .vc_tta-panel-title a:hover,
	.fh-accordion.style-2.vc_tta-accordion .vc_tta-panel-title a:hover i,
	.fh-accordion.style-2.vc_tta-accordion .vc_tta-panel.vc_active .vc_tta-panel-title a,
	.fh-accordion.style-2.vc_tta-accordion .vc_tta-panel.vc_active .vc_tta-panel-title a i
	{color: $main_color !important;}


	/* ------------------- Secondary color -------------------- */

	/*Background Color: */

	.sub-background-color,
	.topbar,
	.nav li li:hover,
	.header-v3 .site-menu,
	.header-v4 .site-menu,
	.fh-service-box-2.box-style-2 .box-header .fh-icon,
	.fh-price-table .table-header,
	.project-wrapper .project-thumbnail .pro-link,
	.single-post .entry-thumbnail:before,
	.blog-wrapper .entry-thumbnail a:before,
	.service .service-thumbnail a:before,
	.fh-latest-post .item-latest-post .entry-thumbnail a:before,
	.fh-service .entry-thumbnail .link,
	.fh-team .team-member .team-header:before,
	.fh-icon-box.version-light:before,
	.fh-btn-2,
	.fh-testimonials-carousel .testi-wrapper
	{background-color: $sub_color}

	/*Color: */

	.sub-color,
	.fh-icon-box .fh-icon,
	.fh-icon-box.style-2 .fh-icon,
	.fh-service-box.style-2 i,
	.fh-service-box-2.box-style-2 .read-more
	{color: $sub_color}

CSS;
}

/**
 * Returns CSS for the cursor.
 *
 * @return string cursor CSS.
 */
function cargohub_cursor_css( $cursor ) {
	return <<<CSS
	.fh-latest-post .item-latest-post .entry-thumbnail a,
	.fh-service-box.style-1
	.fh-service-box.style-1 a
	{ cursor: url( $cursor ), auto; }
CSS;
}

/**
 * Returns CSS for the cursor.
 *
 * @return string cursor CSS.
 */
function cargohub_cursor_css_2( $cursor2 ) {
	return <<<CSS
	.fh-latest-post.carousel .owl-nav div,
	.fh-team .owl-carousel .owl-nav div,
	.fh-icon-box,
	.fh-icon-box a
	{ cursor: url( $cursor2 ), auto; }
CSS;
}

if ( ! function_exists( 'cargohub_typography_css' ) ) :
	/**
	 * Get typography CSS base on settings
	 *
	 * @since 1.1.6
	 */
	function cargohub_typography_css() {
		$css        = '';
		$properties = array(
			'font-family'    => 'font-family',
			'font-size'      => 'font-size',
			'variant'        => 'font-weight',
			'line-height'    => 'line-height',
			'letter-spacing' => 'letter-spacing',
			'color'          => 'color',
			'text-transform' => 'text-transform',
			'text-align'     => 'text-align',
		);

		$settings = array(
			'body_typo'              => 'body',
			'heading1_typo'          => 'h1',
			'heading2_typo'          => 'h2',
			'heading3_typo'          => 'h3',
			'heading4_typo'          => 'h4',
			'heading5_typo'          => 'h5',
			'heading6_typo'          => 'h6',
			'menu_typo'              => '.nav a',
			'footer_text_typo'       => '.site-footer',
		);

		foreach ( $settings as $setting => $selector ) {
			$typography = cargohub_get_option( $setting );
			$default    = (array) cargohub_get_option_default( $setting );
			$style      = '';

			foreach ( $properties as $key => $property ) {
				if ( isset( $typography[$key] ) && ! empty( $typography[$key] ) ) {
					if ( isset( $default[$key] ) && strtoupper( $default[$key] ) == strtoupper( $typography[$key] ) ) {
						continue;
					}

					$value = 'font-family' == $key ? '"' . rtrim( trim( $typography[ $key ] ), ',' ) . '"' : $typography[$key];
					$value = 'variant' == $key ? str_replace( 'regular', '400', $value ) : $value;

					if ( $value ) {
						$style .= $property . ': ' . $value . ';';
					}
				}
			}

			if ( ! empty( $style ) ) {
				$css .= $selector . '{' . $style . '}';
			}
		}

		return $css;
	}
endif;

/**
 * Returns CSS for the typography.
 *
 * @return string typography CSS.
 */
function cargohub_get_heading_typography_css() {

	$headings   = array(
		'h1' => 'heading1_typo',
		'h2' => 'heading2_typo',
		'h3' => 'heading3_typo',
		'h4' => 'heading4_typo',
		'h5' => 'heading5_typo',
		'h6' => 'heading6_typo'
	);
	$inline_css = '';
	foreach ( $headings as $heading ) {
		$keys = array_keys( $headings, $heading );
		if ( $keys ) {
			$inline_css .= cargohub_get_heading_font( $keys[0], $heading );
		}
	}


	return $inline_css;

}

/**
 * Returns CSS for the typography.
 *
 *
 * @param array $body_typo Color scheme body typography.
 *
 * @return string typography CSS.
 */
function cargohub_get_heading_font( $key, $heading ) {

	$inline_css   = '';
	$heading_typo = cargohub_get_option( $heading );

	if ( $heading_typo ) {
		if ( isset( $heading_typo['font-family'] ) && strtolower( $heading_typo['font-family'] ) !== 'open sans' ) {
			$inline_css .= $key . '{font-family:' . rtrim( trim( $heading_typo['font-family'] ), ',' ) . ', Arial, sans-serif}';
		}
	}

	if ( empty( $inline_css ) ) {
		return;
	}

	return <<<CSS
	{$inline_css}
CSS;
}
Back to Directory File Manager