<?php

/*
 * Real Connect Start Session function strat 
 */ 
function realConnectStartSession() {
    global $wp;
    if(!empty($wp->request))
    {    
        if(!session_id()) {
            session_start();
        }
    }
}
add_action('init', 'realConnectStartSession');



/*
 * Wppage function strat 
*/ 
function wppage($rc_listing_view_template_file_path = '', $return_data=false, $page_id=0) {
	global $wp;

			$pageurl =  get_permalink();
			
			
			$pageurl_uri =  str_replace(get_site_url(),"",$pageurl);
			$pageurl_uri = ltrim($pageurl_uri, '/');
			$pageurl_uri = rtrim($pageurl_uri, '/');
			

			// added by vikas on 2 apr 2020
			$pageurl_uri=$wp->request;



			$searchpos = strpos($pageurl,'searchrc');

			$pos = strpos($pageurl,'listings');
			
                global $post;
				$map = get_post_meta($post->ID,'map',true);
				$special = get_post_meta($post->ID,'special',true);
				$sort_term = get_post_meta($post->ID,'sort_term',true);
				
				if(isset($_POST['sort_term'])){
					$sort_term = $_POST['sort_term'];
				}
				if(isset($_POST['special'])){
					$special = $_POST['special'];
				}
				if(isset($_POST['map'])){
					$map = $_POST['map'];
				}
				
				
				if(empty($map)){
					
					 $pagination_start_no = get_query_var( 'page', 1 ); 
					 if(is_numeric($pagination_start_no) && ($pagination_start_no != 0)){
						 $map = $pagination_start_no;
					 }
				} 
				
				unset($_SESSION['main_search']);
				unset($_SESSION['property_type']);
				//$_SESSION['selectednew'];
				$_SESSION['referer'] = $pageurl_uri ;
                if($return_data){ 
                    return properties($map,$special,$sort_term,$rc_listing_view_template_file_path, $return_data, $page_id);
                }
                else{
                    properties($map,$special,$sort_term,$rc_listing_view_template_file_path);
                    unset($_SESSION['custom_listing_data'][$page_id]);
                }
				
			
		
}


?>