static function _enqueue_data() { //'Most recent booking for this property was 15 minute ago .Most recent booking for this property was 15 minute ago' if (!self::$is_working) { return; } $data = array(); if (is_singular()) { $post_type = get_post_type(); $book_able = array('st_hotel', 'st_cars', 'st_tours', 'st_activity', 'st_rental', 'cruise'); if (!in_array($post_type, $book_able)) { return; } $label = get_post_type_object($post_type); $demo_mode = st()->get_option('edv_enable_demo_mode', 'off'); if (st()->get_option('enable_user_online_noti', 'on') == 'on') { if ($demo_mode == 'on') { $data['noty'][] = array('icon' => 'home', 'message' => sprintf(st_get_language('now_s_users_seeing_this_s'), rand(300, 5000), $label->labels->singular_name), 'type' => 'success'); } else { $data['noty'][] = array('icon' => 'home', 'message' => sprintf(st_get_language('now_s_users_seeing_this_s'), self::get_user_online(get_the_ID()), $label->labels->singular_name), 'type' => 'success'); } } if (st()->get_option('enable_last_booking_noti', 'on') == 'on') { if ($demo_mode == 'on') { $data['noty'][] = array('icon' => 'clock-o', 'message' => sprintf(st_get_language('most_revent_booking_for_this_s_was_s'), $label->labels->singular_name, sprintf(__('%s minutes ago', ST_TEXTDOMAIN), rand(2, 50))), 'type' => 'warning'); } else { $data['noty'][] = array('icon' => 'clock-o', 'message' => sprintf(st_get_language('most_revent_booking_for_this_s_was_s'), $label->labels->singular_name, TravelerObject::get_last_booking_string(get_the_ID())), 'type' => 'warning'); } } $data['noti_position'] = st()->get_option('noti_position', 'topRight'); } wp_localize_script('jquery', 'stanalytics', $data); }
function init() { parent::init(); add_action('init', array($this, 'st_login_func')); add_action('init', array($this, 'update_user')); add_action('init', array($this, 'update_pass')); add_action('init', array($this, 'upload_image')); add_action('init', array($this, 'st_insert_post_type_hotel'), 50); add_action('init', array($this, 'st_insert_post_type_rental'), 50); add_action('init', array($this, 'st_insert_post_type_cruise'), 50); add_action('init', array($this, 'st_insert_post_type_cruise_cabin'), 50); add_action('init', array($this, 'st_insert_post_type_room'), 50); add_action('init', array($this, 'st_insert_post_type_tours'), 50); add_action('init', array($this, 'st_insert_post_type_activity'), 50); add_action('init', array($this, 'st_insert_post_type_cars'), 50); add_action('init', array($this, 'st_insert_post_type_location'), 50); add_action('init', array($this, 'st_write_review'), 50); add_action('wp_ajax_st_add_wishlist', array($this, 'st_add_wishlist_func')); add_action('wp_ajax_nopriv_st_add_wishlist', array($this, 'st_add_wishlist_func')); add_action('wp_ajax_st_remove_wishlist', array($this, 'st_remove_wishlist_func')); add_action('wp_ajax_nopriv_st_remove_wishlist', array($this, 'st_remove_wishlist_func')); add_action('wp_ajax_st_load_more_wishlist', array($this, 'st_load_more_wishlist_func')); add_action('wp_ajax_nopriv_st_load_more_wishlist', array($this, 'st_load_more_wishlist_func')); add_action('wp_ajax_st_remove_post_type', array($this, 'st_remove_post_type_func')); add_action('wp_ajax_nopriv_st_remove_post_type', array($this, 'st_remove_post_type_func')); add_action('wp_ajax_st_change_status_post_type', array($this, 'st_change_status_post_type_func')); add_action('wp_ajax_nopriv_st_change_status_post_type', array($this, 'st_change_status_post_type_func')); add_action('template_redirect', array($this, 'check_login')); add_action('wp_ajax_st_load_more_history_book', array($this, 'get_book_history')); add_action('wp_ajax_nopriv_st_load_more_history_book', array($this, 'get_book_history')); }
function init() { parent::init(); $this->init_metabox(); add_action('wp_ajax_st_search_location', array($this, 'search_location')); add_action('wp_ajax_nopriv_st_search_location', array($this, 'search_location')); add_action('widgets_init', array($this, 'add_sidebar')); }
function init() { parent::init(); //$this->init_metabox(); add_action('init', array($this, 'init_metabox'), 9); add_action('wp_ajax_st_search_location', array($this, 'search_location')); add_action('wp_ajax_nopriv_st_search_location', array($this, 'search_location')); add_action('widgets_init', array($this, 'add_sidebar')); add_action('wp_enqueue_scripts', array($this, 'add_script')); add_action('wp_enqueue_scripts', array(__CLASS__, 'get_list_post_type')); add_action('admin_enqueue_scripts', array($this, 'admin_script')); add_action('save_post', array($this, 'save_location'), 55); add_action('init', array($this, 'create_session'), 1); }
function init() { parent::init(); $this->init_metabox(); }
function st_list_map_new($attr, $content = false) { $data = shortcode_atts(array('title' => '', 'st_list_location' => '', 'st_type' => 'st_hotel', 'zoom' => '13', 'height' => '500', 'number' => '12', 'style_map' => 'normal', 'show_circle' => 'no', 'range' => '20'), $attr, 'st_list_map_new'); extract($data); $st_type = explode(',', $st_type); $map_lat = get_post_meta($st_list_location, 'map_lat', true); $map_lng = get_post_meta($st_list_location, 'map_lng', true); $location_center = '[' . $map_lat . ',' . $map_lng . ']'; $class_traveler = new TravelerObject(); $data_post = $class_traveler->get_near_by_lat_lng($map_lat, $map_lng, $st_type, $range, $number); global $post; $stt = 0; if (!empty($data_post)) { foreach ($data_post as $post) { setup_postdata($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++; } } wp_reset_postdata(); if ($location_center == '[,]') { $location_center = '[0,0]'; } if ($show_circle == 'no') { $range = 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, 'title' => $title, 'range' => $range); $data_tmp['data_tmp'] = $data_tmp; $html = st()->load_template('vc-elements/st-list-map-new/html', '', $data_tmp); } return $html; $ids = $st_list_location; $_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')); $html = ''; if (!empty($ids)) { $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 . ']'; $data_map = array(); 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']); $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++; } } wp_reset_query(); if ($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, 'title' => $title, 'show_search_box' => $show_search_box, 'show_data_list_map' => $show_data_list_map); $data_tmp['data_tmp'] = $data_tmp; $html = st()->load_template('vc-elements/st-list-map-new/html', '', $data_tmp); } return $html; }
static function get_room_price($room_id = false, $start_date, $end_date) { if (!$room_id) { $room_id = get_the_ID(); } $list_price = array(); $price = 0; $number_days = 0; if ($start_date and $end_date) { $one_day = 60 * 60 * 24; $str_start_date = strtotime($start_date); $str_end_date = strtotime($end_date); $number_days = ($str_end_date - $str_start_date) / $one_day; $total = 0; for ($i = 1; $i <= $number_days; $i++) { $data_date = date("Y-m-d", $str_start_date + $one_day * $i); $date_tmp = date("Y-m-d", strtotime($data_date) - $one_day); $data_price = get_post_meta($room_id, 'price', true); $price_custom = TravelerObject::st_get_custom_price_by_date($room_id, $data_date); if ($price_custom) { $data_price = $price_custom; } $list_price[$data_date] = array('start' => $date_tmp, 'end' => $data_date, 'price' => apply_filters('st_apply_tax_amount', $data_price)); $total += $data_price; } $price = $total; } /** get custom price by date **/ /** get custom price by date **/ $data_price = array('discount' => false, 'price' => apply_filters('st_apply_tax_amount', $price), 'info_price' => $list_price, 'number_day' => $number_days); if ($price > 0) { $discount_rate = get_post_meta($room_id, 'discount_rate', true); $is_sale_schedule = get_post_meta($room_id, 'is_sale_schedule', true); if ($is_sale_schedule == 'on') { $sale_from = get_post_meta($room_id, 'sale_price_from', true); $sale_to = get_post_meta($room_id, 'sale_price_to', true); $str_sale_from = strtotime($sale_from); $str_sale_to = strtotime($sale_to); //$str_start_date // discount = 0 if ($str_sale_from and $str_start_date < $str_sale_from or $str_sale_to and $str_start_date > $str_sale_to or $str_sale_to and $str_sale_from and $str_sale_from < $str_sale_to and $str_start_date < $str_sale_from and $str_start_date > $str_sale_to or $str_sale_to and $str_sale_from and $str_sale_from > $str_sale_to) { $discount_rate = 0; } } if ($discount_rate > 100) { $discount_rate = 100; } if ($discount_rate) { $data_price = array('discount' => true, 'price' => apply_filters('st_apply_tax_amount', $price - $price / 100 * $discount_rate), 'price_old' => apply_filters('st_apply_tax_amount', $price), 'info_price' => $list_price, 'number_day' => $number_days); } } return $data_price; }
public function hotel_room_external_booking_submit() { /* * since 1.1.1 * filter hook car_external_booking_submit */ $hotel_external_booking = st()->get_option('hotel_external_booking', "off"); if ($hotel_external_booking == "on") { if (st()->get_option('hotel_external_booking_link')) { ob_start(); ?> <a class='btn btn-primary' href='<?php echo st()->get_option('car_external_booking_link'); ?> '> <?php st_the_language('book_now'); ?> </a> <?php $return = ob_get_clean(); } } else { $return = TravelerObject::get_book_btn(); } return apply_filters('hotel_external_booking_submit', $return); }
if (!empty($get)) { foreach ($get as $key => $value) { if (is_array($value)) { if (!empty($value)) { if (!empty($value) and is_array($value)) { foreach ($value as $key2 => $value2) { if (!empty($value2) and is_array($value2)) { foreach ($value2 as $key3 => $value3) { echo "<input type='hidden' name='{$key}[{$key2}][{$key3}]' value='{$value3}' >"; } } } } } } else { if ($key != "price_range") { echo "<input type='hidden' name='{$key}' value='{$value}' >"; } } } } $data_min_max = TravelerObject::get_min_max_price('st_cars'); echo '<input type="text" name="price_range" value="' . STInput::get('price_range') . '" class="price-slider" data-symbol="' . TravelHelper::get_current_currency('symbol') . '" data-min="' . $data_min_max['price_min'] . '" data-max="' . $data_min_max['price_max'] . '" data-step="' . st()->get_option('search_price_range_step', 0) . '">'; ?> <button style="margin-top: 4px;" type="submit" class="btn btn-primary"><?php st_the_language('car_filter'); ?> </button> </form>
</label> <div class="controls"> <input placeholder="dd/mm/yyyy" type="text" name="check_out" value="<?php $time = get_post_meta($item_id, 'check_out', true); if ($time) { echo date('m/d/Y', strtotime($time)); } ?> " class="form-control st_datepicker"> </div> </div> <?php $info_price = get_post_meta($item_id, 'data_price', true); $info_price = unserialize($info_price); $info_price = $info_price['info_price']; $info_price = TravelerObject::st_conver_info_price($info_price); ?> <div class="form-row"> <label class="form-label" for="st_note"><?php _e('Info date', ST_TEXTDOMAIN); ?> </label> <div class="controls"> <table class="wp-list-table widefat " style="border: 1px;"> <tr> <td><?php _e("Date", ST_TEXTDOMAIN); ?> </td> <td><?php _e("Price", ST_TEXTDOMAIN);
if (!empty($get) and empty($hidde_button)) { foreach ($get as $key => $value) { if (is_array($value)) { if (!empty($value)) { foreach ($value as $key2 => $value2) { echo "<input type='hidden' name='{$key}[{$key2}]' value='{$value2}' >"; } } } else { if ($key != "price_range") { echo "<input type='hidden' name='{$key}' value='{$value}' >"; } } } } $data_min_max = TravelerObject::get_min_max_price('st_hotel'); $max = $data_min_max['price_max']; $min = $data_min_max['price_min']; if (TravelHelper::get_default_currency('rate') != 0 and TravelHelper::get_default_currency('rate')) { $rate_change = TravelHelper::get_current_currency('rate') / TravelHelper::get_default_currency('rate'); $max = round($rate_change * $max); $min = round($rate_change * $min); } /*$min = number_format($min , TravelHelper::get_current_currency('booking_currency_precision')) ; $max = number_format($max , TravelHelper::get_current_currency('booking_currency_precision')) ;*/ $value_show = $min . ";" . $max; // default if error if ($rate_change) { if (STInput::request('price_range')) { $price_range = explode(';', STInput::request('price_range')); $value_show = $price_range[0] . ";" . $price_range[1];
* */ ?> <form method="get" action=""> <?php $get = STInput::get(); if (!empty($get)) { foreach ($get as $key => $value) { if (is_array($value)) { if (!empty($value)) { foreach ($value as $key2 => $value2) { echo "<input type='hidden' name='{$key}[{$key2}]' value='{$value2}' >"; } } } else { if ($key != "price_range") { echo "<input type='hidden' name='{$key}' value='{$value}' >"; } } } } $data_min_max = TravelerObject::get_min_max_price('st_rental'); echo '<input type="text" name="price_range" value="' . STInput::get('price_range') . '" class="price-slider" data-symbol="' . TravelHelper::get_current_currency('symbol') . '" data-min="' . $data_min_max['price_min'] . '" data-max="' . $data_min_max['price_max'] . '" data-step="' . st()->get_option('search_price_range_step', 0) . '">'; ?> <button style="margin-top: 4px;" type="submit" class="btn btn-primary"><?php st_the_language('rental_filter'); ?> </button> </form>
function _get_where_query($where) { if (!TravelHelper::checkTableDuplicate('st_hotel')) { return $where; } global $wpdb; $where .= ""; if (isset($_REQUEST['location_id']) && !empty($_REQUEST['location_id'])) { $location_id = STInput::request('location_id', ''); $list = TravelHelper::getLocationByParent($location_id); if (is_array($list) && count($list)) { $where .= " AND ("; $where_tmp = ""; foreach ($list as $item) { if (empty($where_tmp)) { $where_tmp .= "tb.multi_location LIKE '%_{$item}_%'"; } else { $where_tmp .= " OR tb.multi_location LIKE '%_{$item}_%'"; } } $list = implode(',', $list); $where_tmp .= " OR tb.id_location IN ({$list})"; $where .= $where_tmp . ")"; } else { $where .= " AND (tb.multi_location LIKE '%_{$location_id}_%' OR tb.id_location IN ('{$location_id}')) "; } } else { if (!empty($_REQUEST['location_name'])) { $location_name = STInput::request('location_name', ''); $ids_location = TravelerObject::_get_location_by_name($location_name); if (is_array($ids_location) && count($ids_location)) { $ids_location_tmp = array(); foreach ($ids_location as $item) { $list = TravelHelper::getLocationByParent($item); if (is_array($list) && count($list)) { foreach ($list as $item) { $ids_location_tmp[] = $item; } } } if (count($ids_location_tmp)) { $ids_location = $ids_location_tmp; } } if (is_array($ids_location) && count($ids_location)) { $where .= " AND (("; $where_tmp = ""; foreach ($ids_location as $id) { if (empty($where_tmp)) { $where_tmp .= " tb.multi_location LIKE '%_{$id}_%' "; } else { $where_tmp .= " OR tb.multi_location LIKE '%_{$id}_%' "; } } $ids_location = implode(',', $ids_location); $where_tmp .= " OR (tb.id_location IN ({$ids_location})"; $where .= $where_tmp . ")"; $where .= " OR (tb.address LIKE '%{$location_name}%'"; $where .= " OR {$wpdb->prefix}posts.post_title LIKE '%{$location_name}%')))"; } else { if (!empty($_REQUEST['search_all'])) { $where .= " AND (tb.address LIKE '%{$location_name}%'"; $where .= " OR {$wpdb->prefix}posts.post_title LIKE '%{$location_name}%')"; } } } elseif (isset($_REQUEST['address']) && !empty($_REQUEST['address'])) { $address = STInput::request('address', ''); $value = STInput::request('address'); $value = explode(",", $value); if (!empty($value[0]) and !empty($value[2])) { $where .= " AND ( tb.address LIKE '%{$value[0]}%' OR tb.address LIKE '%{$value[2]}%')"; } else { $where .= " AND ( tb.address LIKE '%{$address}%')"; } } } if (isset($_GET['start']) && !empty($_GET['start']) && isset($_GET['end']) && !empty($_GET['end'])) { $check_in = date('Y-m-d', strtotime(TravelHelper::convertDateFormat($_GET['start']))); $check_out = date('Y-m-d', strtotime(TravelHelper::convertDateFormat($_GET['end']))); $today = date('m/d/Y'); $period = TravelHelper::dateDiff($today, $check_in); $adult_number = STInput::get('adult_number', 0); if (intval($adult_number) < 0) { $adult_number = 0; } $children_number = STInput::get('children_num', 0); if (intval($children_number) < 0) { $children_number = 0; } $number_room = STInput::get('room_num_search', 0); if (intval($number_room) < 0) { $number_room = 0; } $list_hotel = HotelHelper::_hotelValidate($check_in, $check_out, $adult_number, $children_number, $number_room); if (!is_array($list_hotel) || count($list_hotel) <= 0) { $list_hotel = "''"; } else { $list_hotel = implode(',', $list_hotel); } $where .= " AND {$wpdb->prefix}posts.ID NOT IN ({$list_hotel}) AND CAST(tb.hotel_booking_period AS UNSIGNED) <= {$period}"; } if (isset($_REQUEST['star_rate']) && !empty($_REQUEST['star_rate'])) { $stars = STInput::get('star_rate', 1); $stars = explode(',', $stars); $all_star = array(); if (!empty($stars) && is_array($stars)) { foreach ($stars as $val) { for ($i = $val; $i < $val + 0.9; $i += 0.1) { if ($i) { $all_star[] = $i; } } } } $list_star = implode(',', $all_star); if ($list_star) { $where .= " AND (tb.rate_review IN ({$list_star}))"; } } if (isset($_REQUEST['hotel_rate']) && !empty($_REQUEST['hotel_rate'])) { $hotel_rate = STInput::get('hotel_rate', ''); $where .= " AND (tb.hotel_star IN ({$hotel_rate}))"; } if (isset($_REQUEST['price_range']) && !empty($_REQUEST['price_range'])) { $price = STInput::get('price_range', '0;0'); $priceobj = explode(';', $price); // convert to default money $priceobj[0] = TravelHelper::convert_money_to_default($priceobj[0]); $priceobj[1] = TravelHelper::convert_money_to_default($priceobj[1]); $where .= " AND (tb.price_avg >= {$priceobj[0]})"; if (isset($priceobj[1])) { $priceobj[1] = TravelHelper::convert_money_to_default($priceobj[1]); $where .= " AND (tb.price_avg <= {$priceobj[1]})"; } } if (isset($_REQUEST['range']) and isset($_REQUEST['location_id'])) { $range = STInput::request('range', '5'); $location_id = STInput::request('location_id'); $post_type = get_query_var('post_type'); $map_lat = (double) get_post_meta($location_id, 'map_lat', true); $map_lng = (double) get_post_meta($location_id, 'map_lng', true); global $wpdb; $where .= "\r\n AND {$wpdb->posts}.ID IN (\r\n SELECT ID FROM (\r\n SELECT {$wpdb->posts}.*,( 6371 * acos( cos( radians({$map_lat}) ) * cos( radians( mt1.meta_value ) ) *\r\n cos( radians( mt2.meta_value ) - radians({$map_lng}) ) + sin( radians({$map_lat}) ) *\r\n sin( radians( mt1.meta_value ) ) ) ) AS distance\r\n FROM {$wpdb->posts}, {$wpdb->postmeta} as mt1,{$wpdb->postmeta} as mt2\r\n WHERE {$wpdb->posts}.ID = mt1.post_id\r\n and {$wpdb->posts}.ID=mt2.post_id\r\n AND mt1.meta_key = 'map_lat'\r\n and mt2.meta_key = 'map_lng'\r\n AND {$wpdb->posts}.post_status = 'publish'\r\n AND {$wpdb->posts}.post_type = '{$post_type}'\r\n AND {$wpdb->posts}.post_date < NOW()\r\n GROUP BY {$wpdb->posts}.ID HAVING distance<{$range}\r\n ORDER BY distance ASC\r\n ) as st_data\r\n\t )"; } if (!empty($_REQUEST['taxonomy_hotel_room'])) { $tax = STInput::request('taxonomy_hotel_room'); if (!empty($tax) and is_array($tax)) { $tax_query = array(); foreach ($tax as $key => $value) { if ($value) { $ids = ""; $ids_tmp = explode(',', $value); if (!empty($ids_tmp)) { foreach ($ids_tmp as $k => $v) { if (!empty($v)) { $ids[] = $v; } } } if (!empty($ids)) { $tax_query[] = array('taxonomy' => $key, 'terms' => $ids); } } } $where_room = ''; if (!empty($tax_query)) { $where_room = ' AND ('; foreach ($tax_query as $k => $v) { $ids = implode(',', $v['terms']); if ($k > 0) { $where_room .= " AND "; } $where_room .= " (\r\n SELECT COUNT(1)\r\n FROM wp_term_relationships\r\n WHERE term_taxonomy_id IN ({$ids})\r\n AND object_id = wp_posts.ID\r\n ) = " . count($v['terms']) . " "; } $where_room .= " ) "; } $where .= " AND {$wpdb->posts}.ID IN\r\n (\r\n SELECT ID FROM\r\n (\r\n SELECT meta1.meta_value as ID\r\n FROM {$wpdb->prefix}posts\r\n\r\n INNER JOIN {$wpdb->prefix}postmeta as meta1 ON wp_posts.ID = meta1.post_id and meta1.meta_key='room_parent'\r\n WHERE 1=1\r\n {$where_room}\r\n AND {$wpdb->prefix}posts.post_type = 'hotel_room'\r\n GROUP BY meta1.meta_value\r\n ) as ids\r\n ) "; } } if (isset($_REQUEST['item_id']) and !empty($_REQUEST['item_id'])) { $item_id = STInput::request('item_id', ''); $where .= " AND ({$wpdb->prefix}posts.ID = '{$item_id}')"; } return $where; }
public function form($instance) { // title // list post type checkbox // review checkbox // location select if (isset($instance['title'])) { $title = $instance['title']; } else { $title = __('Title', ST_TEXTDOMAIN); } if (isset($instance['post_type'])) { $post_type = $instance['post_type']; } if (isset($instance['count_review'])) { $count_review = $instance['count_review']; } ?> <div class='location_widget_item'> <p> <label ><?php echo balancetags("Title", ST_TEXTDOMAIN); ?> </label> <input value='<?php echo esc_attr($title); ?> ' type='text' name='<?php echo $this->get_field_name('title'); ?> '/> </p> <p> <label><?php echo balancetags("Post type select ", ST_TEXTDOMAIN); ?> </label> <?php $get_post_type_list_active = STLocation::get_post_type_list_active(); if (!empty($get_post_type_list_active) and is_array($get_post_type_list_active)) { foreach (STLocation::get_post_type_list_active() as $key => $value) { ?> <br> <input <?php if (!empty($post_type) and $post_type and in_array($value, $post_type)) { echo esc_attr('checked'); } ?> id ='<?php echo esc_attr("st_w_" . $value); ?> ' value = '<?php echo esc_attr($value); ?> ' type='checkbox' name='<?php echo balancetags($this->get_field_name('post_type')); ?> []'/> <label ><?php echo esc_attr(STLocation::get_post_type_name($value, true)); ?> </label> <?php } } ?> </p> <p> <label><?php echo balancetags("Count Review", ST_TEXTDOMAIN); ?> </label> <input <?php if (!empty($count_review) and $count_review == 'on') { echo "checked"; } ?> type='checkbox' name='<?php echo balancetags($this->get_field_name('count_review')); ?> '/> </p> <p> <label><?php echo esc_attr("Location select", ST_TEXTDOMAIN); ?> </label> <?php $list_location = TravelerObject::get_list_location(); if (!empty($instance['location'])) { $old_location = $instance['location']; } //$old_location = $instance['location']; ?> <select name="<?php echo balancetags($this->get_field_name('location')); ?> " class="form-control"> <option value=""><?php _e('-- Select --', ST_TEXTDOMAIN); ?> </option> <?php foreach ($list_location as $k => $v) { ?> <option <?php if (!empty($old_location) and $old_location == $v['id']) { echo 'selected'; } ?> value="<?php echo esc_html($v['id']); ?> "> <?php echo esc_html($v['title']); ?> </option> <?php } ?> </select> </p> </div> <?php }
public static function hotel_room_external_booking_submit($post_id) { /* * since 1.1.1 * filter hook hotel_room_external_booking_submit */ $st_room_external_booking = get_post_meta($post_id, 'st_room_external_booking', "off"); $st_room_external_booking_link = get_post_meta($post_id, 'st_room_external_booking_link', true); if ($st_room_external_booking == "on" and $st_room_external_booking_link !== "") { if (get_post_meta($post_id, 'st_room_external_booking_link', true)) { ob_start(); ?> <a class='btn btn-primary btn_hotel_booking' href='<?php echo get_post_meta($post_id, 'st_room_external_booking_link', true); ?> '> <?php st_the_language('book_now'); ?> </a> <?php $return = ob_get_clean(); } } else { $return = TravelerObject::get_book_btn(); } return apply_filters('hotel_room_external_booking_submit', $return); }
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; }
if (!empty($get) and empty($hidde_button)) { foreach ($get as $key => $value) { if (is_array($value)) { if (!empty($value)) { foreach ($value as $key2 => $value2) { echo "<input type='hidden' name='{$key}[{$key2}]' value='{$value2}' >"; } } } else { if ($key != "price_range") { echo "<input type='hidden' name='{$key}' value='{$value}' >"; } } } } $data_min_max = TravelerObject::get_min_max_price('st_holidays'); $max = $data_min_max['price_max']; $min = $data_min_max['price_min']; if (TravelHelper::get_default_currency('rate') != 0 and TravelHelper::get_default_currency('rate')) { $rate_change = TravelHelper::get_current_currency('rate') / TravelHelper::get_default_currency('rate'); $max = round($rate_change * $max); $min = round($rate_change * $min); } /*$min = number_format($min , TravelHelper::get_current_currency('booking_currency_precision')) ; $max = number_format($max , TravelHelper::get_current_currency('booking_currency_precision')) ;*/ $value_show = $min . ";" . $max; // default if error if ($rate_change) { if (STInput::request('price_range')) { $price_range = explode(';', STInput::request('price_range')); $value_show = $price_range[0] . ";" . $price_range[1];
* */ ?> <form method="get" action=""> <?php $get = STInput::get(); if (!empty($get)) { foreach ($get as $key => $value) { if (is_array($value)) { if (!empty($value)) { foreach ($value as $key2 => $value2) { echo "<input type='hidden' name='{$key}[{$key2}]' value='{$value2}' >"; } } } else { if ($key != "price_range") { echo "<input type='hidden' name='{$key}' value='{$value}' >"; } } } } $data_min_max = TravelerObject::get_min_max_price($post_type); echo '<input type="text" name="price_range" value="' . STInput::get('price_range') . '" class="price-slider" data-symbol="' . TravelHelper::get_current_currency('symbol') . '" data-min="' . $data_min_max['price_min'] . '" data-max="' . $data_min_max['price_max'] . '" data-step="' . st()->get_option('search_price_range_step', 0) . '">'; ?> <button style="margin-top: 4px;" type="submit" class="btn btn-primary"><?php st_the_language('filter'); ?> </button> </form>
} return $ids; } /** * get current term by post id * * */ static function get_term_list_by_id($post_id = null) { if (!$post_id) { $post_id = get_the_ID(); } $list_taxonomy = st_list_taxonomy('st_tours'); $array = array(); if (!empty($list_taxonomy) and is_array($list_taxonomy)) { foreach ($list_taxonomy as $key => $value) { $array[$value] = wp_get_post_terms($post_id, $value, array()); } } return $array; } // from 1.1.9 function _show_wc_cart_item_information_btn($cart_item_key = array()) { //print balancetags("<br><p class ='btn btn-primary' data-toggle='collapse' data-target='#st_cart_item".md5(json_encode($cart_item_key))."'>".__("Details" , ST_TEXTDOMAIN)."</p>"); print balancetags('<br><span data-hide = "' . __("Less", ST_TEXTDOMAIN) . ' <i class="fa fa-angle-up">" data-target= "#st_cart_item' . md5(json_encode($cart_item_key)) . '" data-toggle="collapse" class="_show_wc_cart_item_information_btn text-color booking-item-review-expand-more">' . __("More", ST_TEXTDOMAIN) . ' <i class="fa fa-angle-down"></i></span>'); } } $a = new TravelerObject(); $a->_class_init();
if (!empty($get) and empty($hidde_button)) { foreach ($get as $key => $value) { if (is_array($value)) { if (!empty($value)) { foreach ($value as $key2 => $value2) { echo "<input type='hidden' name='{$key}[{$key2}]' value='{$value2}' >"; } } } else { if ($key != "price_range") { echo "<input type='hidden' name='{$key}' value='{$value}' >"; } } } } $data_min_max = TravelerObject::get_min_max_price('st_activity'); $max = $data_min_max['price_max']; $min = $data_min_max['price_min']; if (TravelHelper::get_default_currency('rate') != 0 and TravelHelper::get_default_currency('rate')) { $rate_change = TravelHelper::get_current_currency('rate') / TravelHelper::get_default_currency('rate'); $max = round($rate_change * $max); $min = round($rate_change * $min); } /*$min = number_format($min , TravelHelper::get_current_currency('booking_currency_precision')) ; $max = number_format($max , TravelHelper::get_current_currency('booking_currency_precision')) ;*/ $value_show = $min . ";" . $max; // default if error if ($rate_change) { if (STInput::request('price_range')) { $price_range = explode(';', STInput::request('price_range')); $value_show = $price_range[0] . ";" . $price_range[1];
extract($default); } $card_accepted = get_post_meta(get_the_ID(), 'card_accepted', true); ?> <?php if (!empty($card_accepted) and is_array($card_accepted)) { ?> <?php if ($title) { echo "<h4 class='text-{$align}'>{$title}</h4>"; } ?> <ul class="list-card-accepted text-<?php echo esc_attr($align); ?> "> <?php foreach ($card_accepted as $key => $value) { $card = TravelerObject::get_card($value); if ($card) { echo "<li><img src='{$card['image']}' alt='{$card['title']}' title='{$card['title']}'></li>"; } } ?> </ul> <?php } ?>
public static function activity_external_booking_submit() { /* * since 1.1.1 * filter hook activity_external_booking_submit */ $post_id = get_the_ID(); if (STInput::request('post_id')) { $post_id = STInput::request('post_id'); } $activity_external_booking = get_post_meta($post_id, 'st_activity_external_booking', "off"); $activity_external_booking_link = get_post_meta($post_id, 'st_activity_external_booking_link', true); if ($activity_external_booking == "on" and $activity_external_booking_link !== "") { if (get_post_meta($post_id, 'st_activity_external_booking_link', true)) { ob_start(); ?> <a class='btn btn-primary' href='<?php echo get_post_meta($post_id, 'st_activity_external_booking_link', true); ?> '> <?php st_the_language('book_now'); ?> </a> <?php $return = ob_get_clean(); } } else { $return = TravelerObject::get_book_btn(); } return apply_filters('activity_external_booking_submit', $return); }
static function _get_product_discount($amount, $products, $cart_items, $type = 'amount') { $discount = 0; if (!empty($products)) { foreach ($products as $key) { if (self::_check_in_items($key, $cart_items)) { if ($type == 'amount') { if ($cart_items[$key]['price'] > $amount) { $discount += $amount; } else { $discount += $cart_items[$key]['price']; } } elseif ($type == 'percent') { if ($amount > 100) { $amount = 100; } $discount += $cart_items[$key]['price'] / 100 * $amount; } } } } if (!empty($cart_items)) { foreach ($cart_items as $key => $value) { $booking_id = TravelerObject::get_orgin_booking_id($key); if (in_array($booking_id, $products)) { if ($type == 'amount') { if ($value['price'] > $amount) { $discount += $amount; } else { $discount += $value['price']; } } elseif ($type == 'percent') { if ($amount > 100) { $amount = 100; } $discount += $value['price'] / 100 * $amount; } } } } return $discount; }
<?php if (!st_check_service_available('st_cars')) { return; } if (function_exists('vc_map') and class_exists('TravelerObject')) { $list_taxonomy = st_list_taxonomy('st_cars'); $list_taxonomy = array_merge(array("---Select---" => ""), $list_taxonomy); $list_location = TravelerObject::get_list_location(); $list_location_data[__('-- Select --', ST_TEXTDOMAIN)] = ''; if (!empty($list_location)) { foreach ($list_location as $k => $v) { $list_location_data[$v['title']] = $v['id']; } } $param = array(array("type" => "textfield", "holder" => "div", "heading" => __("List ID in Car", ST_TEXTDOMAIN), "param_name" => "st_ids", "description" => __("Ids separated by commas", ST_TEXTDOMAIN), 'value' => ""), array("type" => "textfield", "holder" => "div", "heading" => __("Number cars", ST_TEXTDOMAIN), "param_name" => "st_number_cars", "description" => "", 'value' => 4), array("type" => "dropdown", "holder" => "div", "heading" => __("Order By", ST_TEXTDOMAIN), "param_name" => "st_orderby", "description" => "", 'edit_field_class' => 'vc_col-sm-6', 'value' => function_exists('st_get_list_order_by') ? st_get_list_order_by(array(__('Sale', ST_TEXTDOMAIN) => 'sale', __('Featured', ST_TEXTDOMAIN) => 'featured')) : array()), array("type" => "dropdown", "holder" => "div", "heading" => __("Order", ST_TEXTDOMAIN), "param_name" => "st_order", 'value' => array(__('--Select--', ST_TEXTDOMAIN) => '', __('Asc', ST_TEXTDOMAIN) => 'asc', __('Desc', ST_TEXTDOMAIN) => 'desc'), 'edit_field_class' => 'vc_col-sm-6'), array("type" => "dropdown", "holder" => "div", "heading" => __("Items per row", ST_TEXTDOMAIN), "param_name" => "st_cars_of_row", 'edit_field_class' => 'vc_col-sm-12', "value" => array(__('--Select--', ST_TEXTDOMAIN) => '', __('Four', ST_TEXTDOMAIN) => 4, __('Three', ST_TEXTDOMAIN) => 3, __('Two', ST_TEXTDOMAIN) => 2)), array("type" => "dropdown", "holder" => "div", "heading" => __("Sort By Taxonomy", ST_TEXTDOMAIN), "param_name" => "sort_taxonomy", "description" => "", "value" => $list_taxonomy)); $data_vc = STCars::get_taxonomy_and_id_term_car(); $param = array_merge($param, $data_vc['list_vc']); vc_map(array("name" => __("ST List of Cars", ST_TEXTDOMAIN), "base" => "st_list_cars", "content_element" => true, "icon" => "icon-st", "category" => "Shinetheme", "params" => $param)); } if (!function_exists('st_vc_list_cars')) { function st_vc_list_cars($attr, $content = false) { $data_vc = STCars::get_taxonomy_and_id_term_car(); $param = array('st_ids' => '', 'taxonomy' => '', 'st_number_cars' => 4, 'st_order' => '', 'st_orderby' => '', 'st_cars_of_row' => 4, 'sort_taxonomy' => '', 'st_location' => ''); $param = array_merge($param, $data_vc['list_id_vc']); $data = wp_parse_args($attr, $param); extract($data); $query = array('post_type' => 'st_cars', 'posts_per_page' => $st_number_cars, 'order' => $st_order, 'orderby' => $st_orderby); if (!empty($st_ids)) { $query['post__in'] = explode(',', $st_ids);
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 get_near_by($post_id = false, $range = 20, $limit = 5) { return parent::get_near_by($post_id, $range, $limit); }
function init() { parent::init(); }