<?php
/*
 * All CSS and JS files are enqueued from this file
 * Author & Copyright:themexshaper
 * URL: http://themeforest.net/user/themexshaper
 */

/**
 * Enqueue Files for FrontEnd
 */
function confin_google_font_url() {
    $font_url = '';
    if ( 'off' !== esc_html__( 'on', 'confin' ) ) {
        $font_url = add_query_arg( 'family', urlencode( 'Heebo:300,400,500,700|Montserrat:400,500,600,700' ), "//fonts.googleapis.com/css" );
    }
    return $font_url;
}

if ( ! function_exists( 'confin_scripts_styles' ) ) {
  function confin_scripts_styles() {

    // Styles
    wp_enqueue_style( 'themify-icons', CONFIN_CSS .'/themify-icons.css', array(), '4.6.3', 'all' );
    wp_enqueue_style( 'flaticon', CONFIN_CSS .'/flaticon.css', array(), '1.0.0', 'all' );
    wp_enqueue_style( 'bootstrap', CONFIN_CSS .'/bootstrap.min.css', array(), '3.3.7', 'all' );
    wp_enqueue_style( 'animate', CONFIN_CSS .'/animate.css', array(), '3.5.1', 'all' );
    wp_enqueue_style( 'owl-carousel', CONFIN_CSS .'/owl.carousel.css', array(), '2.0.0', 'all' );
    wp_enqueue_style( 'owl-theme', CONFIN_CSS .'/owl.theme.css', array(), '2.0.0', 'all' );
    wp_enqueue_style( 'slick', CONFIN_CSS .'/slick.css', array(), '1.6.0', 'all' );
    wp_enqueue_style( 'slick-theme', CONFIN_CSS .'/slick-theme.css', array(), '1.6.0', 'all' );
    wp_enqueue_style( 'owl-transitions', CONFIN_CSS .'/owl.transitions.css', array(), '2.0.0', 'all' );
    wp_enqueue_style( 'fancybox', CONFIN_CSS .'/jquery.fancybox.css', array(), '2.0.0', 'all' );
    wp_enqueue_style( 'confin-style', CONFIN_CSS .'/styles.css', array(), time(), 'all' );
    wp_enqueue_style( 'element', CONFIN_CSS .'/elements.css', array(), time(), 'all' );
    if ( !function_exists('cs_framework_init') ) {
      wp_enqueue_style('confin-default-style', get_template_directory_uri() . '/style.css', array(),  CONFIN_VERSION, 'all' );
    }
    wp_enqueue_style( 'confin-default-google-fonts', confin_google_font_url(), array(), CONFIN_VERSION, 'all' );
    // Scripts
    wp_enqueue_script( 'bootstrap', CONFIN_SCRIPTS . '/bootstrap.min.js', array( 'jquery' ), '3.3.7', true );
    wp_enqueue_script( 'imagesloaded');
    wp_enqueue_script( 'isotope', CONFIN_SCRIPTS . '/isotope.min.js', array( 'jquery' ), '2.2.2', true );
    wp_enqueue_script( 'appear', CONFIN_SCRIPTS . '/jquery.appear.min.js', array( 'jquery' ), '2.2.2', true );
    wp_enqueue_script( 'fancybox', CONFIN_SCRIPTS . '/fancybox.min.js', array( 'jquery' ), '2.1.5', true );
    wp_enqueue_script( 'masonry');
    wp_enqueue_script( 'owl-carousel', CONFIN_SCRIPTS . '/owl-carousel.js', array( 'jquery' ), '2.0.0', true );
    wp_enqueue_script( 'inheritence', CONFIN_SCRIPTS . '/inheritence.js', array( 'jquery' ), '1.4.0', true );
    wp_enqueue_script( 'countdown', CONFIN_SCRIPTS . '/countdown.js', array( 'jquery' ), '2.0.2', true );
    wp_enqueue_script( 'jquery-easing', CONFIN_SCRIPTS . '/jquery-easing.js', array( 'jquery' ), '1.4.0', true );
    wp_enqueue_script( 'wow', CONFIN_SCRIPTS . '/wow.min.js', array( 'jquery' ), '1.4.0', true );
    wp_enqueue_script( 'magnific-popup', CONFIN_SCRIPTS . '/magnific-popup.js', array( 'jquery' ), '1.1.0', true );
    wp_enqueue_script( 'slick-slider', CONFIN_SCRIPTS . '/slick-slider.js', array( 'jquery' ), '1.6.0', true );
    wp_enqueue_script( 'confin-scripts', CONFIN_SCRIPTS . '/scripts.js', array( 'jquery' ), time(), true );
    // Comments
    wp_enqueue_script( 'confin-validate-js', CONFIN_SCRIPTS . '/jquery.validate.min.js', array( 'jquery' ), '1.9.0', true );
    wp_add_inline_script( 'confin-validate-js', 'jQuery(document).ready(function($) {$("#commentform").validate({rules: {author: {required: true,minlength: 2},email: {required: true,email: true},comment: {required: true,minlength: 10}}});});' );

    // Responsive Active
    $confin_viewport = cs_get_option('theme_responsive');
    if( !$confin_viewport ) {
      wp_enqueue_style( 'confin-responsive', CONFIN_CSS .'/responsive.css', array(), CONFIN_VERSION, 'all' );
    }

    // Adds support for pages with threaded comments
    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
      wp_enqueue_script( 'comment-reply' );
    }

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

/**
 * Enqueue Files for BackEnd
 */
if ( ! function_exists( 'confin_admin_scripts_styles' ) ) {
  function confin_admin_scripts_styles() {

    wp_enqueue_style( 'confin-admin-main', CONFIN_CSS . '/admin-styles.css', true );
    wp_enqueue_style( 'flaticon', CONFIN_CSS . '/flaticon.css', true );
    wp_enqueue_style( 'themify-icons', CONFIN_CSS . '/themify-icons.css', true );

  }
  add_action( 'admin_enqueue_scripts', 'confin_admin_scripts_styles' );
}
