$all_time, 'details' => '', 'form' => '', 'msg' => esc_html__( 'Session expired. Please refresh the page.', 'abp-rentalforge' ) ], 403 ); } $post_int = fn( $key, $default = '' ) => isset( $_POST[ $key ] ) ? absint( $_POST[ $key ] ) : $default; $post_val = fn( $key, $default = '' ) => isset( $_POST[ $key ] ) ? sanitize_text_field( wp_unslash( $_POST[ $key ] ) ) : $default; $post_id = $post_int( 'post_id' ); $all_dates = []; $all_end_dates = []; ob_start(); $params['global_order'] = 'yes'; $params['post_id'] = $post_id; do_action( 'abprf_search_form', $params ); $form_html = ob_get_clean(); ob_start(); if ( ! empty( $post_id ) ) { if(get_post_type( $post_id ) == ABPRF_Function::get_cpt() && (get_post_status($post_id)=='publish' || is_admin()) ) { $abprf_infos = ABPRF_Function::get_all_meta($post_id); $rent_rule = $post_val('rent_rule'); $rent_rule = !empty($rent_rule) ? $rent_rule : ABPRF_Function::get_post_info($post_id, 'rent_rule'); if (!empty($rent_rule) && $rent_rule != 'monthly') { $all_dates = ABPRF_Function::get_start_dates($post_id); $upcoming_date = current($all_dates); $upcoming_date = !empty($upcoming_date) ? gmdate('Y-m-d', strtotime($upcoming_date)) : ''; $all_end_dates = ABPRF_Function::get_end_dates($post_id, $upcoming_date, $all_dates); $all_dates = ABPRF_Layout::create_datepicker_array($all_dates); $all_end_dates = ABPRF_Layout::create_datepicker_array($all_end_dates); } if ($rent_rule == 'hourly' || $rent_rule == 'multi_day') { $all_time = ABPRF_Function::get_time($post_id, 'js'); } do_action('abprf_registration', $abprf_infos); $msg = get_the_title($post_id) . ' ' . __('Loaded Successfully.....! ', 'abp-rentalforge'); }else{ $msg = get_the_title($post_id) . ' ' . __('can not permission to view this.....! ', 'abp-rentalforge'); } } else { $params['all_post'] = ABPRF_Query::get_post_id( $params ); do_action( 'abprf_post_filter', $params ); include_once ABPRF_Function::template_path( 'list/default.php' ); do_action( 'abprf_default_template', $params ); $msg = __( 'Post List Loaded Successfully.....! ', 'abp-rentalforge' ); } $details = ob_get_clean(); wp_send_json_success( [ 'time_info' => $all_time, 'start_date' => $all_dates, 'end_date' => $all_end_dates, 'details' => $details, 'form' => $form_html, 'msg' => $msg ] ); } public function load_property(): void { if ( ! check_ajax_referer( 'abprf_ajax_nonce', 'nonce', false ) ) { wp_send_json_error( [ 'msg' => esc_html__( 'Session expired. Please refresh the page.', 'abp-rentalforge' ) ], 403 ); } $post_int = fn( $key, $default = '' ) => isset( $_POST[ $key ] ) ? absint( $_POST[ $key ] ) : $default; $post_val = fn( $key, $default = '' ) => isset( $_POST[ $key ] ) ? sanitize_text_field( wp_unslash( $_POST[ $key ] ) ) : $default; $abprf_infos = []; $post_id = $post_int( 'post_id' ); $rent_start_date = $post_val( 'rent_start_date' ); $rent_end_date = $post_val( 'rent_end_date' ); $rent_rule = $post_val( 'rent_rule' ); $rent_rule = ! empty( $rent_rule ) ? $rent_rule : ABPRF_Function::get_post_info( $post_id, 'rent_rule' ); $location = $post_val( 'location' ); $start = ''; $end = ''; $filter_arg['rent_continue'] = 'on'; $filter_arg['status'] = 'publish'; $date_info = []; if ( ! empty( $post_id ) ) { $abprf_infos['post_id'] = $post_id; $filter_arg['post_id'] = $post_id; } if ( ! empty( $rent_rule ) ) { $abprf_infos['rent_rule'] = $rent_rule; $filter_arg['rent_rule'] = $rent_rule; } if ( ! empty( $location ) ) { $abprf_infos['location'] = $location; $filter_arg['location'] = $location; } $properties = ABPRF_Query::get_property( $filter_arg ); if ( 'hourly' === $rent_rule && ! empty( $rent_start_date ) ) { $start_time = $post_val( 'start_time' ); $end_time = $post_val( 'end_time' ); $start = $rent_start_date . ' ' . $start_time; $end = $rent_start_date . ' ' . $end_time; $date_info = ABPRF_Function::get_date_time_difference( $start, $end, $rent_rule ); } elseif ( ( 'daily' === $rent_rule || 'multi_month' === $rent_rule ) && ! empty( $rent_start_date ) && ! empty( $rent_end_date ) ) { $start = gmdate( 'Y-m-d', strtotime( $rent_start_date ) ); $end = gmdate( 'Y-m-d', strtotime( $rent_end_date ) ); $date_info = ABPRF_Function::get_date_time_difference( $start, $end, $rent_rule ); } elseif ( 'multi_day' === $rent_rule && ! empty( $rent_start_date ) && ! empty( $rent_end_date ) ) { $start_time = $post_val( 'start_time' ); $end_time = $post_val( 'end_time' ); $start = $rent_start_date . ' ' . $start_time; $end = $rent_end_date . ' ' . $end_time; $date_info = ABPRF_Function::get_date_time_difference( $start, $end, $rent_rule ); } elseif ( 'monthly' === $rent_rule && ! empty( $rent_start_date ) && ! empty( $rent_end_date ) ) { $start = $rent_start_date; $end = $rent_end_date; $date_info = ABPRF_Function::get_date_time_difference( $start, $end, $rent_rule ); } $abprf_infos['start_time'] = $start; $abprf_infos['end_time'] = $end; $abprf_infos['date_info'] = $date_info; $check_date = ABPRF_Function::check_date_exit( $abprf_infos ); ob_start(); if ( ! empty( $post_id ) && ! empty( $properties ) && $check_date && (get_post_status($post_id)=='publish' || is_admin()) ) { $template = ABPRF_Function::get_post_info( $post_id, 'abprf_template', 'grid' ); ?> $property_info, 'property_others' => $property_others, 'date_details' => $date_details, 'msg' => __( 'Property List already Loaded !', 'abp-rentalforge' ) ] ); } public function load_end_date(): void { if ( ! check_ajax_referer( 'abprf_ajax_nonce', 'nonce', false ) ) { wp_send_json_error( [ 'msg' => esc_html__( 'Session expired. Please refresh the page.', 'abp-rentalforge' ) ], 403 ); } $post_int = fn( $key, $default = '' ) => isset( $_POST[ $key ] ) ? absint( $_POST[ $key ] ) : $default; $post_val = fn( $key, $default = '' ) => isset( $_POST[ $key ] ) ? sanitize_text_field( wp_unslash( $_POST[ $key ] ) ) : $default; $post_id = $post_int( 'post_id' ); $rent_start_date = $post_val( 'rent_start_date' ); $rent_rule = $post_val( 'rent_rule' ); $rent_start_date = ! empty( $rent_start_date ) ? gmdate( 'Y-m-d', strtotime( $rent_start_date ) ) : ''; $new_picker_config = []; ob_start(); if ( 'monthly' === $rent_rule ) { ABPRF_Layout::rent_end_month( $post_id, $rent_start_date ); } else { $all_end_dates = ABPRF_Function::get_end_dates( $post_id, $rent_start_date ); ABPRF_Layout::rent_end_date( $all_end_dates, $post_id ); $new_picker_config = ! empty( $all_end_dates ) ? ABPRF_Layout::create_datepicker_array( $all_end_dates ) : ''; } $html = ob_get_clean(); wp_send_json_success( [ 'html' => $html, 'msg' => esc_html__( 'Rent End Date Loaded successfully.', 'abp-rentalforge' ), 'picker_config' => $new_picker_config, 'selector' => '#end_date' ] ); } } new ABPRF_Ajax(); }