<?php if( ! defined( 'ABSPATH' ) ) exit;

/**
 * Enqueue scripts and styles.
 */
function live_news_animations_scripts() {	
	wp_enqueue_style( 'live_news-aos-css', get_template_directory_uri() . '/include/animations/aos.css' );
	wp_enqueue_script( 'live_news-aos-js', get_template_directory_uri() . '/include/animations/aos.js', array(), '', true);
	wp_enqueue_script( 'live_news-aos-options-js', get_template_directory_uri() . '/include/animations/aos-options.js', array(), '', true);
}
add_action( 'wp_enqueue_scripts', 'live_news_animations_scripts' );

function  live_news_animation ($animation) {
	if ( get_theme_mod( $animation ) != "none" and get_theme_mod( $animation ) != ""  )  {
		return "data-aos-delay='100'"." ".
		"data-aos-duration='500'"." ".
		"data-aos='".esc_html ( get_theme_mod( $animation ) )."'";
	}
	if ( get_theme_mod( $animation  ) == "" ) {
		return "data-aos-delay='100'"." ".
		"data-aos-duration='500'"." ".
		"data-aos='slide-up'";		
	}
}

function live_news_animation_calender () {
		return "data-aos-delay='400'"." ".
		"data-aos-duration='500'"." ".
		"data-aos='flip-up'";
}

function live_news_animations() {
	$array = array(
				'' => esc_attr__( 'Default', 'live-news' ),			
				'none' => esc_attr__( 'Deactivate Animation', 'live-news' ),			
				'fade' => esc_attr__( 'fade', 'live-news' ),
				'fade-up' => esc_attr__( 'fade-up', 'live-news' ),
				'fade-down' => esc_attr__( 'fade-down', 'live-news' ),
				'fade-left' => esc_attr__( 'fade-left', 'live-news' ),
				'fade-right' => esc_attr__( 'fade-right', 'live-news' ),
				'fade-up-right' => esc_attr__( 'fade-up-right', 'live-news' ),
				'fade-up-left' => esc_attr__( 'fade-up-left', 'live-news' ),
				'fade-down-right' => esc_attr__( 'fade-down-right', 'live-news' ),
				'fade-down-left' => esc_attr__( 'fade-down-left', 'live-news' ),
				'flip-up' => esc_attr__( 'flip-up', 'live-news' ),
				'flip-down' => esc_attr__( 'flip-down', 'live-news' ),
				'flip-left' => esc_attr__( 'flip-left', 'live-news' ),
				'flip-right' => esc_attr__( 'flip-right', 'live-news' ),
				'slide-up' => esc_attr__( 'slide-up', 'live-news' ),
				'slide-down' => esc_attr__( 'slide-down', 'live-news' ),
				'slide-left' => esc_attr__( 'slide-left', 'live-news' ),
				'slide-right' => esc_attr__( 'slide-right', 'live-news' ),
				'zoom-in' => esc_attr__( 'zoom-in', 'live-news' ),
				'zoom-in-up' => esc_attr__( 'zoom-in-up', 'live-news' ),
				'zoom-in-down' => esc_attr__( 'zoom-in-down', 'live-news' ),
				'zoom-in-left' => esc_attr__( 'zoom-in-left', 'live-news' ),
				'zoom-in-right' => esc_attr__( 'zoom-in-right', 'live-news' ),
				'zoom-out' => esc_attr__( 'zoom-out', 'live-news' ),
				'zoom-out-up' => esc_attr__( 'zoom-out-up', 'live-news' ),
				'zoom-out-down' => esc_attr__( 'zoom-out-down', 'live-news' ),
				'zoom-out-left' => esc_attr__( 'zoom-out-left', 'live-news' ),
				'zoom-out-right' => esc_attr__( 'zoom-out-right', 'live-news' ),
				);
	return $array;
}


		function live_news_sanitize_animations( $input ) {

			$valid = live_news_animations();

			if ( array_key_exists( $input, $valid ) ) {
				return $input;
			} else {
				return '';
			}
		}
		
function live_news_animations_customize_register( $wp_customize ) {
 
		$wp_customize->add_panel( 'live_news_panel_animations' , array(
			'title'       => __( 'Animations', 'live-news' ),
			'priority'   => 7,
		) );


/************************************
* Animation Articles
************************************/

		$wp_customize->add_section( 'live_news_animations_section_articles' , array(
			'title'       => __( 'Animation Articles', 'live-news' ),
			'panel'       => 'live_news_panel_animations',
			'priority'   => 64,
		) );
		
		$wp_customize->add_setting( 'live_news_articles_animation', array (
			'sanitize_callback' => 'live_news_sanitize_animations',
		) );
		
		$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'live_news_articles_animation', array(
			'label'    => __( 'Animation Articles', 'live-news' ),
			'description'       => __( 'Animations of all elements - PRO version of the theme.', 'live-news' ),
			'section'  => 'live_news_animations_section_articles',
			'settings' => 'live_news_articles_animation',
			'type'     =>  'select',
            'choices'  => live_news_animations(),		
		) ) );
		
}
add_action( 'customize_register', 'live_news_animations_customize_register' );
