<?php 
/**
 * @package WordPress
 * @subpackage Campoal
 */

/**
 * Enqueue Semantic UI styles
 *
 * @since Campoal 1.7.4
 */
if( !function_exists('conikal_semantic_ui_style') ):
	function conikal_semantic_ui_style() {
		// Load stylesheets
		if (is_rtl()) {
			// rtl mode css
			wp_enqueue_style('semantic-ui', get_template_directory_uri() . '/css/semantic.rtl.min.css', array(), '2.4.1');
		} else {
			// ltr mode css
			wp_enqueue_style('semantic-ui', get_template_directory_uri() . '/css/semantic.min.css', array(), '2.8.3');
		}
	}
endif;
add_action( 'wp_enqueue_scripts', 'conikal_semantic_ui_style', 0 );


/**
 * Enqueue scripts and styles
 *
 * @since Campoal 1.0.0
 */
if( !function_exists('conikal_styles_scripts') ):
	function conikal_styles_scripts() {
		global $campoal_options;
		global $post;
		global $current_user;

		$verify_transition 		= isset($campoal_options['conikal_verify_notification_transition_field']) ? $campoal_options['conikal_verify_notification_transition_field'] : 'overlay';
		$verify_dimmer 			= isset($campoal_options['conikal_verify_notification_dimmer_field']) ? $campoal_options['conikal_verify_notification_dimmer_field'] : 0;
		$verify_closable 		= isset($campoal_options['conikal_verify_notification_closable_field']) ? $campoal_options['conikal_verify_notification_closable_field'] : 0;
		$editor_style 			= isset($campoal_options['conikal_editor_style_field']) ? $campoal_options['conikal_editor_style_field'] : 'markdown';
		$spell_checker 			= isset($campoal_options['conikal_markdown_spell_checker_field']) ? $campoal_options['conikal_markdown_spell_checker_field'] : 1;
		$smooth_scroll 			= isset($campoal_options['conikal_smooth_scroll_field']) ? $campoal_options['conikal_smooth_scroll_field'] : 0;
		$ajax_pages 			= isset($campoal_options['conikal_ajax_pages_field']) ? $campoal_options['conikal_ajax_pages_field'] : 0;
		$rtl_mode 				= (is_rtl() ? 1 : 0);
		$type_preloader 		= isset($campoal_options['conikal_type_ajax_preloader_field']) ? $campoal_options['conikal_type_ajax_preloader_field'] : 'none';
		$html_preloader 		= conikal_preloader_html($type_preloader);
		$signature_update_time 	= isset($campoal_options['conikal_signature_update_time_field']) ? $campoal_options['conikal_signature_update_time_field'] : 0;
		$header_menu_color 		= isset($campoal_options['conikal_header_menu_color_field']) ? $campoal_options['conikal_header_menu_color_field'] : '';
		$home_menu_text_color 	= isset($campoal_options['conikal_home_menu_text_color_field']) ? $campoal_options['conikal_home_menu_text_color_field'] : '';
		$home_victory 			= isset($campoal_options['conikal_home_victory_field']) ? $campoal_options['conikal_home_victory_field'] : 0;
		$home_victory_hide_logined = isset($campoal_options['conikal_home_victory_hide_logined_field']) ? $campoal_options['conikal_home_victory_hide_logined_field'] : 0;
		$unsign 				= isset($campoal_options['conikal_disable_unsign_field']) ? $campoal_options['conikal_disable_unsign_field'] : 0;
		$action_after_sign 		= isset($campoal_options['conikal_action_after_sign_field']) ? $campoal_options['conikal_action_after_sign_field'] : '';
		$view_counter 			= isset($campoal_options['conikal_view_counter_field']) ? $campoal_options['conikal_view_counter_field'] : 0;
		$type_menu 				= isset($campoal_options['conikal_type_header_menu_field']) ? $campoal_options['conikal_type_header_menu_field'] : 'none';
		$mobile_sign_style 		= isset($campoal_options['conikal_mobile_sign_style_field']) ? $campoal_options['conikal_mobile_sign_style_field'] : 'button';
		$mobile_sign_scroll 	= isset($campoal_options['conikal_mobile_sign_scroll_field']) ? $campoal_options['conikal_mobile_sign_scroll_field'] : 1;
		$mobile_menu_animation 	= isset($campoal_options['conikal_mobile_menu_animation_field']) ? $campoal_options['conikal_mobile_menu_animation_field'] : 'overlay';
		$maximum_category 		= isset($campoal_options['conikal_maximum_category_field']) ? $campoal_options['conikal_maximum_category_field'] : 1;
		$maximum_topics 		= isset($campoal_options['conikal_maximum_topics_field']) ? $campoal_options['conikal_maximum_topics_field'] : 5;
		$min_characters 		= isset($campoal_options['conikal_s_min_characters_field']) ? $campoal_options['conikal_s_min_characters_field'] : 3;
		$max_results 			= isset($campoal_options['conikal_s_max_results_field']) ? $campoal_options['conikal_s_max_results_field'] : 8;
		$search_type 			= isset($campoal_options['conikal_s_type_field']) ? $campoal_options['conikal_s_type_field'] : 'category';
		$search_settings 		= array(
			'conikal_s_link_field' 			=> isset($campoal_options['conikal_s_link_field']) ? $campoal_options['conikal_s_link_field'] : 0,
			'conikal_s_supporters_field' 	=> isset($campoal_options['conikal_s_supporters_field']) ? $campoal_options['conikal_s_supporters_field'] : 0,
			'conikal_s_image_field' 		=> isset($campoal_options['conikal_s_image_field']) ? $campoal_options['conikal_s_image_field'] : 0,
			'conikal_s_description_field' 	=> isset($campoal_options['conikal_s_description_field']) ? $campoal_options['conikal_s_description_field'] : 0,
		);
		$default_font 			= isset($campoal_options['conikal_default_font_field']) ? $campoal_options['conikal_default_font_field'] : 1;
		$theme_font_family 		= isset($campoal_options['conikal_theme_font_family_field']) && $campoal_options['conikal_theme_font_family_field'] != '' ? $campoal_options['conikal_theme_font_family_field'] : 'Sen';
		$default_font_family 	= isset($campoal_options['conikal_default_font_family_field']) && $campoal_options['conikal_default_font_family_field'] != '' ? $campoal_options['conikal_default_font_family_field'] : 'Sen';
		$google_api_key 		= ( isset($campoal_options['conikal_google_api_key_field']) && !empty($campoal_options['conikal_google_api_key_field']) ) ? $campoal_options['conikal_google_api_key_field'] : '';
		$google_place_types 	= ( isset($campoal_options['conikal_google_place_types_field']) && !empty($campoal_options['conikal_google_place_types_field']) ) ? $campoal_options['conikal_google_place_types_field'] : '';
		$google_signin 			= isset($campoal_options['conikal_google_login_field']) ? $campoal_options['conikal_google_login_field'] : 0;
		$google_client_id 		= isset($campoal_options['conikal_google_id_field']) ? $campoal_options['conikal_google_id_field'] : 0;
		$external_link 			= isset($campoal_options['conikal_external_link_field']) ? $campoal_options['conikal_external_link_field'] : 0;
		$oauth_page_url 		= isset($campoal_options['conikal_page_oauth_redirect_field']) ? $campoal_options['conikal_page_oauth_redirect_field'] : 0;
		$oauth_page_url 		= (!empty($oauth_page_url) ? get_page_link($oauth_page_url) : 0);
		$api_page_url 			= isset($campoal_options['conikal_page_api_field']) ? $campoal_options['conikal_page_api_field'] : 0;
		$api_page_url 			= (!empty($api_page_url) ? get_page_link($api_page_url) : 0);
		$current_page_template 	= is_page() ? get_page_template_slug($post->ID) : '';
		$recaptcha_site_key     = isset($campoal_options['conikal_google_recaptcha_key_field']) ? $campoal_options['conikal_google_recaptcha_key_field'] : '';
        $recaptcha_secret_key   = isset($campoal_options['conikal_google_recaptcha_secret_field']) ? $campoal_options['conikal_google_recaptcha_secret_field'] : '';
        $enable_reCaptcha       = isset($campoal_options['conikal_google_recaptcha_field']) ? $campoal_options['conikal_google_recaptcha_field'] : 0;
        $recaptcha_position     = isset($campoal_options['conikal_google_recaptcha_position_field']) ? $campoal_options['conikal_google_recaptcha_position_field'] : 'inline';
        $receiver_step 			= isset($campoal_options['conikal_receiver_step_field']) ? $campoal_options['conikal_receiver_step_field'] : 1;
        $fundraising_step 		= isset($campoal_options['conikal_fundraising_step_field']) ? $campoal_options['conikal_fundraising_step_field'] : 0;
        $video_watching_time 	= isset($campoal_options['conikal_video_watching_time_field']) ? $campoal_options['conikal_video_watching_time_field'] : 30;
        $video_embed_placeholder 	= isset($campoal_options['conikal_video_embed_placeholder_field']) ? $campoal_options['conikal_video_embed_placeholder_field'] : 1;
        $close_promo_time		= isset($campoal_options['conikal_close_promo_time_field']) && $campoal_options['conikal_close_promo_time_field'] != '' ? $campoal_options['conikal_close_promo_time_field'] : 'session';
        $top_menu = isset($campoal_options['conikal_top_menu_field']) && !wp_is_mobile() ? $campoal_options['conikal_top_menu_field'] : 0;
        $supporters_donors_style = isset($campoal_options['conikal_supporters_donors_style_field']) ? $campoal_options['conikal_supporters_donors_style_field'] : 'list';
        $supporter_counter_animation = isset($campoal_options['conikal_supporter_counter_animation_field']) && !wp_is_mobile() ? $campoal_options['conikal_supporter_counter_animation_field'] : 0;
		$cookie_notice 			= isset($campoal_options['conikal_cookie_notice_field']) ? $campoal_options['conikal_cookie_notice_field'] : 0;
		$use_inverted_logo 		= isset($campoal_options['conikal_use_inverted_logo_field']) ? $campoal_options['conikal_use_inverted_logo_field'] : 1;
		$modal_transition 		= isset($campoal_options['conikal_modal_transition_field']) ? $campoal_options['conikal_modal_transition_field'] : 'scale';

       	// get account acctivation status and verify email settings
        $verification_email = isset($campoal_options['conikal_verification_email_field']) ? $campoal_options['conikal_verification_email_field'] : 1;
        $force_verify = isset($campoal_options['conikal_force_verify_field']) ? $campoal_options['conikal_force_verify_field'] : 0;
		$account_activation = get_user_meta($current_user->ID, 'is_activated', true);
        
		// Google reCaptcha mode
        $reCaptcha_status = 0;
        if ($enable_reCaptcha != 0 && !empty($recaptcha_site_key) && !empty($recaptcha_secret_key)) {
        	$reCaptcha_status = 1;
        }

		// Main style
		wp_enqueue_style('campoal-style', get_stylesheet_uri(), array(), wp_get_theme()->get('Version'));

		// Add iniline custom color and typography css
		wp_add_inline_style('campoal-style', conikal_custom_style_css());
		
		// Loader style
		if ($type_preloader != 'none') {
			wp_enqueue_style('spinkit', get_template_directory_uri().'/css/spinkit.min.css', array(), '1.2.5');
		}

		// Load default font
		if ((!class_exists('ReduxFramework') || $default_font == 1) && $default_font_family != 'system') {
			if ($theme_font_family != 'system' && $theme_font_family != 'custom') {
				wp_enqueue_style('campoal-fonts', get_template_directory_uri() . '/css/' . esc_attr($theme_font_family) . '.css', array(), '1.0.0');
			}
		}

		// Print style page
		wp_enqueue_style( 'campoal-print-style', get_template_directory_uri() . '/css/print.css', array(), wp_get_theme()->get('Version'), 'print' );

		// SimpleEMDE markdown editor style
		wp_enqueue_style( 'simplemde-style', get_template_directory_uri() . '/css/simplemde.min.css', array(), '1.11.2');

		// RTL custom style
		if (is_rtl()) {
			wp_enqueue_style('campoal-style-rtl', get_template_directory_uri() . '/rtl.css', array(), wp_get_theme()->get('Version'));
		}

		// Load scripts
		wp_enqueue_script('semantic-ui', get_template_directory_uri() . '/js/semantic.min.js', array('jquery'), '2.8.3', true);
		wp_enqueue_script('slick', get_template_directory_uri() . '/js/slick.min.js',array('jquery'), '1.8.0', true);
		wp_enqueue_script('jquery-lazy', get_template_directory_uri() . '/js/jquery.lazy.min.js',array('jquery'), '1.7.9', true);
		wp_enqueue_script('slimscroll', get_template_directory_uri() . '/js/jquery.slimscroll.min.js', array('jquery'), '1.3.0', true);
		if ($ajax_pages == 1 && is_user_logged_in()) {
			wp_enqueue_script('campoal-bjax', get_template_directory_uri() . '/js/bjax.min.js',array('jquery'), '1.0.2', true);
		}

		// Google Maps API
		if ( !empty( $google_api_key ) ) {
			wp_enqueue_script('gmaps', '//maps.googleapis.com/maps/api/js?key=' . esc_attr($google_api_key) . '&amp;libraries=geometry&amp;libraries=places&amp;language=' . get_locale(), array(), '1.0', true);
		}

		// Smothscroll
		if ($smooth_scroll == 1 && !wp_is_mobile()) {
			wp_enqueue_script('smoothscroll', get_template_directory_uri().'/js/smoothscroll.min.js', array('jquery'), '1.4.6', true);
		}

		// Cookie contest notice
		if ($cookie_notice == 1) {
			wp_enqueue_script('cookie', get_template_directory_uri().'/js/jquery.cookie.js', array('jquery'), '1.4.1', true);
		}

		// Load Chart js and data when user on Dashboard page
		if (is_page_template('dashboard-petition.php')) {
			$dashboard_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : '';
			if ($dashboard_section == 'dashboard') {
				wp_enqueue_script('chartjs', get_template_directory_uri().'/js/Chart.min.js', array('jquery'), '2.8.0', true);
				wp_enqueue_script('moment', get_template_directory_uri().'/js/moment.min.js', array('jquery'), '2.12.1', true);
				wp_enqueue_script('daterangepicker', get_template_directory_uri().'/js/daterangepicker.min.js', array('jquery'), '3.14.1', true);
				wp_enqueue_script('date_range', get_template_directory_uri().'/js/date_range.js', array('jquery'), wp_get_theme()->get('Version'), true);
			}
		}

		// SimpleEMDE markdown editor
		wp_enqueue_script('simplemde', get_template_directory_uri() . '/js/simplemde.min.js', array('jquery'), '1.11.2', true);

		// Gooogle reCaptcha
		if ($enable_reCaptcha != 0 && !empty($recaptcha_site_key) && !empty($recaptcha_secret_key)) {
            wp_enqueue_script('google-reCaptcha', 'https://www.google.com/recaptcha/api.js?onload=conikalReCaptchaLoad&hl=' . get_locale() . '&render=' . esc_attr($recaptcha_site_key), array('jquery'), '3.0', true);
            wp_enqueue_script('campoal-reCaptcha', get_template_directory_uri() . '/js/google-recaptcha.js', array('jquery', 'google-reCaptcha'), wp_get_theme()->get('Version'), true);

            $reCaptcha_data = array(
                'site_key' => esc_js($recaptcha_site_key),
                'secret_key' => esc_js($recaptcha_secret_key),
                'position_badge' => esc_js($recaptcha_position),
            );
            wp_localize_script('campoal-reCaptcha', 'grecaptcha_data', $reCaptcha_data);
        }

		// Semantic UI js add-on library
        wp_enqueue_script('calendar', get_template_directory_uri() . '/js/calendar.min.js', array('jquery'), '2.8.3', true);
        wp_enqueue_script('toast', get_template_directory_uri() . '/js/toast.min.js', array('jquery'), '2.8.3', true);

		// Custom javascript
		wp_enqueue_script('campoal-services', get_template_directory_uri().'/js/services.js', array('jquery'), wp_get_theme()->get('Version'), true);
		wp_enqueue_script('campoal-main', get_template_directory_uri().'/js/main.js', array('jquery'), wp_get_theme()->get('Version'), true);

		// Toast config setting
		$toast_settings = array(
			'transition' => array(
				'showMethod'   => isset($campoal_options['conikal_toast_transiation_show_field']) ? $campoal_options['conikal_toast_transiation_show_field'] : 'fly left',
				'showDuration' => isset($campoal_options['conikal_toast_show_duration_field']) ? $campoal_options['conikal_toast_show_duration_field'] : 800,
				'hideMethod'   => isset($campoal_options['conikal_toast_transiation_hide_field']) ? $campoal_options['conikal_toast_transiation_hide_field'] : 'fly left',
				'hideDuration' => isset($campoal_options['conikal_toast_hide_duration_field']) ? $campoal_options['conikal_toast_hide_duration_field'] : 500,
				'closeEasing'  => 'easeOutCubic'
			),
			'position'		=> isset($campoal_options['conikal_toast_position_field']) ? $campoal_options['conikal_toast_position_field'] : 'bottom right',
			'displayTime'	=> isset($campoal_options['conikal_toast_display_time_field']) ? $campoal_options['conikal_toast_display_time_field'] : 'auto',
			'newestOnTop'	=> isset($campoal_options['conikal_toast_newest_on_top_field']) ? $campoal_options['conikal_toast_newest_on_top_field'] : false,
			'compact'		=> isset($campoal_options['conikal_toast_compact_field']) ? $campoal_options['conikal_toast_compact_field'] : true,
			'remind'		=> isset($campoal_options['conikal_toast_remind_time_field']) ? $campoal_options['conikal_toast_remind_time_field'] : 60,
		);

		// cookie notice
		$cookie_setting 	= array(
			'cookie_notice' 		=> isset($campoal_options['conikal_cookie_notice_field']) ? $campoal_options['conikal_cookie_notice_field'] : 1,
			'cookie_notice_time' 	=> isset($campoal_options['conikal_cookie_notice_time_field']) ? $campoal_options['conikal_cookie_notice_time_field'] : 30,
			'cookie_position'		=> isset($campoal_options['conikal_cookie_toast_position_field']) ? $campoal_options['conikal_cookie_toast_position_field'] : 'bottom left',
			'cookie_notice_style'	=> isset($campoal_options['conikal_cookie_notice_style_field']) ? $campoal_options['conikal_cookie_notice_style_field'] : 'toast',
			'cookie_hidden_type'	=> isset($campoal_options['conikal_cookie_hidden_type_field']) ? $campoal_options['conikal_cookie_hidden_type_field'] : 'scroll',
			'transition' => array(
				'showMethod'   => isset($campoal_options['conikal_cookie_toast_transiation_show_field']) ? $campoal_options['conikal_cookie_toast_transiation_show_field'] : 'fly left',
				'hideMethod'   => isset($campoal_options['conikal_cookie_toast_transiation_hide_field']) ? $campoal_options['conikal_cookie_toast_transiation_hide_field'] : 'fly left',
			),
		);  

		// Prompt action
		$prompt_action_settings = array(
			'prompt_status'		=> isset($campoal_options['conikal_prompt_action_field']) ? $campoal_options['conikal_prompt_action_field'] : 1,
			'show_time'			=> isset($campoal_options['conikal_prompt_action_time_field']) ? $campoal_options['conikal_prompt_action_time_field'] : 3,
			'remind_time'		=> isset($campoal_options['conikal_prompt_action_remind_field']) && $campoal_options['conikal_prompt_action_remind_field'] != '' ? $campoal_options['conikal_prompt_action_remind_field'] : 'session',
		);

		// Guest fields validation
		$guest_location_r   = isset($campoal_options['conikal_guest_location_r_field']) ? $campoal_options['conikal_guest_location_r_field'] : 0;
		$guest_phone_r      = isset($campoal_options['conikal_guest_phone_r_field']) ? $campoal_options['conikal_guest_phone_r_field'] : 0;
		$guest_zip_r        = isset($campoal_options['conikal_guest_zip_r_field']) ? $campoal_options['conikal_guest_zip_r_field'] : 0;
		$guest_country_r    = isset($campoal_options['conikal_guest_country_r_field']) ? $campoal_options['conikal_guest_country_r_field'] : 0;

		$guest_form_validation = array(
			'addressSign'     => $guest_location_r ? 'empty' : 0,
			'zipSign'         => $guest_zip_r ? 'empty' : 0,
			'countrySign'     => $guest_country_r ? 'empty' : 0,
			'phonecodeSign'   => $guest_phone_r ? 'empty' : 0,
		);

		// Sign up fields validation
		$user_gender_r 		= isset($campoal_options['conikal_user_gender_r_field']) ? $campoal_options['conikal_user_gender_r_field'] : 0;
		$user_birthday_r 	= isset($campoal_options['conikal_user_birthday_r_field']) ? $campoal_options['conikal_user_birthday_r_field'] : 0;
		$user_location_r 	= isset($campoal_options['conikal_user_location_r_field']) ? $campoal_options['conikal_user_location_r_field'] : 0;
		$user_country_r 	= isset($campoal_options['conikal_user_country_r_field']) ? $campoal_options['conikal_user_country_r_field'] : 0;
		$user_phone_r 		= isset($campoal_options['conikal_user_phone_r_field']) ? $campoal_options['conikal_user_phone_r_field'] : 0;
		$user_zip_r 		= isset($campoal_options['conikal_user_zip_r_field']) ? $campoal_options['conikal_user_zip_r_field'] : 0;

		$user_form_validation = array(
			'phone'     => $user_phone_r ? 'empty' : 0,
			'phoneCode' => $user_phone_r ? 'empty' : 0,
			'birthday'  => $user_birthday_r ? 'empty' : 0,
			'gender'    => $user_gender_r ? 'empty' : 0,
			'address'   => $user_location_r ? 'empty' : 0,
			'country'   => $user_country_r ? 'empty' : 0,
			'zip'   	=> $user_zip_r ? 'empty' : 0,
		);

		$password_strength = isset($campoal_options['conikal_password_strength_field']) ? $campoal_options['conikal_password_strength_field'] : 0;
        $acceptable_strength = isset($campoal_options['conikal_acceptable_strength_field']) ? $campoal_options['conikal_acceptable_strength_field'] : 0;

		$password_strength_text = array(
			'password_strength' 	=> $password_strength,
			'acceptable_strength' 	=> $acceptable_strength,
			'very_weak'				=> esc_html__('Very weak', 'campoal'),
			'weak'					=> esc_html__('Weak', 'campoal'),
			'medium'				=> esc_html__('Medium', 'campoal'),
			'strong'				=> esc_html__('Strong', 'campoal'),
		);

		// Service javascript variable
		$services_vars = array(
			'is_user_logged_in' 		=> is_user_logged_in(),
			'admin_url' 				=> get_admin_url(),
			'home_url' 					=> home_url('/'),
			'is_front_page' 			=> is_front_page(),
			'is_home' 					=> is_home(),
			'administrator' 			=> current_user_can('administrator'),
			'site_locale'				=> esc_attr(get_locale()),
			'post_id' 					=> esc_js($post ? $post->ID : NULL),
			'is_mobile' 				=> esc_js(wp_is_mobile() ? 'true' : 'false'),
			'is_account_page' 			=> is_page_template('user-account.php'),
			'user_id' 					=> esc_js($current_user ? $current_user->ID : NULL),
			'oauth_url' 				=> esc_url($oauth_page_url),
			'api_url' 					=> esc_url($api_page_url),
			'editor_style' 				=> esc_js($editor_style),
			'spell_checker' 			=> esc_js($spell_checker),
			'home_victory' 				=> esc_js($home_victory),
			'home_victory_hide_logined' => esc_js($home_victory_hide_logined),
			'co_author' 				=> esc_js($post ? conikal_co_author_permission($post->ID) : ''),
			'signup_text' 				=> esc_attr__('Sign Up','campoal'),
			'signin_text' 				=> esc_attr__('Sign In','campoal'),
			'forgot_text' 				=> esc_attr__('Get New Password','campoal'),
			'reset_pass_text' 			=> esc_attr__('Reset Password','campoal'),
			'fb_login_text' 			=> esc_attr__('Sign In with Facebook','campoal'),
			'fb_login_error' 			=> esc_attr__('Login cancelled or not fully authorized!','campoal'),
			'google_signin' 			=> esc_js($google_signin),
			'google_client_id' 			=> esc_js($google_client_id),
			'google_place_types' 		=> esc_js($google_place_types),
			'google_signin_text' 		=> esc_attr__('Sign In with Google','campoal'),
			'google_signin_error' 		=> esc_attr__('Signin cancelled or not fully authorized!','campoal'),
			'follow' 					=> esc_attr__('Follow', 'campoal'),
			'following' 				=> esc_attr__('Following', 'campoal'),
			'unfollow' 					=> esc_attr__('Unfollow', 'campoal'),
			'save_this' 				=> esc_attr__('Save this campaign', 'campoal'),
			'unsave_this' 				=> esc_attr__('Unsave this campaign', 'campoal'),
			'edit' 						=> esc_attr__('Edit', 'campoal'),
			'delete' 					=> esc_attr__('Delete', 'campoal'),
			'comment' 					=> esc_attr__('Comment', 'campoal'),
			'comments' 					=> esc_attr__('Comments', 'campoal'),
			'comment_reply' 			=> esc_attr__('Reply', 'campoal'),
			'comment_placeholder' 		=> esc_attr__('Write comment here', 'campoal'),
			'comment_reply_to' 			=> esc_attr__('Reply to', 'campoal'),
			'comment_vote' 				=> esc_attr__('like', 'campoal'),
			'comment_up_vote' 			=> esc_attr__('Like', 'campoal'),
			'comment_down_vote' 		=> esc_attr__('Unlike', 'campoal'),
			'comment_view_all' 			=> esc_attr__('View all', 'campoal'),
			'comment_replies' 			=> esc_attr__('replies', 'campoal'),
			'comment_replies_hide' 		=> esc_attr__('Hide replies', 'campoal'),
			'petition_to' 				=> esc_attr__('Petition to %s', 'campoal'),
			'supporters' 				=> esc_attr__('supporters', 'campoal'),
			'pending_approval' 			=> esc_attr__('Pending approval!', 'campoal'),
			'posted_by' 				=> esc_attr__('Posted by', 'campoal'),
			'min_characters' 			=> esc_js($min_characters),
			'max_results' 				=> esc_js($max_results),
			'search_type' 				=> esc_js(wp_is_mobile() ? 'standard' : $search_type),
			'search_settings' 			=> esc_js(json_encode($search_settings)),
			'action_after_sign' 		=> esc_js($action_after_sign),
			'unsign' 					=> esc_js($unsign),
			'signature_update_time' 	=> esc_js($signature_update_time),
			'view_counter' 				=> esc_js($view_counter),
			'victory_text' 				=> esc_attr__('Victory!', 'campoal'),
			'victory_icon' 				=> conikal_custom_icon('victory'),
			'supporter_icon' 			=> conikal_custom_icon('supporter'),
			'send_icon' 				=> conikal_custom_icon('send'),
			'external_link' 			=> esc_js($external_link),
			'rtl_mode' 					=> esc_js($rtl_mode),
			'page_template' 			=> esc_js($current_page_template),
			'recaptcha' 				=> esc_js($reCaptcha_status),
			'toast' 					=> esc_js(json_encode($toast_settings)),
			'video_watching_time' 		=> esc_js($video_watching_time),
			'fundraising_step' 			=> esc_js($fundraising_step),
			'supporters_donors_style' 	=> esc_js($supporters_donors_style),
			'modal_transition' 			=> esc_js($modal_transition),
		);
		wp_localize_script('campoal-services', 'services_vars', $services_vars);


		// main javascript variable
		$main_vars = array(
			'is_user_logged_in' 			=> is_user_logged_in(),
			'admin_url' 					=> get_admin_url(),
			'home_url' 						=> home_url('/'),
			'api_url' 						=> esc_url($api_page_url),
			'is_mobile' 					=> esc_js(wp_is_mobile() ? 'true' : 'false'),
			'full_name_holder' 				=> esc_attr__('Who can make this happen?','campoal'),
			'position_holder' 				=> esc_attr__('What is their position?','campoal'),
			'amount_level_holder' 			=> esc_attr__('Amount of level','campoal'),
			'level_name_holder' 			=> esc_attr__('Level name','campoal'),
			'level_description_holder' 		=> esc_attr__('Desciption of level','campoal'),
			'copy_clipboard' 				=> esc_attr__('Copied to clipboard!', 'campoal'),
			'copy_clipboard_err' 			=> esc_attr__('Press Ctrl+C to copy!', 'campoal'),
			'save' 							=> esc_attr__('Save', 'campoal'),
			'cancel' 						=> esc_attr__('Cancel', 'campoal'),
			'repeat_password_wrong'			=> esc_attr__('Repeated password does not match!', 'campoal'),
			'type_menu' 					=> esc_js($type_menu),
			'verify_transition' 			=> esc_js($verify_transition),
			'verify_dimmer' 				=> esc_js($verify_dimmer),
			'verify_closable' 				=> esc_js($verify_closable),
			'mobile_sign_style' 			=> esc_js($mobile_sign_style),
			'mobile_sign_scroll' 			=> esc_js($mobile_sign_scroll),
			'mobile_menu_animation' 		=> esc_js($mobile_menu_animation),
			'ajax_pages' 					=> esc_js($ajax_pages),
			'html_preloader' 				=> esc_js($html_preloader),
			'header_color' 					=> esc_js(strtoupper($header_menu_color)),
			'home_text_color' 				=> esc_js(strtoupper($home_menu_text_color)),
			'maximum_category' 				=> esc_js($maximum_category),
			'maximum_topics' 				=> esc_js($maximum_topics),
			'rtl_mode' 						=> esc_js($rtl_mode),
			'recaptcha' 					=> esc_js($reCaptcha_status),
			'toast' 						=> esc_js(json_encode($toast_settings)),
			'cookie_setting' 				=> esc_js(json_encode($cookie_setting)),
			'prompt_action' 				=> esc_js(json_encode($prompt_action_settings)),
			'email_verify' 					=> esc_js($account_activation != 1 && $verification_email != 0 && $force_verify != 0 ? 1 : 0),
			'receiver_step' 				=> esc_js($receiver_step),
			'fundraising_step' 				=> esc_js($fundraising_step),
			'close_promo_time' 				=> esc_js($close_promo_time),
			'top_menu' 						=> esc_js($top_menu),
			'supporter_counter_animation' 	=> esc_js($supporter_counter_animation),
			'use_inverted_logo' 			=> esc_js($use_inverted_logo),
			'modal_transition' 				=> esc_js($modal_transition),
			'editor_style' 					=> esc_js($editor_style),
			'guest_form_validation'			=> esc_js(json_encode($guest_form_validation)),
			'user_form_validation'			=> esc_js(json_encode($user_form_validation)),
			'password_strength_text'		=> esc_js(json_encode($password_strength_text)),
		);

		// add currency and symbol from Give to main vars
		if (class_exists('Give')) {
			$main_vars['give_currency_position'] 	= give_get_option('currency_position', 'before');
			$main_vars['give_currency_symbol'] 		= give_currency_symbol();
		}

		wp_localize_script('campoal-main', 'main_vars', $main_vars);

		// ajax file upload
		wp_enqueue_script('campoal-ajax-upload', get_template_directory_uri().'/js/ajax-upload.js',array('jquery','plupload-handlers'), '1.0', true);

		$max_file_size  = 10 * 1024 * 1024;
		$resize_image = array();
		if (is_page_template('user-account.php')) {
			if (!isset($_GET['tab'])) {
				$resize_image = array(
					'width' 	=> 512, 
					'height' 	=> 512, 
					'crop' 		=> true, 
					'quality' 	=> 90
				);
			}
		} else {
			$resize_image = array(
				'width' 	=> 1600, 
				'height' 	=> 900, 
				'crop' 		=> true, 
				'quality' 	=> 90
			);
		}

		// ajax file upload variable
		wp_localize_script('campoal-ajax-upload', 'ajax_vars',
			array(  
				'ajaxurl'           => admin_url('admin-ajax.php'),
				'upload_dir'        => wp_upload_dir(),
				'nonce'             => wp_create_nonce('conikal_upload'),
				'remove'            => wp_create_nonce('conikal_remove'),
				'number'            => 1,
				'upload_enabled'    => true,
				'confirmMsg'        => esc_attr__('Are you sure you want to delete this?','campoal'),
				'delete'            => esc_attr__('Delete','campoal'),
				'embed_placeholder' => esc_attr($video_embed_placeholder),
				'plupload'          => array(
					'runtimes'          => 'html5,flash,browserplus,silverlight,gears,html4',
					'browse_button'     => 'aaiu-uploader',
					'container'         => 'aaiu-upload-container',
					'file_data_name'    => 'aaiu_upload_file',
					'max_file_size'     => esc_js($max_file_size . 'b'),
					'url'               => admin_url('admin-ajax.php') . '?action=conikal_upload&nonce=' . wp_create_nonce('conikal_allow'),
					'flash_swf_url'     => includes_url('js/plupload/plupload.flash.swf'),
					'filters'           => array(array('title' => esc_attr__('Allowed Files','campoal'), 'extensions' => "jpg,jpeg,gif,png,heic,heif,JPG,JPEG,GIF,PNG,HEIC,HEIF")),
					'multipart'         => true,
					'multi_selection'   => false,
					'dragdrop'          => true,
					'drop_element'      => 'box-upload',
					'urlstream_upload'  => true,
					'resize'            => $resize_image
				)
			)
		);

		// enqueue comment reply ajax
		if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
			wp_enqueue_script( 'comment-reply' );
		}
	}
