HEX
Server: nginx/1.18.0
System: Linux vcwordpress 5.15.0-174-generic #184-Ubuntu SMP Fri Mar 13 18:41:50 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/bharti-foundation.stgviitor.com/wp-content/plugins/lifeline-plugin/includes/Functions.php
<?php
if (! function_exists('lifeline_terms_plug')) {
	/**
	 * lifeline_terms_plug
	 *
	 * @param  mixed $args
	 * @param  mixed $vc_autocomplete
	 * @param  mixed $field_set
	 * @return void
	 */
	function lifeline_terms_plug($args = array(), $vc_autocomplete = false, $field_set = array('term_id', 'name'))
	{
		$terms = get_terms($args);

		$terms = wp_list_pluck($terms, $field_set[1], $field_set[0]);

		if (true === $vc_autocomplete) {
			$terms = array_map(
				function ($a, $b) {
					return array(

						'value' => $b,

						'label' => sprintf(esc_html__('ID: %1$s | Name: %2$s', 'lifeline-plugin'), $b, $a),

					);
				},
				$terms,
				array_flip($terms)
			);
		}

		return $terms;
	}
}

if (! function_exists('lifeline_terms_by_id_plug')) {
	/**
	 * lifeline_terms_by_id_plug
	 *
	 * @param  mixed $id
	 * @param  mixed $term
	 * @param  mixed $vc_autocomplete
	 * @return void
	 */
	function lifeline_terms_by_id_plug(int $id, string $term, $vc_autocomplete = false)
	{
		$terms_list = get_term_by('term_id', $id, $term);

		$terms = array(

			$terms_list->terms_list => $terms_list->name,

		);

		if (true === $vc_autocomplete) {
			$terms = array(

				'value' => $terms_list->term_id,

				'label' => sprintf(esc_html__('ID: %1$s | Name: %2$s', 'lifeline-plugin'), $terms_list->term_id, $terms_list->name),

			);
		}

		return $terms;
	}
}

if (! function_exists('lifeline_posts_plug')) {
	/**
	 * lifeline_posts_plug
	 *
	 * @param  mixed $args
	 * @param  mixed $vc_autocomplete
	 * @param  mixed $field_set
	 * @return void
	 */
	function lifeline_posts_plug($args = array('post_type' => 'post'), $vc_autocomplete = false, $field_set = array('ID', 'post_title'))
	{
		$posts = get_posts($args);

		$posts = wp_list_pluck($posts, $field_set[1], $field_set[0]);

		if (true === $vc_autocomplete) {
			$posts = array_map(
				function ($a, $b) {
					return array(

						'value' => $b,

						'label' => sprintf(esc_html__('ID: %1$s | Name: %2$s', 'lifeline-plugin'), $b, $a),

					);
				},
				$posts,
				array_flip($posts)
			);
		}

		return $posts;
	}
}

if (! function_exists('lifeline_post_by_id_plug')) {
	/**
	 * lifeline_post_by_id_plug
	 *
	 * @param  mixed $id
	 * @param  mixed $vc_autocomplete
	 * @param  mixed $data_full
	 * @return void
	 */
	function lifeline_post_by_id_plug(int $id, $vc_autocomplete = false, $data_full = false)
	{
		$post_list = get_post($id);

		if (! $data_full) {
			$post = array(

				$post_list->ID => $post_list->post_title,

			);
		} else {
			$post = $post_list;
		}
		if (true === $vc_autocomplete) {
			$post = array(

				'value' => $post_list->ID,

				'label' => sprintf(esc_html__('ID: %1$s | Name: %2$s', 'lifeline-plugin'), $post_list->ID, $post_list->post_title),

			);
		}

		return $post;
	}
}

if (! function_exists('lifeline_fontawesome_plug')) {
	/**
	 * lifeline_fontawesome_plug
	 *
	 * @return void
	 */
	function lifeline_fontawesome_plug()
	{
		$subject = wp_remote_get(LIFELINE_PL_URL . 'assets/data/font-awesome-5.json');
		$subject  = lifeline_get($subject, 'body');
		$res      = json_decode($subject, true);
		return $res;
	}
}

/**
 * [get_lists description]
 */
if (! function_exists('lifeline_get_mc_lists')) {
	/**
	 * lifeline_get_mc_lists
	 *
	 * @param  mixed $assos
	 * @return void
	 */
	function lifeline_get_mc_lists($assos = true)
	{
		if (! function_exists('mc4wp')) {

			return array();
		}
		if (! class_exists('MC4WP_Mailchimp')) {

			require_once MC4WP_PLUGIN_DIR . 'includes/class-mailchimp.php';
		}
		$mc4   = new MC4WP_Mailchimp();
		$lists = array();
		if (method_exists($mc4, 'get_lists')) {
			$lists = $mc4->get_lists();

			if ($assos) {

				$return = array();

				foreach ($lists as $list) {

					$return[$list->id] = $list->name;
				}

				return $return;
			}
		}
		return $lists;
	}
}

if (! function_exists('lifeline_mailchimp_forms')) {
	/**
	 * lifeline_get_mc_lists
	 *
	 * @return void
	 */
	function lifeline_mailchimp_forms()
	{
		$wp_posts = get_posts(
			array(
				'post_type' => 'mc4wp-form',
				'order'     => 'ASC',
			)
		);
		$result   = array();
		if (! empty($wp_posts) && function_exists('mc4wp_form')) {
			foreach ($wp_posts as $post) {
				$result[$post->post_name] = $post->post_title;
			}
		}

		return $result;
	}
}

