<?php

/**
 * ostech functions for getting inline styles from theme customizer
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package ostech
 */

if (!function_exists('ostech_theme_customizer_styles')) :
	function ostech_theme_customizer_styles()
	{

		// ostech color option

		$ostech_inline_style = '';
		$ostech_inline_style .= ':root {
			' . ostech_source_color_meta('get') . '
		}';

		$ostech_inner_banner_bg = get_theme_mod('page_header_bg_image');
		$ostech_inline_style .= '.page-header__bg { background-image: url(' . $ostech_inner_banner_bg . '); } ';

		$ostech_inner_banner_shape_two = get_theme_mod('page_header_shape_two');
		$ostech_inline_style .= '.page-header__bg::before { background-image: url(' . $ostech_inner_banner_shape_two . '); } ';

		$ostech_preloader_icon = get_theme_mod('preloader_image');
		if ($ostech_preloader_icon) {
			$ostech_inline_style .= '.preloader .preloader__image { background-image: url(' . $ostech_preloader_icon . '); } ';
		}

		if (is_page()) {
			$ostech_page_header_bg = empty(get_post_meta(get_the_ID(), 'ostech_set_header_image', true)) ? get_theme_mod('page_header_bg_image') : get_post_meta(get_the_ID(), 'ostech_set_header_image', true);

			$ostech_inline_style .= '.page-header__bg { background-image: url(' . $ostech_page_header_bg . '); }';
		}

		if (is_singular('post')) {
			$ostech_post_header_bg = empty(get_post_meta(get_the_ID(), 'ostech_set_header_image', true)) ? get_theme_mod('page_header_bg_image') : get_post_meta(get_the_ID(), 'ostech_set_header_image', true);

			$ostech_inline_style .= '.page-header__bg  { background-image: url(' . $ostech_post_header_bg . '); }';
		}


		wp_add_inline_style('ostech-style', $ostech_inline_style);
	}
endif;

add_action('wp_enqueue_scripts', 'ostech_theme_customizer_styles', 991);
