<?php
if (!defined('ABSPATH')) exit();
if (class_exists('MainPublicUlp')) return;
class MainPublicUlp{
	/**
	 * @param none
	 * @return none
	 */
	public function __construct(){}
	/**
	 * @param none
	 * @return none
	 */
	public static function run(){
		self::loadDependencies();
		add_action('init', array('MainPublicUlp', 'init'));
		add_action('wp_enqueue_scripts', array('MainPublicUlp', 'assets'));
	}
	/**
	 * @param none
	 * @return none
	 */
	public static function assets(){
		wp_enqueue_style('ulp_font_awesome', ULP_URL . 'assets/css/font-awesome.css');
		wp_enqueue_style('ulp_main_public_style', ULP_URL . 'assets/css/public.css');
		wp_enqueue_style('ulp_sweet_alert_css', ULP_URL . 'assets/css/sweetalert.css');
		wp_enqueue_script('jquery');
		wp_enqueue_script('ulp_main_easytimer', ULP_URL . 'assets/js/easytimer.js', array(), null);
		wp_register_script('ulp_main_public', ULP_URL . 'assets/js/public.js', array(), null);
		wp_localize_script('ulp_main_public', 'ulp_site_url', get_site_url());
		wp_localize_script('ulp_main_public', 'ulp_messages', self::messages_for_javascript() );
		wp_enqueue_script('ulp_main_public', ULP_URL . 'assets/js/public.js', array(), null);
		wp_enqueue_script('ulp_sweet_alert', ULP_URL . 'assets/js/sweetalert.js', array(), null);
		wp_enqueue_script('ulp_jquery_form_module', ULP_URL . 'assets/js/jquery.form.js', array(), null);
		wp_enqueue_script('ulp-jquery.uploadfile', ULP_URL . 'assets/js/jquery.uploadfile.min.js', array(), null);
		wp_enqueue_script('jquery-ui-core');
		wp_enqueue_script('jquery-ui-sortable');
		wp_enqueue_script('jquery-ui-draggable');
		wp_enqueue_script('jquery-ui-droppable');
		wp_enqueue_script( 'ulp_printThis', ULP_URL . 'assets/js/printThis.js', array(), null );

		if (is_rtl()){
				wp_enqueue_style('ulp_main_public_rtl', ULP_URL . 'assets/css/public_rtl.css', array(), null);
		}
	}
	/**
	 * @param none
	 * @return none
	 */
	public static function loadDependencies(){
			//require_once ULP_PATH . 'classes/Ulp_Permalinks.php';
	}
	/**
	 * @param none
	 * @return none
	 */
	public static function init(){
		require_once ULP_PATH . 'classes/public/PublicInitUlp.class.php';
		$PublicInitUlp = new PublicInitUlp();
	}
	public static function messages_for_javascript(){
			return json_encode([
					'error' 								=> __('Error', 'ulp'),
					'general_error' 				=> __("An error have occued, please try again later!", 'ulp'),
					'payment_type_error' 		=> __('Please select a payment type!', 'ulp'),
					'delete_post' 					=> __('Are you sure you want to delete this post', 'ulp'),
					'delete_it' 						=> __("Yes, delete it!", 'ulp'),
					'cannot_delete'					=> __('You cannot delete this post!', 'ulp'),
					'toggle_section' 				=> __('Toggle Section', 'ulp'),
			]);
	}
}