if (! function_exists('lifeline_all_image_sizes_plug')) {
	/**
	 * lifeline_all_image_sizes_plug
	 *
	 * @return void
	 */
	function lifeline_all_image_sizes_plug()
	{
		global $_wp_additional_image_sizes;

		$default_image_sizes = array('thumbnail', 'medium', 'medium_large', 'large');

		$image_sizes = array();

		foreach ($default_image_sizes as $size) {
			$image_sizes[$size] = array(
				'width'  => (int) get_option($size . '_size_w'),
				'height' => (int) get_option($size . '_size_h'),
				'crop'   => (bool) get_option($size . '_crop'),
			);
		}

		if ($_wp_additional_image_sizes) {
			$image_sizes = array_merge($image_sizes, $_wp_additional_image_sizes);
		}

		/** This filter is documented in wp-admin/includes/media.php */
		$wp_image_sizes = apply_filters('image_size_names_choose', $image_sizes);

		$image_sizes = array();

		foreach ($wp_image_sizes as $size_key => $size_attributes) {
			$control_title = ucwords(str_replace('_', ' ', $size_key));
			if (is_array($size_attributes)) {
				$control_title .= sprintf(' - %d x %d', $size_attributes['width'], $size_attributes['height']);
			}

			$image_sizes[$size_key] = $control_title;
		}

		$image_sizes['full'] = _x('Full', 'Image Size Control', 'lifeline-plugin');

		$image_sizes['custom'] = _x('Custom', 'Image Size Control', 'lifeline-plugin');

		return $image_sizes;
	}
}


if (! function_exists('lifeline_load_template')) {
	/**
	 * lifeline_load_template
	 *
	 * @param  mixed $file_path
	 * @return void
	 */
	function lifeline_load_template($file_path)
	{
		$theme_location = get_theme_file_path("lifeline-plugin/{$file_path}");
		//print_r($theme_location);
		if (file_exists($theme_location)) {
			return $theme_location;
		}

		$theme_location = LIFELINE_PL_PATH . "{$file_path}";

		if (file_exists($theme_location)) {
			return $theme_location;
		}

		return get_theme_file_path($file_path);
	}
}

if (! function_exists('lifeline_post_types_list_plug')) {
	/**
	 * lifeline_post_types_list_plug
	 *
	 * @return void
	 */
	function lifeline_post_types_list_plug()
	{
		$args       = array(
			'public' => true,
		);
		$post_types = get_post_types($args, 'objects');
		return $post_types;
	}
}

if (! function_exists('lifeline_color')) {
	/**
	 * lifeline_color
	 *
	 * @param  mixed $content
	 * @return void
	 */
	function lifeline_color($content)
	{
		$content = str_replace(array('%STR_COLOR%', '%ED_COLOR%'), array('<span class="text-theme">', '</span>'), $content);

		return $content;
	}
}

if (! function_exists('lifeline_post_gallery')) {
	/**
	 * lifeline_post_gallery
	 *
	 * @param  mixed $string
	 * @param  mixed $attr
	 * @return void
	 */
	function lifeline_post_gallery($string, $attr)
	{
		wp_enqueue_script(array('fancybox'));
		$id = lifeline_get($attr, 'ids');
		if (! is_array($id)) {
			$id = explode(',', $id);
		}
		if (! $id && ! is_array($id)) {
			return;
		}
		$col = lifeline_get($attr, 'columns', '3');
		switch ($col) {
			case '2':
				$cols = 'col-lg-6';
				break;
			case '3':
				$cols = 'col-lg-4';
				break;
			case '4':
				$cols = 'col-lg-3';
				break;
			case '5':
				$cols = 'col-5';
				break;
			case '6':
				$cols = 'col-6';
				break;
			case '8':
				$cols = 'col-8';
				break;
			case '9':
				$cols = 'col-9';
				break;
			default:
				$cols = 'col-12';
		}
		ob_start();
?>
		<div class="page-gallery w-100">
			<div class="row <?php echo apply_filters('lifeline/gallery/classes', 'mrg'); ?>">
				<?php foreach ($id as $_id) : ?>
					<div class="col-6 res-gallery col-md-6 col-sm-6 <?php echo esc_attr($cols); ?>">
						<a class="position-relative d-block overflow-hidden" href="<?php echo esc_url(wp_get_attachment_image_src($_id, 'full')[0]); ?>" data-fancybox="gallery">
							<?php echo wp_get_attachment_image($_id, lifeline_get($attr, 'size', 'thumbnail'), false, array('class' => 'img-fluid')); ?>
						</a>
					</div>
				<?php endforeach; ?>
			</div>
		</div>
	<?php
		$output = ob_get_clean();
		return $output;
	}
}

if (! function_exists('lifeline_print')) {
	/**
	 * lifeline_print
	 *
	 * @param  mixed $data
	 * @return void
	 */
	function lifeline_print($data)
	{
		echo $data;
	}
}

if (! function_exists('lifeline_svg_print')) {
	/**
	 * lifeline_svg_print
	 *
	 * @param  mixed $link
	 * @return void
	 */
	function lifeline_svg_print($link)
	{
		$file = wp_remote_get($link);
		$file  = lifeline_get($file, 'body');
		echo $file;
	}
}

if (! function_exists('lifeline_encrypt')) {
	/**
	 * lifeline_encrypt
	 *
	 * @param  mixed $data
	 * @return void
	 */
	function lifeline_encrypt($data)
	{
		return base64_encode(json_encode($data));
	}
}

if (! function_exists('lifeline_dencrypt')) {
	/**
	 * lifeline_dencrypt
	 *
	 * @param  mixed $data
	 * @param  mixed $array
	 * @return void
	 */
	function lifeline_dencrypt($data, $array = false)
	{
		return json_decode(base64_decode($data), $array);
	}
}

