<?php
/**
 * Script Class
 *
 * Handles the script and style functionality of plugin
 *
 * @package Amyra
 * @since 1.0
 */

// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;

class Amyra_Script {
	
	function __construct() {

		// Action to add style in front end
		add_action( 'wp_enqueue_scripts', array($this, 'amyra_lite_front_styles'), 1 );

		// Action to add script in front end
		add_action( 'wp_enqueue_scripts', array($this, 'amyra_lite_front_scripts'), 1 );
      
                
	}      
    
   

	/**
	 * Enqueue styles for front-end
	 * 
	 * @package Amyra
	 * @since 1.0
	 */
	function amyra_lite_front_styles() {
		global $wp_styles;

		// Taking some variables
		$site_gf_fonts = array();

		// Font Awesome CSS
		wp_register_style( 'font-awesome', AMYRA_LITE_URL . '/assets/css/font-awesome.min.css', array(), AMYRA_LITE_VERSION);
		wp_enqueue_style( 'font-awesome' );		

		// Loads theme main stylesheet
		wp_enqueue_style( 'amyra-lite-style', get_stylesheet_uri(), array(), AMYRA_LITE_VERSION);
                	
	}

	/**
	 * Enqueue scripts for front-end
	 * 
	 * @package Amyra
	 * @since 1.0
	 */
	function amyra_lite_front_scripts() {
		
		global $post;
		$post_id = isset($post->ID) ? $post->ID : '';
                
                $post_view_count	= 0;
                
                $supported_posts = array('post','page'); // suppoterd post type
                
		if( !empty($post_id) && !empty($supported_posts) && is_singular($supported_posts) && !is_preview() && !is_front_page() && !is_home() && !is_feed() && !is_robots() ) {
			$post_view_count = $post_id;
		}
                
		/*
		 * Adds JavaScript to pages with the comment form to support
		 * sites with threaded comments (when in use).
		 */
		if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ){
			wp_enqueue_script( 'comment-reply' );
		}
		
		// Masonry Script
		$blog_layout 	= amyra_lite_get_theme_mod( 'blog_layout' );
		$cat_layout		= amyra_lite_get_theme_mod( 'cat_layout' );
		if( !empty($blog_layout) || !empty($cat_layout) ) {
			wp_enqueue_script('masonry');
		}

		// Navigation Js
		wp_register_script( 'amyra-lite-navigation-js', AMYRA_LITE_URL . '/assets/js/navigation.js', array('jquery'), AMYRA_LITE_VERSION, true);
		wp_enqueue_script( 'amyra-lite-navigation-js' );
		
		// Skip Link Focus Fix Js
		wp_register_script( 'amyra-lite-skip-link-js', AMYRA_LITE_URL . '/assets/js/skip-link-focus-fix.js', array('jquery'), AMYRA_LITE_VERSION, true);
		wp_enqueue_script( 'amyra-lite-skip-link-js' );

		// Skip Link Focus Fix Js
		wp_register_script( 'amyra-lite-sticky-sidebar-js', AMYRA_LITE_URL . '/assets/js/theia-sticky-sidebar.js', array('jquery'), AMYRA_LITE_VERSION, true);
		wp_enqueue_script( 'amyra-lite-sticky-sidebar-js' );

		// Public Js
		wp_register_script( 'amyra-lite-public-js', AMYRA_LITE_URL . '/assets/js/public.js', array('jquery'), AMYRA_LITE_VERSION, true);
             
		wp_enqueue_script( 'amyra-lite-public-js' );	
                
               
        }
}

$amyra_lite_script = new Amyra_Script();