本文整理汇总了PHP中BYT_Theme_Utils::get_default_language_post_id方法的典型用法代码示例。如果您正苦于以下问题:PHP BYT_Theme_Utils::get_default_language_post_id方法的具体用法?PHP BYT_Theme_Utils::get_default_language_post_id怎么用?PHP BYT_Theme_Utils::get_default_language_post_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BYT_Theme_Utils
的用法示例。
在下文中一共展示了BYT_Theme_Utils::get_default_language_post_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sync_cruise_min_price
function sync_cruise_min_price($cruise_id, $min_price, $force = false)
{
$last_update_time = get_post_meta($cruise_id, '_cruise_min_price_last_update', true);
$last_update_time = isset($last_update_time) && !empty($last_update_time) ? $last_update_time : time();
$time_today = time();
$diff_hours = ($time_today - $last_update_time) / (60 * 60);
if ($diff_hours > 24 || $force) {
$cruise_id = BYT_Theme_Utils::get_default_language_post_id($cruise_id, 'cruise');
$languages = BYT_Theme_Utils::get_active_languages();
foreach ($languages as $language) {
$language_cruise_id = BYT_Theme_Utils::get_language_post_id($cruise_id, 'cruise', $language);
update_post_meta($language_cruise_id, '_cruise_min_price', $min_price);
update_post_meta($language_cruise_id, '_cruise_min_price_last_update', time());
}
}
}
示例2: get_base_id
/**
* Get the base ID of the post (ID of post in default language)
*
* @access public
* @return int
*/
public function get_base_id()
{
return apply_filters('bookyourtravel_entity_base_id', $this->post ? BYT_Theme_Utils::get_default_language_post_id($this->post->ID, $this->entity_type) : null, $this);
}
示例3: car_rental_get_booked_days
function car_rental_get_booked_days($car_rental_id, $month, $year)
{
global $wpdb;
$car_rental_id = BYT_Theme_Utils::get_default_language_post_id($car_rental_id, 'car_rental');
$sql = "\tSELECT DISTINCT booking_date, (car_rentals_meta_number_of_cars.meta_value+0) number_of_cars\r\n\t\t\t\t\tFROM " . BOOKYOURTRAVEL_CAR_RENTAL_BOOKING_DAYS_TABLE . " days\r\n\t\t\t\t\tINNER JOIN " . BOOKYOURTRAVEL_CAR_RENTAL_BOOKINGS_TABLE . " bookings ON bookings.Id = days.car_rental_booking_id \r\n\t\t\t\t\tINNER JOIN {$wpdb->postmeta} car_rentals_meta_number_of_cars ON bookings.car_rental_id=car_rentals_meta_number_of_cars.post_id AND car_rentals_meta_number_of_cars.meta_key='car_rental_number_of_cars' \r\n\t\t\t\t\tWHERE bookings.car_rental_id=%d AND booking_date >= %s AND MONTH(booking_date) = %d AND YEAR(booking_date) = %d\r\n\t\t\t\t\tGROUP BY booking_date\r\n\t\t\t\t\tHAVING COUNT(DISTINCT car_rental_booking_id) >= number_of_cars";
$today = date('Y-m-d H:i:s');
$sql = $wpdb->prepare($sql, $car_rental_id, $today, $month, $year);
return $wpdb->get_results($sql);
}
示例4: render_entry_form
function render_entry_form()
{
global $byt_cruises_post_type;
$cruise_id = 0;
$cabin_type_id = 0;
$schedule_object = null;
$cruise_obj = null;
$cabin_type_obj = null;
$is_price_per_person = 0;
$cruise_type_is_repeated = 0;
// on-off cruise by default
$edit = isset($_GET['edit']) ? absint($_GET['edit']) : "";
if (!empty($edit)) {
$schedule_object = $byt_cruises_post_type->get_cruise_schedule($edit);
}
if (isset($_POST['cruises_select'])) {
$cruise_id = wp_kses($_POST['cruises_select'], '');
} else {
if ($schedule_object != null) {
$cruise_id = $schedule_object->cruise_id;
}
}
if ($cruise_id) {
$cruise_obj = new byt_cruise(intval($cruise_id));
$cruise_id = $cruise_obj->get_base_id();
$cruise_type_is_repeated = $cruise_obj->get_type_is_repeated();
$is_price_per_person = $cruise_obj->get_is_price_per_person();
}
if (isset($_POST['cabin_types_select'])) {
$cabin_type_id = wp_kses($_POST['cabin_types_select'], '');
} else {
if ($schedule_object) {
$cabin_type_id = $schedule_object->cabin_type_id;
}
}
if (!empty($cabin_type_id)) {
$cabin_type_id = BYT_Theme_Utils::get_default_language_post_id($cabin_type_id, 'cabin_type');
}
$cruises_select = '<select id="cruises_select" name="cruises_select">';
$cruises_select .= '<option value="">' . __('Select cruise', 'bookyourtravel') . '</option>';
$author_id = null;
if (!is_super_admin()) {
$author_id = get_current_user_id();
}
$cruise_results = $byt_cruises_post_type->list_cruises(0, -1, 'title', 'ASC', 0, array(), array(), array(), false, $author_id);
if (count($cruise_results) > 0 && $cruise_results['total'] > 0) {
foreach ($cruise_results['results'] as $cruise_result) {
global $post;
$post = $cruise_result;
setup_postdata($post);
$cruises_select .= '<option value="' . $post->ID . '" ' . ($post->ID == $cruise_id ? 'selected' : '') . '>' . $post->post_title . '</option>';
}
}
$cruises_select .= '</select>';
$cabin_types_select = '<select class="normal" id="cabin_types_select" name="cabin_types_select">';
$cabin_types_select .= '<option value="">' . __('Select cabin type', 'bookyourtravel') . '</option>';
if ($cruise_obj) {
$cabin_type_ids = $cruise_obj->get_cabin_types();
if ($cabin_type_ids && count($cabin_type_ids) > 0) {
for ($i = 0; $i < count($cabin_type_ids); $i++) {
$temp_id = $cabin_type_ids[$i];
$cabin_type_obj = new byt_cabin_type(intval($temp_id));
$cabin_types_select .= '<option value="' . $temp_id . '" ' . ($temp_id == $cabin_type_id ? 'selected' : '') . '>' . $cabin_type_obj->get_title() . '</option>';
}
}
}
$cabin_types_select .= '</select>';
$start_date = null;
if (isset($_POST['start_date'])) {
$start_date = wp_kses($_POST['start_date'], '');
} else {
if ($schedule_object != null) {
$start_date = $schedule_object->start_date;
}
}
if (isset($start_date)) {
$start_date = date($this->date_format, strtotime($start_date));
}
$duration_days = 0;
if (isset($_POST['duration_days'])) {
$duration_days = intval(wp_kses($_POST['duration_days'], '0'));
} else {
if ($schedule_object != null) {
$duration_days = $schedule_object->duration_days;
}
}
$cabin_count = 1;
if (isset($_POST['cabin_count'])) {
$cabin_count = intval(wp_kses($_POST['cabin_count'], '1'));
} else {
if ($schedule_object && isset($schedule_object->cabin_count)) {
$cabin_count = $schedule_object->cabin_count;
}
}
if ($cabin_count == 0) {
$cabin_count = 1;
}
$price = 0;
if (isset($_POST['price'])) {
$price = floatval(wp_kses($_POST['price'], '2'));
//.........这里部分代码省略.........
示例5: render_entry_form
function render_entry_form()
{
global $byt_accommodations_post_type, $byt_room_types_post_type;
$accommodation_id = 0;
$is_self_catered = 0;
$vacancy_object = null;
$accommodation_obj = null;
$is_price_per_person = 0;
$edit = isset($_GET['edit']) ? absint($_GET['edit']) : "";
if (!empty($edit)) {
$vacancy_object = $byt_accommodations_post_type->get_accommodation_vacancy($edit);
}
if (isset($_POST['accommodations_select'])) {
$accommodation_id = wp_kses($_POST['accommodations_select'], '');
} else {
if ($vacancy_object) {
$accommodation_id = $vacancy_object->accommodation_id;
}
}
if ($accommodation_id) {
$accommodation_obj = new byt_accommodation(intval($accommodation_id));
$accommodation_id = $accommodation_obj->get_base_id();
$is_self_catered = $accommodation_obj->get_is_self_catered();
$is_price_per_person = $accommodation_obj->get_is_price_per_person();
}
$room_type_id = 0;
if (isset($_POST['room_types_select'])) {
$room_type_id = wp_kses($_POST['room_types_select'], '');
} else {
if ($vacancy_object) {
$room_type_id = $vacancy_object->room_type_id;
}
}
if (!empty($room_type_id)) {
$room_type_id = BYT_Theme_Utils::get_default_language_post_id($room_type_id, 'room_type');
}
$accommodations_select = '<select id="accommodations_select" name="accommodations_select">';
$accommodations_select .= '<option value="">' . __('Select accommodation', 'bookyourtravel') . '</option>';
$author_id = null;
if (!is_super_admin()) {
$author_id = get_current_user_id();
}
$accommodation_results = $byt_accommodations_post_type->list_accommodations(0, -1, 'title', 'ASC', 0, array(), array(), array(), false, null, $author_id);
if (count($accommodation_results) > 0 && $accommodation_results['total'] > 0) {
foreach ($accommodation_results['results'] as $accommodation_result) {
global $post;
$post = $accommodation_result;
setup_postdata($post);
$accommodations_select .= '<option value="' . $post->ID . '" ' . ($post->ID == $accommodation_id ? 'selected' : '') . '>' . $post->post_title . '</option>';
}
}
$accommodations_select .= '</select>';
$room_types_select = '';
if (!$is_self_catered) {
$room_types_select = '<select class="normal" id="room_types_select" name="room_types_select">';
$room_types_select .= '<option value="">' . __('Select room type', 'bookyourtravel') . '</option>';
if ($accommodation_obj) {
$room_type_ids = $accommodation_obj->get_room_types();
if ($room_type_ids && count($room_type_ids) > 0) {
for ($i = 0; $i < count($room_type_ids); $i++) {
$temp_id = $room_type_ids[$i];
$room_type_obj = new byt_room_type(intval($temp_id));
$room_types_select .= '<option value="' . $temp_id . '" ' . ($temp_id == $room_type_id ? 'selected' : '') . '>' . $room_type_obj->get_title() . '</option>';
}
}
}
$room_types_select .= '</select>';
}
wp_reset_postdata();
$date_from = null;
if (isset($_POST['date_from'])) {
$date_from = wp_kses($_POST['date_from'], '');
} else {
if ($vacancy_object) {
$date_from = $vacancy_object->start_date;
}
}
if (isset($date_from)) {
$date_from = date($this->date_format, strtotime($date_from));
}
$date_to = null;
if (isset($_POST['date_to'])) {
$date_to = wp_kses($_POST['date_to'], '');
} else {
if ($vacancy_object) {
$date_to = $vacancy_object->end_date;
}
}
if (isset($date_to)) {
$date_to = date($this->date_format, strtotime($date_to));
}
$room_count = 1;
if (isset($_POST['room_count'])) {
$room_count = intval(wp_kses($_POST['room_count'], ''));
} else {
if ($vacancy_object && isset($vacancy_object->room_count)) {
$room_count = $vacancy_object->room_count;
}
}
if ($room_count == 0) {
//.........这里部分代码省略.........