<?php

namespace Layerdrops\Ostech;

class Assets {

	/**
	 * Class constructor
	 */
	function __construct() {
		add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ], 991 );
		add_action( 'admin_enqueue_scripts', [ $this, 'register_assets' ] );
	}

	/**
	 * All available scripts
	 *
	 * @return array
	 */
	public function get_scripts() {
		return [ 
			'bootstrap-select' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/bootstrap-select/js/bootstrap-select.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/bootstrap-select/js/bootstrap-select.min.js' ),
				'deps' => [ 'jquery', 'bootstrap' ]
			],
			'jquery-bxslider' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/bxslider/jquery.bxslider.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/bxslider/jquery.bxslider.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'countdown' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/countdown/countdown.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/countdown/countdown.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'jarallax' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jarallax/jarallax.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jarallax/jarallax.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'jquery-ajaxchimp' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jquery-ajaxchimp/jquery.ajaxchimp.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jquery-ajaxchimp/jquery.ajaxchimp.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'jquery-appear' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jquery-appear/jquery.appear.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jquery-appear/jquery.appear.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'jquery-circle-progress' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jquery-circle-progress/jquery.circle-progress.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jquery-circle-progress/jquery.circle-progress.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'jquery-magnific-popup' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jquery-magnific-popup/jquery.magnific-popup.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jquery-magnific-popup/jquery.magnific-popup.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'odometer' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/odometer/odometer.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/odometer/odometer.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'owl-carousel' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/owl-carousel/owl.carousel.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/owl-carousel/owl.carousel.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'swiper' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/swiper/swiper.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/swiper/swiper.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'wow' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/wow/wow.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/wow/wow.js' ),
				'deps' => [ 'jquery' ]
			],

			'sharer' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/sharer/sharer.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/sharer/sharer.min.js' ),
				'deps' => [ 'jquery' ]
			],

			'circletype' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/circleType/jquery.circleType.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/circleType/jquery.circleType.js' ),
				'deps' => [ 'jquery' ]
			],

			'circleletter' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/circleType/jquery.lettering.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/circleType/jquery.lettering.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'select2' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/select2/js/select2.min.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/select2/js/select2.min.js' ),
				'deps' => [ 'jquery' ]
			],
			'timepicker' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/timepicker/timePicker.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/timepicker/timePicker.js' ),
				'deps' => [ 'jquery' ]
			],
			'ostech-addon-customizer' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/js/ostech-addon-customizer.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/js/ostech-addon-customizer.js' ),
				'deps' => [ 'jquery', 'select2' ]
			],
			'ostech-addon-script' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/js/ostech-addon.js',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/js/ostech-addon.js' ),
				'deps' => [ 'jquery' ]
			]
		];
	}

	/**
	 * All available styles
	 *
	 * @return array
	 */
	public function get_styles() {
		return [ 
			'animate' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/animate/animate.min.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/animate/animate.min.css' )
			],
			'custom-animate' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/animate/custom-animate.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/animate/custom-animate.css' )
			],
			'bootstrap-select' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/bootstrap-select/css/bootstrap-select.min.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/bootstrap-select/css/bootstrap-select.min.css' )
			],
			'bxslider' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/bxslider/jquery.bxslider.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/bxslider/jquery.bxslider.css' )
			],
			'jarallax' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jarallax/jarallax.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jarallax/jarallax.css' )
			],
			'jquery-magnific-popup' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jquery-magnific-popup/jquery.magnific-popup.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jquery-magnific-popup/jquery.magnific-popup.css' )
			],
			'odometer' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/odometer/odometer.min.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/odometer/odometer.min.css' )
			],
			'owl-carousel' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/owl-carousel/owl.carousel.min.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/owl-carousel/owl.carousel.min.css' )
			],
			'owl-theme' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/owl-carousel/owl.theme.default.min.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/owl-carousel/owl.theme.default.min.css' )
			],
			'reey-font' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/reey-font/stylesheet.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/reey-font/stylesheet.css' )
			],
			'alagambe-font' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/alagambe-font/stylesheet.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/alagambe-font/stylesheet.css' )
			],
			'swiper' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/swiper/swiper.min.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/swiper/swiper.min.css' )
			],
			'select2' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/select2/css/select2.min.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/select2/css/select2.min.css' )
			],
			'jquery-ui' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/jquery-ui/jquery-ui.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/jquery-ui/jquery-ui.css' )
			],
			'timepicker' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/vendors/timepicker/timePicker.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/vendors/timepicker/timePicker.css' )
			],
			'ostech-addon-style' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/css/ostech-addon.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/css/ostech-addon.css' )
			],
			'ostech-addon-admin-style' => [ 
				'src' => OSTECH_ADDON_ASSETS . '/css/ostech-addon-admin.css',
				'version' => filemtime( OSTECH_ADDON_PATH . '/assets/css/ostech-addon-admin.css' )
			]
		];
	}

	/**
	 * Register scripts and styles
	 *
	 * @return void
	 */
	public function register_assets() {
		$scripts = $this->get_scripts();
		$styles = $this->get_styles();

		foreach ( $scripts as $handle => $script ) {
			$deps = isset( $script['deps'] ) ? $script['deps'] : false;

			wp_register_script( $handle, $script['src'], $deps, $script['version'], true );
		}

		foreach ( $styles as $handle => $style ) {
			$deps = isset( $style['deps'] ) ? $style['deps'] : false;

			wp_register_style( $handle, $style['src'], $deps, $style['version'] );
		}
	}
}