if (! function_exists('lifeline_json_encrypt')) {
	/**
	 * lifeline_json_encrypt
	 *
	 * @param  mixed $data
	 * @return void
	 */
	function lifeline_json_encrypt($data)
	{
		return json_encode($data);
	}
}

if (! function_exists('lifeline_json_dencrypt')) {
	/**
	 * lifeline_json_dencrypt
	 *
	 * @param  mixed $data
	 * @return void
	 */
	function lifeline_json_dencrypt($data, $array = false)
	{
		return json_decode($data, $array);
	}
}

/* Google recaptcha add before the submit button
*/
if (! is_user_logged_in()) {
	add_filter('comment_form_defaults', 'lifeline_add_google_recaptcha');
	add_action('pre_comment_on_post', 'lifeline_verify_google_recaptcha');
}

function lifeline_add_google_recaptcha($field)
{
	$key                    = lifeline_get(lifeline()->options(), 'google_captcha_key');
	$field['comment_field'] = $field['comment_field'] . '<div class="g-recaptcha" data-sitekey="' . $key . '"></div>';
	return $field;
}

/**
 * Google recaptcha check, validate and catch the spammer
 */
function lifeline_is_valid_captcha($captcha)
{
	$key              = lifeline_get(lifeline()->options(), 'google_captcha_secrate');
	$captcha_postdata = http_build_query(
		array(
			'secret'   => $key,
			'response' => $captcha,
			'remoteip' => $_SERVER['REMOTE_ADDR'],
		)
	);
	$captcha_opts     = array(
		'http' => array(
			'method'  => 'POST',
			'header'  => 'Content-type: application/x-www-form-urlencoded',
			'content' => $captcha_postdata,
		),
	);
	$captcha_context  = stream_context_create($captcha_opts);
	$captcha_response = json_decode(file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $captcha_context), true);
	if ($captcha_response['success']) {
		return true;
	} else {
		return false;
	}
}

function lifeline_verify_google_recaptcha()
{
	$recaptcha = isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : '';
	if (empty($recaptcha)) {
		wp_die(__("<b>ERROR:</b> please select <b>I'm not a robot!</b><p><a href='javascript:history.back()'>« Back</a></p>"));
	} elseif (! lifeline_is_valid_captcha($recaptcha)) {
		wp_die(__('<b>Go away SPAMMER!</b>'));
	}
}

if (! function_exists('lifeline_server')) {
	/**
	 * lifeline_server
	 *
	 * @param  mixed $key
	 * @param  mixed $value
	 * @return void
	 */
	function lifeline_server($key = '', $value = '')
	{
		if ($key && $value) {
			return $_SERVER[$key] = $value;
		}

		return $_SERVER[$key];
	}
}

if (! function_exists('lifeline_decrypt')) {
	/**
	 * lifeline_decrypt
	 *
	 * @param  mixed $param
	 * @return void
	 */
	function lifeline_decrypt($param)
	{
		return base64_decode($param);
	}
}

if (! function_exists('lifeline_taxonomy_regster')) {
	/**
	 * lifeline_taxonomy_regster
	 *
	 * @param  mixed $name
	 * @param  mixed $post_type
	 * @param  mixed $args
	 * @return void
	 */
	function lifeline_taxonomy_regster($name, $post_type, $args)
	{
		// Register the taxonomy now so that the import works!
		register_taxonomy(
			$data['taxonomy'],
			apply_filters('woocommerce_taxonomy_objects_' . $data['taxonomy'], array('product')),
			apply_filters(
				'woocommerce_taxonomy_args_' . $data['taxonomy'],
				array(
					'hierarchical' => true,
					'show_ui'      => false,
					'query_var'    => true,
					'rewrite'      => false,
				)
			)
		);
	}
}


if (! function_exists('lifeline_redux_remove_demo_options')) {
	/**
	 * lifeline_redux_remove_demo_options
	 *
	 * @param  mixed $class
	 * @return void
	 */
	function lifeline_redux_remove_demo_options()
	{

		add_action(
			'admin_enqueue_scripts',
			function () {
				$style = '#wp-pointer-0{display:none !important}';
				wp_add_inline_style('redux-admin-css', $style);
			}
		);
	}
	add_action('redux/construct', 'lifeline_redux_remove_demo_options', 100);
}

if (! function_exists('lifeline_sh_res_slider_opt')) {

	/**
	 * lifeline_sh_res_slider_opt
	 *
	 * @param  mixed $attr
	 * @return void
	 */
	function lifeline_sh_res_slider_opt($attr)
	{

		if (lifeline_get($attr, '__slider') !== 'on') {
			return lifeline_json_encrypt(array());
		}

		wp_enqueue_script(array('slick', 'slick-init'));
		$break_points = json_decode(urldecode(lifeline_get($attr, 'slider_res_device')), true);

		$res_opt = array();
		if ($break_points) {
			foreach ($break_points as $point) {
				$res_opt[] = array(
					'breakpoint' => (int) lifeline_get($point, 'device'),
					'settings'   => array(
						'slidesToShow'   => lifeline_get($point, 'slidesToShow') ? (int) lifeline_get($point, 'slidesToShow') : 2,
						'slidesToScroll' => lifeline_get($point, 'slidesToScroll') ? (int) lifeline_get($point, 'slidesToScroll') : 1,
						'dots'           => ('true' === lifeline_get($point, 'dots')) ? true : false,
						'arrows'         => ('true' === lifeline_get($point, 'arrows')) ? true : false,
						'infinite'       => ('true' === lifeline_get($point, 'infinite')) ? true : false,
						'autoplay'       => ('true' === lifeline_get($point, 'autoplay')) ? true : false,
						'fade'           => ('true' === lifeline_get($point, 'fade')) ? true : false,
						'pauseOnFocus'   => ('true' === lifeline_get($point, 'pauseOnFocus')) ? true : false,
						'swipe'          => ('true' === lifeline_get($point, 'swipe')) ? true : false,
						'swipeToSlide'   => ('true' === lifeline_get($point, 'swipeToSlide')) ? true : false,
						'touchMove'      => ('true' === lifeline_get($point, 'touchMove')) ? true : false,
					),
				);
			}
		}

		return lifeline_json_encrypt(
			array(
				'autoplaySpeed' => (lifeline_get($attr, 'autoplaySpeed')) ? (int) lifeline_get($attr, 'autoplaySpeed') : 3000,
				'speed'         => (lifeline_get($attr, 'speed')) ? (int) lifeline_get($attr, 'speed') : 3000,
				'rtl'           => ('true' === lifeline_get($attr, 'rtl')) ? true : false,
				'responsive'    => $res_opt,
			)
		);
	}
}

