Function Reference: geodir_duplicate_alert_localize_vars

Summary

This function has not been documented yet.

Source File

geodir_duplicate_alert_localize_vars() is located in geodir_ajax_duplicate_alert/geodir_ajax_duplicate_alert.php [Line: 373]

Source Code

function geodir_duplicate_alert_localize_vars()
{
	
	if(geodir_is_page('add-listing')){
	
		global $post;
		$geodir_current_posttype = 	isset($post->post_type) ? $post->post_type : '';
		
		if(isset($_REQUEST['listing_type']) && $_REQUEST['listing_type'] != ''){
			$geodir_current_posttype = 	$_REQUEST['listing_type'];
		}elseif(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
			 $geodir_current_posttype = get_post_type($_REQUEST['pid']);
		}elseif(isset($_REQUEST['backandedit'])){
			$post = (object)unserialize($_SESSION['listing']);
			$geodir_current_posttype = $post->listing_type;	
		}	
		
		$geodir_field_name = get_option('geodir_duplicate_field_'.$geodir_current_posttype);
		
		
		$arr_alert_msg = array(
								'geodir_duplicate_alert_ajax_url' => geodir_duplicate_alert_ajax_url(),
								'geodir_post_types_duplicate' => get_option('geodir_post_types_duplicate'),
								'geodir_duplicate_field_name' => $geodir_field_name,
								'geodir_duplicate_current_posttype' => $geodir_current_posttype,
							);
		
		foreach ( $arr_alert_msg as $key => $value ) 
		{
			if ( !is_scalar($value) )
				continue;
			$arr_alert_msg[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
		}
	
		$script = "var geodir_duplicate_alert_js_var = " . json_encode($arr_alert_msg) . ';';
		echo '';
		
	}
	
}