endif;
add_action( 'wp_enqueue_scripts', 'conikal_styles_scripts', 10 );


/**
 * Enqueue style in Gutenberg block editor
 *
 * @since Campoal 2.0.9
 */
if( !function_exists('conikal_block_editor_enqueue') ):
	function conikal_block_editor_enqueue() {
		// Main style
		if (function_exists('conikal_register_petition_type')) {
			conikal_semantic_ui_style();
		}
		wp_enqueue_style('campoal-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get('Version'));
		wp_enqueue_style('campoal-child', get_stylesheet_directory_uri() . '/style.css', array('campoal-style'), wp_get_theme()->get('Version'));
		conikal_styles_scripts();
	}
endif;
add_action( 'enqueue_block_editor_assets', 'conikal_block_editor_enqueue', 10 );


/**
 * Enqueue Fontawesome Pro icon in footer
 *
 * @since Campoal 2.0.0
 */
if( !function_exists('conikal_enqueue_style_footer') ):
	function conikal_enqueue_style_footer() {
		// Font Awesome Pro
		wp_dequeue_style( 'fontawesome' );
		wp_enqueue_style( 'fontawesome-pro', get_template_directory_uri() . '/css/all.min.css', array(), '5.15.4');
	}
endif;
add_action( 'wp_footer', 'conikal_enqueue_style_footer', 10 );
?>