if (! function_exists('lifeline_sh_slider_opt')) {

	/**
	 * lifeline_sh_slider_opt
	 *
	 * @param  mixed $attr
	 * @return void
	 */
	function lifeline_sh_slider_opt($attr)
	{

		wp_enqueue_script(array('slick', 'slick-init'));

		$break_points = json_decode(urldecode(lifeline_get($attr, 'slider_res_device')), true);

		$settings = array(
			'rtl'           => ('true' === lifeline_get($attr, 'rtl')) ? true : false,
			'autoplaySpeed' => (lifeline_get($attr, 'play_speed')) ? (int) lifeline_get($attr, 'play_speed') : 3000,
			'speed'         => (lifeline_get($attr, 'slide_speed')) ? (int) lifeline_get($attr, 'slide_speed') : 3000,
		);

		$res_opt = array();
		if ($break_points && lifeline_get($attr, '__slider') == 'on') {
			foreach ($break_points as $point) {
				$res_opt[] = array(
					'breakpoint' => (int) lifeline_get($point, 'device'),
					'settings'   => array(
						'slidesToShow'   => lifeline_get($point, 'slidesToShow') ? (int) lifeline_get($point, 'slidesToShow') : 2,
						'slidesToScroll' => lifeline_get($point, 'slidesToScroll') ? (int) lifeline_get($point, 'slidesToScroll') : 1,
						'dots'           => ('true' === lifeline_get($point, 'dots')) ? true : false,
						'arrows'         => ('true' === lifeline_get($point, 'arrows')) ? true : false,
						'infinite'       => ('true' === lifeline_get($point, 'infinite')) ? true : false,
						'autoplay'       => ('true' === lifeline_get($point, 'autoplay')) ? true : false,
						'fade'           => ('true' === lifeline_get($point, 'fade')) ? true : false,
						'pauseOnFocus'   => ('true' === lifeline_get($point, 'pauseOnFocus')) ? true : false,
						'swipe'          => ('true' === lifeline_get($point, 'swipe')) ? true : false,
						'swipeToSlide'   => ('true' === lifeline_get($point, 'swipeToSlide')) ? true : false,
						'touchMove'      => ('true' === lifeline_get($point, 'touchMove')) ? true : false,
					),
				);
			}

			$settings['responsive'] = $res_opt;
		}

		if (lifeline_get($attr, '_slider') == 'on') {
			$desktop_opt = array(
				'slidesToShow'   => lifeline_get($attr, 'slides_to_shows') ? (int) lifeline_get($attr, 'slides_to_shows') : 2,
				'slidesToScroll' => lifeline_get($attr, 'slides_to_scrolls') ? (int) lifeline_get($attr, 'slides_to_scrolls') : 1,
				'dots'           => ('true' === lifeline_get($attr, 'dots')) ? true : false,
				'arrows'         => ('true' === lifeline_get($attr, 'arrows')) ? true : false,
				'infinite'       => ('true' === lifeline_get($attr, 'infinite')) ? true : false,
				'autoplay'       => ('true' === lifeline_get($attr, 'autoplay')) ? true : false,
				'fade'           => ('true' === lifeline_get($attr, 'fade')) ? true : false,
				'cssEase'        => (lifeline_get($attr, 'cssEase')) ? "'" . lifeline_get($attr, 'cssEase') . "'" : 'ease',
			);
			$settings    = array_merge($desktop_opt, $settings);
		}

		return lifeline_json_encrypt(
			$settings
		);
	}
}

if (! function_exists('lifeline_remote_get_json_content')) {
	/**
	 * lifeline_remote_get_json_content
	 *
	 * @param  mixed $file_url
	 * @param  mixed $array
	 * @return void
	 */
	function lifeline_remote_get_json_content($file_url, $array = false, $args = array())
	{
		$try = wp_remote_get($file_url, $args);
		if (! is_wp_error($try)) {
			$try = lifeline_json_dencrypt($try['body'], $array);
		} else {
			$try = lifeline_json_dencrypt(file_get_contents($file_url), $array);
		}

		if (! $try) {
			return array();
		}

		return $try;
	}
}

if (! function_exists('lifeline_remote_get_content')) {
	/**
	 * lifeline_remote_get_content
	 *
	 * @param  mixed $file_url
	 * @return void
	 */
	function lifeline_remote_get_content($file_url, $args = array())
	{
		$try = wp_remote_get($file_url, $args);
		if (! is_wp_error($try)) {
			$try = $try['body'];
		} else {
			$try = file_get_contents($file_url);
		}

		if (! $try) {
			return array();
		}

		return $try;
	}
}

