function st_vc_all_post_type_content_search($attr, $content = false) { $default = array('st_style' => 1, 'st_number' => 5); $attr = wp_parse_args($attr, $default); extract($attr); if (!is_page_template('template-search-all-post-type.php')) { return ""; } $html = ''; global $wp_query, $st_search_query; $data_post_type = STInput::request('data_post_type', 'all'); if ($data_post_type == 'all') { $data_post_type = array('st_hotel', 'st_rental', 'st_cars', 'st_tours', 'st_holidays', 'st_activity'); } else { $data_post_type = array($data_post_type); } /////////////////////////////// ////// Hotel ////////////////////////////// if (st_check_service_available('st_hotel') and in_array('st_hotel', $data_post_type)) { $hotel = new STHotel(); add_action('pre_get_posts', array($hotel, 'change_search_hotel_arg')); query_posts(array('post_type' => 'st_hotel', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($hotel, 'change_search_hotel_arg')); $hotel->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Rental ////////////////////////////// if (st_check_service_available('st_rental') and in_array('st_rental', $data_post_type)) { $rental = new STRental(); add_action('pre_get_posts', array($rental, 'change_search_arg')); query_posts(array('post_type' => 'st_rental', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($rental, 'change_search_arg')); $rental->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Activity ////////////////////////////// if (st_check_service_available('st_activity') and in_array('st_activity', $data_post_type)) { $activity = new STActivity(); add_action('pre_get_posts', array($activity, 'change_search_activity_arg')); query_posts(array('post_type' => 'st_activity', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($activity, 'change_search_activity_arg')); $activity->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Cars ////////////////////////////// if (st_check_service_available('st_cars') and in_array('st_cars', $data_post_type)) { $cars = new STCars(); add_action('pre_get_posts', array($cars, 'change_search_cars_arg')); query_posts(array('post_type' => 'st_cars', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; remove_action('pre_get_posts', array($cars, 'change_search_cars_arg')); $cars->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Tours ////////////////////////////// if (st_check_service_available('st_tours') and in_array('st_tours', $data_post_type)) { $tours = new STTour(); $tours->alter_search_query(); add_action('pre_get_posts', array($tours, 'change_search_tour_arg')); query_posts(array('post_type' => 'st_tours', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; $tours->remove_alter_search_query(); wp_reset_query(); } /////////////////////////////// ////// Holidays ////////////////////////////// if (st_check_service_available('st_holidays') and in_array('st_holidays', $data_post_type)) { $holidays = new STHoliday(); $holidays->alter_search_query(); add_action('pre_get_posts', array($holidays, 'change_search_holiday_arg')); query_posts(array('post_type' => 'st_holidays', 's' => '', 'paged' => get_query_var('paged'), 'posts_per_page' => $st_number)); $st_search_query = $wp_query; $html .= st()->load_template('search/search-all-post-type/content', 'all-post-type', array('attr' => $attr)); $html .= '<br>'; $holidays->remove_alter_search_query(); wp_reset_query(); } return $html; }
function st_list_map($attr, $content = false) { $data = shortcode_atts(array('title' => '', 'type' => 'normal', 'st_list_location' => '', 'st_type' => 'st_hotel', 'zoom' => '13', 'height' => '500', 'number' => '12', 'fit_bounds' => 'no', 'style_map' => 'normal', 'custom_code_style' => '', 'show_search_box' => 'yes', 'show_data_list_map' => 'yes', 'range_km' => 'no', 'max_range_km' => '20', 'range_km_col' => '6'), $attr, 'st_list_map'); extract($data); $data_map = array(); $html = ''; //if(!empty( $ids )) { $map_lat_center = 0; $map_lng_center = 0; if ($type == "normal") { $ids = $st_list_location; if (empty($ids)) { return ''; } $_SESSION['el_st_type'] = $st_type; $_SESSION['el_location_id'] = $st_list_location; $st_list_map = new st_list_map(); add_filter('posts_where', array($st_list_map, '_get_query_where')); add_filter('posts_join', array($st_list_map, '_get_query_join')); $query = array('post_type' => explode(',', $st_type), 'posts_per_page' => $number, 'post_status' => 'publish'); $map_lat = get_post_meta($ids, 'map_lat', true); $map_lng = get_post_meta($ids, 'map_lng', true); $location_center = '[' . $map_lat . ',' . $map_lng . ']'; global $wp_query; query_posts($query); remove_filter('posts_where', array($st_list_map, '_get_query_where')); remove_filter('posts_join', array($st_list_map, '_get_query_join')); unset($_SESSION['el_st_type']); unset($_SESSION['el_location_id']); } if ($type == "page_search") { $location_center = '[0,0]'; $address_center = ''; if (STInput::request('pick-up')) { $ids_location = TravelerObject::_get_location_by_name(STInput::get('pick-up')); if (!empty($ids_location)) { $_REQUEST['pick-up'] = implode(',', $ids_location); $map_lat_center = get_post_meta($ids_location[0], 'map_lat', true); $map_lng_center = get_post_meta($ids_location[0], 'map_lng', true); $location_center = '[' . $map_lat_center . ',' . $map_lng_center . ']'; $address_center = get_the_title($ids_location[0]); } } if (STInput::request('location_id')) { $map_lat_center = get_post_meta(STInput::request('location_id'), 'map_lat', true); $map_lng_center = get_post_meta(STInput::request('location_id'), 'map_lng', true); $location_center = '[' . $map_lat_center . ',' . $map_lng_center . ']'; $address_center = get_the_title(STInput::request('location_id')); } if (STInput::request('location_id_pick_up')) { $map_lat_center = get_post_meta(STInput::request('location_id_pick_up'), 'map_lat', true); $map_lng_center = get_post_meta(STInput::request('location_id_pick_up'), 'map_lng', true); $location_center = '[' . $map_lat_center . ',' . $map_lng_center . ']'; $address_center = get_the_title(STInput::request('location_id_pick_up')); } global $wp_query, $st_search_query; switch ($st_type) { case "st_hotel": $hotel = new STHotel(); add_action('pre_get_posts', array($hotel, 'change_search_hotel_arg')); break; case "st_rental": $rental = new STRental(); add_action('pre_get_posts', array($rental, 'change_search_arg')); break; case "st_cars": $cars = new STCars(); add_action('pre_get_posts', array($cars, 'change_search_cars_arg')); break; case "st_tours": $tour = new STTour(); //add_action( 'pre_get_posts' , array( $tour , 'change_search_tour_arg' ) ); st()->tour->alter_search_query(); break; case "st_holidays": $holiday = new STHoliday(); //add_action( 'pre_get_posts' , array( $holiday , 'change_search_holiday_arg' ) ); st()->holiday->alter_search_query(); break; case "st_activity": $activity = new STActivity(); add_action('pre_get_posts', array($activity, 'change_search_activity_arg')); break; } $query = array('post_type' => $st_type, 'posts_per_page' => $number, 'post_status' => 'publish', 's' => ''); query_posts($query); } $stt = 0; while (have_posts()) { the_post(); $map_lat = get_post_meta(get_the_ID(), 'map_lat', true); $map_lng = get_post_meta(get_the_ID(), 'map_lng', true); if (!empty($map_lat) and !empty($map_lng) and is_numeric($map_lat) and is_numeric($map_lng)) { $post_type = get_post_type(); $data_map[$stt]['id'] = get_the_ID(); $data_map[$stt]['name'] = get_the_title(); $data_map[$stt]['post_type'] = $post_type; $data_map[$stt]['lat'] = $map_lat; $data_map[$stt]['lng'] = $map_lng; $post_type_name = get_post_type_object($post_type); $post_type_name->label; switch ($post_type) { case "st_hotel": $data_map[$stt]['icon_mk'] = st()->get_option('st_hotel_icon_map_marker', 'http://maps.google.com/mapfiles/marker_black.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/hotel', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/hotel', false, array('post_type' => $post_type_name->label))); break; case "st_rental": $data_map[$stt]['icon_mk'] = st()->get_option('st_rental_icon_map_marker', 'http://maps.google.com/mapfiles/marker_brown.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/rental', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/rental', false, array('post_type' => $post_type_name->label))); break; case "st_cars": $data_map[$stt]['icon_mk'] = st()->get_option('st_cars_icon_map_marker', 'http://maps.google.com/mapfiles/marker_green.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/car', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/car', false, array('post_type' => $post_type_name->label))); break; case "st_tours": $data_map[$stt]['icon_mk'] = st()->get_option('st_tours_icon_map_marker', 'http://maps.google.com/mapfiles/marker_purple.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/tour', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/tour', false, array('post_type' => $post_type_name->label))); break; case "st_holidays": $data_map[$stt]['icon_mk'] = st()->get_option('st_holidays_icon_map_marker', 'http://maps.google.com/mapfiles/marker_purple.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/holiday', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/holiday', false, array('post_type' => $post_type_name->label))); break; case "st_activity": $data_map[$stt]['icon_mk'] = st()->get_option('st_activity_icon_map_marker', 'http://maps.google.com/mapfiles/marker_yellow.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/activity', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/activity', false, array('post_type' => $post_type_name->label))); break; } $stt++; } } if ($type == "page_search") { $st_search_query = $wp_query; switch ($post_type) { case "st_hotel": $hotel->remove_alter_search_query(); break; case "st_rental": $rental->remove_alter_search_query(); break; case "st_cars": $cars->remove_alter_search_query(); break; case "st_tours": //remove_action( 'pre_get_posts' , array( $tour , 'change_search_tour_arg' ) ); st()->tour->remove_alter_search_query(); break; case "st_holidays": //remove_action( 'pre_get_posts' , array( $holiday , 'change_search_holiday_arg' ) ); st()->holiday->remove_alter_search_query(); break; case "st_activity": $activity->remove_alter_search_query(); break; } } wp_reset_query(); if (empty($location_center) or $location_center == '[,]') { $location_center = '[0,0]'; } $data_tmp = array('location_center' => $location_center, 'zoom' => $zoom, 'data_map' => $data_map, 'height' => $height, 'style_map' => $style_map, 'st_type' => $st_type, 'number' => $number, 'fit_bounds' => $fit_bounds, 'title' => $title, 'show_search_box' => $show_search_box, 'show_data_list_map' => $show_data_list_map, 'range_km' => $range_km, 'max_range_km' => $max_range_km, 'range_km_col' => $range_km_col); $data_tmp['data_tmp'] = $data_tmp; $html = st()->load_template('vc-elements/st-list-map/html', '', $data_tmp); // } return $html; }
function st_search_list_half_map($attr, $content = false) { $post_type = STInput::request('post_type'); $zoom = STInput::request('zoom'); $number = STInput::request('number', 8); $style_map = STInput::request('style_map'); $query = array('post_type' => $post_type, 'posts_per_page' => $number, 'post_status' => 'publish', 's' => ''); $map_lat_center = 0; $map_lng_center = 0; $location_center = '[0,0]'; $address_center = ''; /*if(STInput::request( 'location_name' )) { $ids_location = TravelerObject::_get_location_by_name( STInput::get( 'location_name' ) ); if(!empty( $ids_location )) { $_REQUEST['location_name'] = implode(',',$ids_location); $map_lat_center = get_post_meta( $ids_location[ 0 ] , 'map_lat' , true ); $map_lng_center = get_post_meta( $ids_location[ 0 ] , 'map_lng' , true ); $location_center = '[' . $map_lat_center . ',' . $map_lng_center . ']'; $address_center = get_the_title( $ids_location[ 0 ] ); } }*/ if (STInput::request('pick-up')) { $ids_location = TravelerObject::_get_location_by_name(STInput::get('pick-up')); if (!empty($ids_location)) { $_REQUEST['pick-up'] = implode(',', $ids_location); $map_lat_center = get_post_meta($ids_location[0], 'map_lat', true); $map_lng_center = get_post_meta($ids_location[0], 'map_lng', true); $location_center = '[' . $map_lat_center . ',' . $map_lng_center . ']'; $address_center = get_the_title($ids_location[0]); } } if (STInput::request('location_id')) { $map_lat_center = get_post_meta(STInput::request('location_id'), 'map_lat', true); $map_lng_center = get_post_meta(STInput::request('location_id'), 'map_lng', true); $location_center = '[' . $map_lat_center . ',' . $map_lng_center . ']'; $address_center = get_the_title(STInput::request('location_id')); } if (STInput::request('location_id_pick_up')) { $map_lat_center = get_post_meta(STInput::request('location_id_pick_up'), 'map_lat', true); $map_lng_center = get_post_meta(STInput::request('location_id_pick_up'), 'map_lng', true); $location_center = '[' . $map_lat_center . ',' . $map_lng_center . ']'; $address_center = get_the_title(STInput::request('location_id_pick_up')); } $data_map = array(); global $wp_query, $st_search_query; switch ($post_type) { case "st_hotel": $hotel = new STHotel(); add_action('pre_get_posts', array($hotel, 'change_search_hotel_arg')); break; case "st_rental": $rental = new STRental(); add_action('pre_get_posts', array($rental, 'change_search_arg')); break; case "st_cars": $cars = new STCars(); add_action('pre_get_posts', array($cars, 'change_search_cars_arg')); break; case "st_tours": $tour = new STTour(); //add_action( 'pre_get_posts' , array( $tour , 'change_search_tour_arg' ) ); st()->tour->alter_search_query(); break; case "st_holidays": $holiday = new STHoliday(); //add_action( 'pre_get_posts' , array( $holiday , 'change_search_holiday_arg' ) ); st()->holiday->alter_search_query(); break; case "st_activity": $activity = new STActivity(); add_action('pre_get_posts', array($activity, 'change_search_activity_arg')); break; } query_posts($query); $stt = 0; while (have_posts()) { the_post(); $map_lat = get_post_meta(get_the_ID(), 'map_lat', true); $map_lng = get_post_meta(get_the_ID(), 'map_lng', true); if (!empty($map_lat) and !empty($map_lng)) { $post_type = get_post_type(); $data_map[$stt]['id'] = get_the_ID(); $data_map[$stt]['name'] = get_the_title(); $data_map[$stt]['post_type'] = $post_type; $data_map[$stt]['lat'] = $map_lat; $data_map[$stt]['lng'] = $map_lng; $post_type_name = get_post_type_object($post_type); $post_type_name->label; switch ($post_type) { case "st_hotel": $data_map[$stt]['icon_mk'] = st()->get_option('st_hotel_icon_map_marker', 'http://maps.google.com/mapfiles/marker_black.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/hotel', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/hotel', false, array('post_type' => $post_type_name->label))); break; case "st_rental": $data_map[$stt]['icon_mk'] = st()->get_option('st_rental_icon_map_marker', 'http://maps.google.com/mapfiles/marker_brown.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/rental', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/rental', false, array('post_type' => $post_type_name->label))); break; case "st_cars": $data_map[$stt]['icon_mk'] = st()->get_option('st_cars_icon_map_marker', 'http://maps.google.com/mapfiles/marker_green.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/car', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/car', false, array('post_type' => $post_type_name->label))); break; case "st_tours": $data_map[$stt]['icon_mk'] = st()->get_option('st_tours_icon_map_marker', 'http://maps.google.com/mapfiles/marker_purple.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/tour', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/tour', false, array('post_type' => $post_type_name->label))); break; case "st_holidays": $data_map[$stt]['icon_mk'] = st()->get_option('st_holidays_icon_map_marker', 'http://maps.google.com/mapfiles/marker_purple.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/holiday', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/holiday', false, array('post_type' => $post_type_name->label))); break; case "st_activity": $data_map[$stt]['icon_mk'] = st()->get_option('st_activity_icon_map_marker', 'http://maps.google.com/mapfiles/marker_yellow.png'); $data_map[$stt]['content_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop/activity', false, array('post_type' => $post_type_name->label))); $data_map[$stt]['content_adv_html'] = preg_replace('/^\\s+|\\n|\\r|\\s+$/m', '', st()->load_template('vc-elements/st-list-map/loop-adv/activity', false, array('post_type' => $post_type_name->label))); break; } $stt++; } } $st_search_query = $wp_query; switch ($post_type) { case "st_hotel": $hotel->remove_alter_search_query(); break; case "st_rental": $rental->remove_alter_search_query(); break; case "st_cars": $cars->remove_alter_search_query(); break; case "st_tours": //remove_action( 'pre_get_posts' , array( $tour , 'change_search_tour_arg' ) ); st()->tour->remove_alter_search_query(); break; case "st_holidays": //remove_action( 'pre_get_posts' , array( $holiday , 'change_search_holiday_arg' ) ); st()->holiday->remove_alter_search_query(); break; case "st_activity": $activity->remove_alter_search_query(); break; } if (!empty($_REQUEST['st_test'])) { } wp_reset_query(); if ($location_center == '[,]' or $location_center == '[0,0]') { $location_center = '[21.289374,15.644531]'; $data_map = ""; $zoom = "3"; } $data_tmp = array('location_center' => $location_center, 'zoom' => $zoom, 'data_map' => $data_map, 'style_map' => $style_map, 'number' => $number, 'address_center' => $address_center, 'map_lat_center' => $map_lat_center, 'map_lng_center' => $map_lng_center); echo json_encode($data_tmp); die; }