<?php

/**
 * Enqueue Google Analytics.
 */
//if (xs_get_option('theme_options', 'google_analytic') != "") {
//    enqueue_inline_script('google-analytic', xs_get_option('theme_options', 'google_analytic'), array(), null, false);
//}

/**
 * Enqueue custom Scripts.
 */
//if (xs_get_option('theme_options', 'custom_js') != "") {
//    enqueue_inline_script('xs-custom-js', xs_get_option('theme_options', 'custom_js'), array('jquery'), null, true);
//}

/**
 * Enqueue custom styles.
 */
if (xs_get_option('theme_options', 'custom_css') != "") {

    function xs_custom_blog_styles() {
        wp_add_inline_style('onevent-override', xs_get_option('theme_options', 'custom_css'));
    }

    add_action('wp_enqueue_scripts', 'xs_custom_blog_styles');
}

/**
 * Adding hook styles.
 */
add_action('wp_head', 'xs_hook_css');

function xs_hook_css() {
    $output = "<style></style>";
    echo $output;
}

/**
 * Enqueue blog Scripts.
 */
if (is_single() && xs_get_option('theme_options', 'blog_custom_js') != "") {
    enqueue_inline_script('custom-blog-js', xs_get_option('theme_options', 'blog_custom_js'), array('jquery'), null, true);
}

/**
 * Enqueue blog styles.
 */
if (is_single() && xs_get_option('theme_options', 'blog_custom_css') != "") {

    function xs_custom_blog_styles() {
        wp_add_inline_style('onevent-override', xs_get_option('theme_options', 'blog_custom_css'));
    }

    add_action('wp_enqueue_scripts', 'xs_custom_blog_styles');
}

// Retrive data


function xs_hook_js_print() {
$code = "
/* ==================================  GLOBAL  ==================================== */

var main_color = \"" . str_replace("#", "", xs_get_option('theme_options', 'main_color')) . "\"; // Orange: This is global main color for your template.

var page_background_color = \"" . str_replace("#", "", xs_get_option('theme_options', 'main_bg_color')) . "\"; // Light Grey: This is the page background color for your template.

var Heading_Font = \"Roboto\"; // thats your special Heading font

var Site_Font = \"Roboto\"; // thats your special body content font
var body_texture = \"body-bg1.png\"; // Change body texture here over the slideshow e.g. body-bg1.png, body-bg2.png, body-bg3.png, body-bg4.png


/* ================================  REGISTER FORM  =================================== */

/* SET REGISTER FORM SUCCESS MESSAGE */

var submitMessage = \"" . xs_get_option('theme_options', 'register_submit_message') . "\";

var successParagraph = \"" . xs_get_option('theme_options', 'register_success_peragraph') . "\";

var successBoxColor = \"" . str_replace("#", "", xs_get_option('theme_options', 'register_success_box_color')) . "\"; // Background color for the success box

var successBoxBorderStyle = \"" . xs_get_option('theme_options', 'register_success_box_border_style') . "\"; // Border Style  -  Example: solid, dotted, dashed, double

var successBox_Border_Color = \"" . str_replace("#", "", xs_get_option('theme_options', 'register_success_box_border_color')) . "\"; // Border color for success box

var textColor = \"" . str_replace("#", "", xs_get_option('theme_options', 'register_text_color')) . "\"; // text color for success box

/* ================================  SUBSCRIBE FORM  =================================== */

/* SET SUBSCRIBE FORM SUCCESS MESSAGE */

var sub_submitMessage = \"" . xs_get_option('theme_options', 'subscription_success_message') . "\";

var sub_successBoxColor = \"" . str_replace("#", "", xs_get_option('theme_options', 'subscription_success_box_color')) . "\"; // Background color for the success box

var sub_successBoxBorderStyle = \"" . xs_get_option('theme_options', 'subscription_success_box_border_style') . "\"; // Border Style  -  Example: solid, dotted, dashed, double

var sub_successBox_Border_Color = \"" . str_replace("#", "", xs_get_option('theme_options', 'subscription_success_box_border_color')) . "\"; // Border color for success box

var sub_textColor = \"" . str_replace("#", "", xs_get_option('theme_options', 'subscription_text_color')) . "\"; // text color for success box


";
$custom = xs_get_option('theme_options', 'custom_js');

echo "<script type='text/javascript'>$code</script>";
echo "<script type='text/javascript'>$custom</script>";

/**
 * Enqueue config Scripts.
 */
}
add_action('wp_footer', 'xs_hook_js_print', 98);

function xs_hook_js_ana() {
    $analytics = xs_get_option('theme_options', 'google_analytic');
    echo $analytics;
}
add_action('wp_footer', 'xs_hook_js_ana', 98);






if (xs_get_option('theme_options', 'main_template_style') == 'image') {



    function xs_hook_js() {
        $slideshow = '';
        $slides = xs_get_option('theme_options', 'main_slider');

        if (is_array($slides)) {
            foreach ($slides as $arr) {
                $slideshow .= "'" . $arr['img_src'] . "',";
            }
        }
        trim($slideshow, ",");
        $output = "
/* ================================  BACKGROUND SLIDESHOW  =================================== */
jQuery(document).ready(function($) {
$.backstretch([

  // you can additional images in here with comma separated values
" . $slideshow . "
  
  ], {
  fade: " . xs_get_option('theme_options', 'fading_speed') . ",
  duration: " . xs_get_option('theme_options', 'animation_pause') . "
});   

});";

        echo "<script>$output</script>";
    }

    add_action('wp_footer', 'xs_hook_js', 99);
}