if (! function_exists('lifeline_cm_price_with_symble')) {
	function lifeline_cm_price_with_symble($price, $class = 'font-style-normal dollar-symbol')
	{
		if(function_exists('wpcm_get_settings')){
			$settings = wpcm_get_settings();
		}
		if (function_exists('webinane_currency_symbol')) {
			$symbol   = webinane_currency_symbol();
		}
		$position = $settings->get('currency_position', 'left');
		$sep      = $settings->get('thousand_saparator', ''); // Thousand Separator
		$d_sep    = $settings->get('decimal_separator', '.'); // Decimal separator
		$d_point  = $settings->get('number_decimals', 0); // Decimal numbers

		$price = number_format((float) $price, (int) $d_point, $d_sep, $sep); // Aplly formation on number.

		if ($position == 'right') {
			return wp_kses_post($price . ' <i class="' . $class . '">' . $symbol . '</i>');
		} else {
			return wp_kses_post('<i class="' . $class . '">' . $symbol . '</i>' . $price);
		}
	}
}

if (! function_exists('lifeline_get_page_title')) {
	/**
	 * lifeline_get_page_title
	 *
	 * @param  mixed $include_context
	 * @return void
	 */
	function lifeline_get_page_title($include_context = true)
	{
		$title = '';

		if (is_singular()) {
			/* translators: %s: Search term. */
			$title = get_the_title();

			if ($include_context) {
				$post_type_obj = get_post_type_object(get_post_type());
				$title         = sprintf('%s: %s', $post_type_obj->labels->singular_name, $title);
			}
		} elseif (is_search()) {
			/* translators: %s: Search term. */
			$title = sprintf(__('Search Results for: %s', 'tacon'), get_search_query());

			if (get_query_var('paged')) {
				/* translators: %s is the page number. */
				$title .= sprintf(__('&nbsp;&ndash; Page %s', 'tacon'), get_query_var('paged'));
			}
		} elseif (is_category()) {
			$title = single_cat_title('', false);

			if ($include_context) {
				/* translators: Category archive title. 1: Category name */
				$title = sprintf(__('Category: %s', 'tacon'), $title);
			}
		} elseif (is_tag()) {
			$title = single_tag_title('', false);
			if ($include_context) {
				/* translators: Tag archive title. 1: Tag name */
				$title = sprintf(__('Tag: %s', 'tacon'), $title);
			}
		} elseif (is_author()) {
			$title = get_the_author();

			if ($include_context) {
				/* translators: Author archive title. 1: Author name */
				$title = sprintf(__('Author: %s', 'tacon'), $title);
			}
		} elseif (is_year()) {
			$title = get_the_date(_x('Y', 'yearly archives date format', 'tacon'));

			if ($include_context) {
				/* translators: Yearly archive title. 1: Year */
				$title = sprintf(__('Year: %s', 'tacon'), $title);
			}
		} elseif (is_month()) {
			$title = get_the_date(_x('F Y', 'monthly archives date format', 'tacon'));

			if ($include_context) {
				/* translators: Monthly archive title. 1: Month name and year */
				$title = sprintf(__('Month: %s', 'tacon'), $title);
			}
		} elseif (is_day()) {
			$title = get_the_date(_x('F j, Y', 'daily archives date format', 'tacon'));

			if ($include_context) {
				/* translators: Daily archive title. 1: Date */
				$title = sprintf(__('Day: %s', 'tacon'), $title);
			}
		} elseif (is_tax('post_format')) {
			if (is_tax('post_format', 'post-format-aside')) {
				$title = _x('Asides', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-gallery')) {
				$title = _x('Galleries', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-image')) {
				$title = _x('Images', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-video')) {
				$title = _x('Videos', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-quote')) {
				$title = _x('Quotes', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-link')) {
				$title = _x('Links', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-status')) {
				$title = _x('Statuses', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-audio')) {
				$title = _x('Audio', 'post format archive title', 'tacon');
			} elseif (is_tax('post_format', 'post-format-chat')) {
				$title = _x('Chats', 'post format archive title', 'tacon');
			}
		} elseif (is_post_type_archive()) {
			$title = post_type_archive_title('', false);

			if ($include_context) {
				/* translators: Post type archive title. 1: Post type name */
				$title = sprintf(__('Archives: %s', 'tacon'), $title);
			}
		} elseif (is_tax()) {
			$title = single_term_title('', false);

			if ($include_context) {
				$tax = get_taxonomy(get_queried_object()->taxonomy);
				/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
				$title = sprintf(__('%1$s: %2$s', 'tacon'), $tax->labels->singular_name, $title);
			}
		} elseif (is_home()) {
			$title = single_post_title('', false);

			if ($include_context) {
				$tax = get_taxonomy(get_queried_object()->taxonomy);
				/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
				$title = sprintf(__('%1$s: %2$s', 'tacon'), $tax->labels->singular_name, $title);
			}
		} elseif (is_404()) {
			$title = __('Page Not Found', 'tacon');
		} // End if().

		/**
		 * The archive title.
		 * Filters the archive title.
		 *
		 * @since 1.0.0
		 *
		 * @param string $title Archive title to be displayed.
		 */
		$title = apply_filters('lifeline/get_the_archive_title', $title);

		return $title;
	}
}

if (! function_exists('lifeline_get_taxonomies')) {
	/**
	 * Used to overcome core bug when taxonomy is in more then one post type
	 *
	 * @see   https://core.trac.wordpress.org/ticket/27918
	 * @global array $wp_taxonomies The registered taxonomies.
	 * @since 0.0.1
	 *
	 * @param array  $args
	 * @param string $output
	 * @param string $operator
	 *
	 * @return array
	 */
	function lifeline_get_taxonomies($args = array(), $output = 'names', $operator = 'and')
	{
		global $wp_taxonomies;

		$field = ('names' === $output) ? 'name' : false;

		// Handle 'object_type' separately.
		if (isset($args['object_type'])) {
			$object_type = (array) $args['object_type'];
			unset($args['object_type']);
		}

		$taxonomies = wp_filter_object_list($wp_taxonomies, $args, $operator);

		if (isset($object_type)) {
			foreach ($taxonomies as $tax => $tax_data) {
				if (! array_intersect($object_type, $tax_data->object_type)) {
					unset($taxonomies[$tax]);
				}
			}
		}

		if ($field) {
			$taxonomies = wp_list_pluck($taxonomies, $field);
		}

		return $taxonomies;
	}
}

if (! function_exists('lifeline_array_reduce')) {
	/**
	 * lifeline_array_reduce
	 *
	 * @param  mixed $value
	 * @return void
	 */
	function lifeline_array_reduce($value)
	{
		$return = array();
		$value  = array_filter($value);
		foreach ($value as $val) {
			$return[] = (is_array($val)) ? lifeline_array_reduce($val) : $val;
		}

		return implode(',', $return);
	}
}

if (! function_exists('lifeline_build_editor_link')) {
	/**
	 * lifeline_build_editor_link
	 *
	 * @param  array $value
	 * @return void
	 */
	function lifeline_build_editor_link($value)
	{
		$default      = array(
			'url'    => '',
			'title'  => '',
			'target' => '',
			'rel'    => '',
		);
		$result       = $default;
		$params_pairs = explode('|', $value);
		if (! empty($params_pairs)) {
			foreach ($params_pairs as $pair) {
				$param = preg_split('/\:/', $pair);
				if (! empty($param[0]) && isset($param[1])) {
					$result[$param[0]] = rawurldecode($param[1]);
				}
			}
		}

		return $result;
	}
}

if (! function_exists('lifeline_build_editor_link_gen')) {
	/**
	 * lifeline_build_editor_link_gen
	 *
	 * @param  array $value
	 * @return void
	 */
	function lifeline_build_editor_link_gen($value)
	{
		$result  = lifeline_build_editor_link($value);
		$result  = array_filter($result);
		$_result = array();
		if (is_array($result) && ! empty($result)) {
			foreach ($result as $key => $val) {
				$_result[$key] = ($key == 'url') ? 'href="' . $val . '"' : $key . '="' . $val . '"';
			}
		}

		return $_result;
	}
}

if (! function_exists('lifeline_vc_link_compatible')) {
	/**
	 * lifeline_vc_link_compatible
	 *
	 * @param  array $value
	 * @return void
	 */
	function lifeline_vc_link_compatible($value)
	{
		$target = rawurlencode(($value->is_external) ? '_blank' : '');
		$title  = rawurlencode(($value->link_title) ? $value->link_title : '');
		$ret    = rawurlencode(($value->nofollow) ? 'nofollow' : '');
		$url    = rawurlencode($value->url);
		$__     = 'url:' . $url . '|' . 'target:' . $target . '|' . 'rel:' . $ret . '|' . 'title:' . $title;

		return $__;
	}
}

if (! function_exists('lifeline_get_fontawesome')) {
	/**
	 * lifeline_get_fontawesome
	 *
	 * @return void
	 */
	function lifeline_get_fontawesome()
	{
		$subject = lifeline_get(wp_remote_get(LIFELINE_PL_URL . 'assets/json/social-profile.json'), 'body');

		return apply_filters('lifeline_get_fontawesome', json_decode($subject, true));
	}
}

function the_pagination($args = array(), $echo = 1)
{

	global $wp_query;
	$default    = array(
		'base'      => str_replace(99999, '%#%', esc_url(get_pagenum_link(99999))),
		'format'    => '?paged=%#%',
		'show_all'  => 'False',
		'current'   => max(1, get_query_var('paged')),
		'total'     => $wp_query->max_num_pages,
		'next_text' => '<i class="fa fa-angle-right"></i>',
		'prev_text' => '<i class="fa fa-angle-left"></i>',
		'type'      => 'list',
	);
	$args       = wp_parse_args($args, $default);
	$pagination = '' . str_replace('<ul class=\'page-numbers\'>', '<ul class="pagination">', paginate_links($args)) . '';
	if (paginate_links(array_merge(array('type' => 'array'), $args))) {
		if ($echo) {
			echo wp_kses_post($pagination);
		}

		return $pagination;
	}
}

if (! function_exists('lifeline_cp_pagination')) {

	/**
	 * lifeline_cp_pagination
	 *
	 * @return void
	 */

	function lifeline_cp_pagination($args = array(), $echo = 1)
	{

		global $wp_query;
		$default    = array(
			'base'      => str_replace(99999, '%#%', esc_url(get_pagenum_link(99999))),
			'format'    => '?paged=%#%',
			'show_all'  => 'False',
			'current'   => max(1, get_query_var('paged')),
			'total'     => $wp_query->max_num_pages,
			'next_text' => '<i class="fas fa-angle-double-right"></i>',
			'prev_text' => '<i class="fas fa-angle-double-left"></i>',
			'type'      => 'list',
		);
		$args       = wp_parse_args($args, $default);
		$ul_classes = apply_filters(
			// phpcs:ignore WordPress
			'lifeline/pagination/ul_classes',
			array(
				'pagenation',
				'text-center',

			)
		);
		$a_classes = apply_filters(
			// phpcs:ignore WordPress
			'lifeline/pagination/a_classes',
			array(
				'page-numbers',

			)
		);
		$li_classes = apply_filters(
			// phpcs:ignore WordPress
			'lifeline/pagination/li_classes',
			array(
				'page-itemm',

			)
		);
		$pagination = '' . str_replace(
			array(
				'<ul class=\'page-numbers\'>',
				'<li>',
				'page-numbers',
			),
			array(
				'<ul class="' . implode(' ', $ul_classes) . '">',
				'<li class="' . implode(' ', $li_classes) . '">',
				implode(' ', $a_classes),
			),
			paginate_links($args)
		) . '';
		if (paginate_links(array_merge(array('type' => 'array'), $args))) {
			if ($echo) {
				echo '<div class="pagination-wrap d-inline-block w-100 text-center">' . wp_kses_post($pagination) . '</div>';
			}

			return $pagination;
		}
	}
}

if (! function_exists('we_animate_in_animation')) {
	function we_animate_in_animation()
	{
		return 	[
			'' => 'Default / None',
			'Fading' => [
				'label' => 'Fading',
				'options' => [
					'fadeIn' => 'Fade In',
					'fadeInDown' => 'Fade In Down',
					'fadeInDownBig' => 'fade In Down Big',
					'fadeInLeft' => 'Fade In Left',
					'fadeInLeftBig' => 'fade In Left Big',
					'fadeInRight' => 'Fade In Right',
					'fadeInRightBig' => 'fade In Right Big',
					'fadeInUp' => 'Fade In Up',
					'fadeInUpBig' => 'fade In Up Big',
					'fadeInTopLeft' => 'fade In Top Left',
					'fadeInTopRight' => 'fade In Top Right',
					'fadeInBottomLeft' => 'fade In Bottom Left',
					'fadeInBottomRight' => 'fade In Bottom Right',
				]
			],
			'Zooming' => [
				'label' => 'Zooming',
				'options' => [
					'zoomIn' => 'Zoom In',
					'zoomInDown' => 'Zoom In Down',
					'zoomInLeft' => 'Zoom In Left',
					'zoomInRight' => 'Zoom In Right',
					'zoomInUp' => 'Zoom In Up',
				]
			],
			'Bouncing' => [
				'label' => 'Bouncing',
				'options' => [
					'bounceIn' => 'Bounce In',
					'bounceInDown' => 'Bounce In Down',
					'bounceInLeft' => 'Bounce In Left',
					'bounceInRight' => 'Bounce In Right',
					'bounceInUp' => 'Bounce In Up',
				]
			],
			'Sliding' => [
				'label' => 'Sliding',
				'options' => [
					'slideInDown' => 'Slide In Down',
					'slideInLeft' => 'Slide In Left',
					'slideInRight' => 'Slide In Right',
					'slideInUp' => 'Slide In Up',
				]
			],
			'Rotating' => [
				'label' => 'Rotating',
				'options' => [
					'rotateIn' => 'Rotate In',
					'rotateInDownLeft' => 'Rotate In Down Left',
					'rotateInDownRight' => 'Rotate In Down Right',
					'rotateInUpLeft' => 'Rotate In Up Left',
					'rotateInUpRight' => 'Rotate In Up Right',
				]
			],
			'Attention-Seekers' => [
				'label' => 'Attention Seekers',
				'options' => [
					'bounce' => 'Bounce',
					'flash' => 'Flash',
					'pulse' => 'Pulse',
					'rubberBand' => 'Rubber Band',
					'shake' => 'Shake',
					'shakeX' => 'ShakeX',
					'shakeY' => 'shakeY',
					'headShake' => 'Head Shake',
					'swing' => 'Swing',
					'tada' => 'Tada',
					'wobble' => 'Wobble',
					'jello' => 'Jello',
					'heartBeat' => 'heartBeat',
				]
			],
			'BackEntrances' => [
				'label' => 'Back Entrances',
				'options' => [
					'backInDown' => 'back In Down',
					'backInLeft' => 'back In Left',
					'backInRight' => 'back In Right',
					'backInUp' => 'back In Up',
				]
			],
			'Light-Speed' => [
				'label' => 'Light Speed',
				'options' => [
					'lightSpeedInRight' => 'light Speed In Right',
					'lightSpeedInLeft' => 'light Speed In Left',
				]
			],
			'Flippers' => [
				'label' => 'Flippers',
				'options' => [
					'flip' => 'flip',
					'flipInX' => 'flip In X',
					'flipInY' => 'flip In Y',
				]
			],
			'Specials' => [
				'label' => 'Specials',
				'options' => [
					'hinge' => 'hinge',
					'jackInTheBox' => 'jackInTheBox',
					'rollIn' => 'Roll In',
				]
			],
		];
	}
}

/**
 * All animate Out css animation
 *
 * @since 0.0.1
 */
if (! function_exists('we_animate_out_animation')) {
	function we_animate_out_animation()
	{
		return 	[
			'' => 'Default / None',
			'FadingOut' => [
				'label' => 'Fading Out',
				'options' => [
					'fadeOut' => 'fade Out',
					'fadeOutDown' => 'fade Out Down',
					'fadeOutDownBig' => 'fade Out Down Big',
					'fadeOutLeft' => 'fade Out Left',
					'fadeOutLeftBig' => 'fade Out Left Big',
					'fadeOutRight' => 'fade Out Right',
					'fadeOutRightBig' => 'fade Out Right Big',
					'fadeOutUp' => 'fade Out Up',
					'fadeOutUpBig' => 'fade Out Up Big',
					'fadeOutTopLeft' => 'fade Out Top Left',
					'fadeOutTopRight' => 'fade Out Top Right',
					'fadeOutBottomRight' => 'fade Out Bottom Right',
					'fadeOutBottomLeft' => 'fade Out Bottom Left',
				]
			],
			'ZoomingOut' => [
				'label' => 'Zooming Out',
				'options' => [
					'zoomOut' => 'Zoom Out',
					'zoomOutDown' => 'Zoom Out Down',
					'zoomOutLeft' => 'Zoom Out Left',
					'zoomOutRight' => 'Zoom Out Right',
					'zoomOutUp' => 'Zoom Out Up',
				]
			],
			'BouncingOut' => [
				'label' => 'Bouncing Out',
				'options' => [
					'bounceOut' => 'Bounce Out',
					'bounceOutDown' => 'Bounce Out Down',
					'bounceOutLeft' => 'Bounce Out Left',
					'bounceOutRight' => 'Bounce Out Right',
					'bounceOutUp' => 'Bounce Out Up',
				]
			],
			'SlidingOut' => [
				'label' => 'Sliding Out',
				'options' => [
					'slideOutDown' => 'Slide Out Down',
					'slideOutLeft' => 'Slide Out Left',
					'slideOutRight' => 'Slide Out Right',
					'slideOutUp' => 'Slide Out Up',
				]
			],
			'RotatingOut' => [
				'label' => 'Rotating Out',
				'options' => [
					'rotateOut' => 'Rotate Out',
					'rotateOutDownLeft' => 'Rotate Out Down Left',
					'rotateOutDownRight' => 'Rotate Out Down Right',
					'rotateOutUpLeft' => 'Rotate Out Up Left',
					'rotateOutUpRight' => 'Rotate Out Up Right',
				]
			],
			'Attention-Seekers' => [
				'label' => 'Attention Seekers',
				'options' => [
					'bounce' => 'Bounce',
					'flash' => 'Flash',
					'pulse' => 'Pulse',
					'rubberBand' => 'Rubber Band',
					'shake' => 'Shake',
					'shakeX' => 'ShakeX',
					'shakeY' => 'shakeY',
					'headShake' => 'Head Shake',
					'swing' => 'Swing',
					'tada' => 'Tada',
					'wobble' => 'Wobble',
					'jello' => 'Jello',
					'heartBeat' => 'heartBeat',
				]
			],
			'BackExits' => [
				'label' => 'Back Exits',
				'options' => [
					'backOutDown' => 'back Out Down',
					'backOutLeft' => 'back Out Left',
					'backOutRight' => 'back Out Right',
					'backOutUp' => 'back Out Up',
				]
			],
			'Light-Speed' => [
				'label' => 'Light Speed',
				'options' => [
					'lightSpeedOutRight' => 'light Speed Out Right',
					'lightSpeedOutLeft' => 'light Speed Out Left',
				]
			],
			'Flippers' => [
				'label' => 'Flippers',
				'options' => [
					'flip' => 'flip',
					'flipOutX' => 'flip Out X',
					'flipOutY' => 'flip Out Y',
				]
			],
			'Specials' => [
				'label' => 'Specials',
				'options' => [
					'hinge' => 'hinge',
					'jackInTheBox' => 'jackInTheBox',
					'rollOut' => 'rollOut',
				]
			],
		];
	}
}

// Enqueue scripts
add_action('wp_enqueue_scripts', function () {
	wp_register_script('event-calendar-script', LIFELINE_PL_URL  . 'assets/js/event-calendar.js', ['jquery'], '1.0', true);

	wp_localize_script('event-calendar-script', 'eventCalendarData', [
		'ajax_url' => admin_url('admin-ajax.php'),
		'nonce' => wp_create_nonce('event_calendar_nonce'),
	]);
	wp_enqueue_script('event-calendar-script');
});

// Handle AJAX
add_action('wp_ajax_get_events_by_month', 'fetch_events_by_month');
add_action('wp_ajax_nopriv_get_events_by_month', 'fetch_events_by_month');

function fetch_events_by_month()
{
    check_ajax_referer('event_calendar_nonce', 'security');

    $month = sanitize_text_field($_POST['month']); // Expected format: YYYY-MM

    $args = [
        'post_type'      => 'lif_event',
        'posts_per_page' => -1,
        'meta_query'     => [
            [
                'key'     => 'start_date-datepicker',
                'value'   => $month,
                'compare' => 'LIKE', // Use LIKE because format is flexible (array, string)
            ],
        ],
    ];

    $query = new WP_Query($args);
    $events = [];

    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();

            $meta = lifeline()->meta();
            $start_meta = lifeline_get($meta, 'start_date-datepicker', true);

            if (is_array($start_meta)) {
                $event_date = '';
                foreach ($start_meta as $key => $value) {
                    if ($key !== 'time' && is_string($value)) {
                        $event_date = $value;
                        break;
                    }
                }
                $event_time = $start_meta['time'] ?? '00:00';
            } else {
                $event_date = $start_meta;
                $event_time = '00:00';
            }

            $datetime_string = $event_date . ' ' . $event_time;

            $events[] = [
                'id'       => get_the_ID(),
                'title'    => get_the_title(),
                'start'    => date('Y-m-d\TH:i:s', strtotime($datetime_string)), // ISO for FullCalendar
                'location' => lifeline_get($meta, 'event_location', true),
                'link'     => get_permalink(),
            ];
        }
        wp_reset_postdata();
    }

    wp_send_json_success($events);
}