';print_r($filter_args);echo ''; $status = $filter_args['status'] ?? ''; if (empty($status) || $status == 'all') { $status = ['publish', 'draft', 'private', 'trash']; } $page_number = absint($filter_args['page_number'] ?? 1) ?: 1; $limit = absint(($filter_args['page_item'] ?? 0) ?: ABPTB_Function::get_option('abptb_per_page_item', 20)); $count = ($page_number - 1) * $limit + 1; $cpt = ABPTB_Function::get_cpt(); $post_title = $filter_args['post_title'] ?? ''; $post_title = is_string($post_title) ? trim($post_title) : ''; $filters['status'] = $status; $filters['posts_per_page'] = $limit; $filters['paged'] = $page_number - 1; if ($post_title !== '') { $filters['post_title'] = $post_title; } //echo '
';print_r($filters);echo ''; $post_ids = ABPTB_Query::get_post_id($filters); if (!empty($post_ids) && sizeof($post_ids) > 0) { $count_filters = ['status' => $status]; if ($post_title !== '') { $count_filters['post_title'] = $post_title; } $total_post = sizeof(ABPTB_Query::get_post_id($count_filters)); $new_post_url = admin_url('post-new.php?post_type=' . $cpt); ?>
| . |
|
|
[abptb-post post_id=""] |
|
|---|
';print_r($all_sp_id);echo ''; //echo '
';print_r($all_ticket_types);echo ''; } /***********************************/ $route_data = []; $route_infos = []; $price_infos = []; $route_direction = []; $stops = $post_int_array('stop_name'); $types = $post_array('stop_type'); $display_pd = $post_array('display_pd'); $times = $post_int_array('stop_time'); if (!empty($stops)) { foreach ($stops as $key => $stop) { if (!empty($stop)) { $route_infos[$stop]['type'] = $types[$key] ?? 'both'; $route_infos[$stop]['time'] = $times[$key] ?? ''; $route_infos[$stop]['pd'] = $display_pd[$key] ?? 'off'; $route_direction[] = $stop; } } } $count = sizeof($route_infos); if ($count > 0) { $route_infos[array_key_first($route_infos)]['type'] = 'bp'; $route_infos[array_key_first($route_infos)]['time'] = 0; if ($count > 1) { $route_infos[array_key_last($route_infos)]['type'] = 'dp'; } } /***********************************/ $route_ids = $post_array('route_id'); if (!empty($route_ids) && !empty($all_ticket_types)) { foreach ($all_ticket_types as $ticket_type) { $price_data = $post_array($ticket_type . '_price'); if (!empty($price_data)) { foreach ($price_data as $key => $price) { $route_id = $route_ids[$key] ?? ''; if (!empty($route_id)) { $price_infos[$route_id][$ticket_type] = $price; $route_data[] = $route_id; } } } } } /***********************************/ $operation_time = []; $operation_times = $post_array('operation_time'); if (!empty($operation_times)) { $operation_time = array_values(array_unique(array_filter($operation_times))); sort($operation_time); } $time_info['time'] = !empty($operation_time) ? $operation_time : ['00:00']; $opt_time = $post_val('operation_time_optional'); $opt_time = !empty($opt_time) ? explode(',', $opt_time) : []; if (in_array('day_wise_time', $opt_time)) { $day_keys = $post_val('operation_time_day_name'); $day_keys = !empty($day_keys) ? explode(',', $day_keys) : []; foreach (ABPTB_Layout::week_day() as $key => $day) { $times = $post_array($key . '_time'); $times = array_filter($times); if (!empty($times) && in_array($key, $day_keys)) { sort($times); $time_info['day_time'][$key] = array_values(array_unique($times)); } } } if (in_array('date_wise_time', $opt_time)) { $date_time_ids = $post_array('date_wise_time_id'); $all_dates = $post_deep('date_wise_date'); $all_times = $post_deep('date_wise_time'); if (!empty($date_time_ids)) { foreach ($date_time_ids as $time_id) { $date_wise_dates = $all_dates[$time_id] ?? []; $date_wise_time = $all_times[$time_id] ?? []; if (!empty($date_wise_dates) && !empty($date_wise_time)) { $clean_dates = array_filter($date_wise_dates); $clean_dates = reset($clean_dates); $clean_times = array_filter($date_wise_time); if (!empty($clean_dates) && !empty($clean_times)) { sort($clean_times); $time_info['date_times'][$time_id]['date'] = $clean_dates; $time_info['date_times'][$time_id]['time'] = array_values(array_unique($clean_times)); } } } } } /***********************************/ $display_return = $post_val('display_return', 'off'); $return_route_infos = []; $return_price_infos = []; $return_time_info = []; $return_route_direction = []; if ($display_return == 'on') { $stops = $post_int_array('return_stop_name'); $types = $post_array('return_stop_type'); $display_pd = $post_array('return_display_pd'); $times = $post_int_array('return_stop_time'); if (!empty($stops)) { foreach ($stops as $key => $stop) { if (!empty($stop)) { $return_route_infos[$stop]['type'] = $types[$key] ?? 'both'; $return_route_infos[$stop]['time'] = $times[$key] ?? ''; $return_route_infos[$stop]['pd'] = $display_pd[$key] ?? 'off'; $return_route_direction[] = $stop; } } } $count = sizeof($return_route_infos); if ($count > 0) { $return_route_infos[array_key_first($return_route_infos)]['type'] = 'bp'; $return_route_infos[array_key_first($return_route_infos)]['time'] = 0; if ($count > 1) { $return_route_infos[array_key_last($return_route_infos)]['type'] = 'dp'; } } /*****************/ $route_ids = $post_array('return_route_id'); if (!empty($route_ids) && !empty($all_ticket_types)) { foreach ($all_ticket_types as $ticket_type) { $price_data = $post_array('return_' . $ticket_type . '_price'); if (!empty($price_data)) { foreach ($price_data as $key => $price) { $route_id = $route_ids[$key] ?? ''; if (!empty($route_id)) { $return_price_infos[$route_id][$ticket_type] = $price; $route_data[] = $route_id; } } } } } /*****************/ $operation_times = $post_array('return_operation_time'); $operation_time = !empty($operation_times) ? array_values(array_unique(array_filter($operation_times))) : []; $operation_time = !empty($operation_time) ? $operation_time : ['00:00']; sort($operation_time); $return_time_info['time'] = $operation_time; $opt_time = $post_val('return_operation_time_optional'); $opt_time = !empty($opt_time) ? explode(',', $opt_time) : []; if (in_array('return_day_wise_time', $opt_time)) { $day_keys = $post_val('return_operation_time_day_name'); $day_keys = !empty($day_keys) ? explode(',', $day_keys) : []; foreach (ABPTB_Layout::week_day() as $key => $day) { $times = $post_array('return_' . $key . '_time'); $times = array_filter($times); if (!empty($times) && in_array($key, $day_keys)) { sort($times); $return_time_info['day_time'][$key] = array_values(array_unique($times)); } } } if (in_array('return_date_wise_time', $opt_time)) { $date_time_ids = $post_array('return_date_wise_time_id'); $all_dates = $post_deep('return_date_wise_date'); $all_times = $post_deep('return_date_wise_time'); if (!empty($date_time_ids)) { foreach ($date_time_ids as $time_id) { $date_wise_dates = $all_dates[$time_id] ?? []; $date_wise_time = $all_times[$time_id] ?? []; if (!empty($date_wise_dates) && !empty($date_wise_time)) { $clean_dates = array_filter($date_wise_dates); $clean_times = array_filter($date_wise_time); if (!empty($clean_dates) && !empty($clean_times)) { sort($clean_times); $return_time_info['date_times'][$time_id]['date'] = reset($clean_dates); $return_time_info['date_times'][$time_id]['time'] = array_values(array_unique($clean_times)); } } } } } } //echo '
';print_r($return_time_info);echo '';die(); /***********************************/ $active_global_dates = $post_val('active_global_dates', 'on'); $abptb_dates = $active_global_dates == 'on' ? [] : apply_filters('abptb_get_date_array', []); $display_additional_services = $post_val('display_additional_services', 'off'); $active_global_additional = $display_additional_services == 'on' ? $post_val('active_global_additional', 'on') : 'off'; $additional_services = ($active_global_additional == 'on' || $display_additional_services == 'off') ? [] : apply_filters('abptb_get_additional_array', []); $display_client_form = $post_val('display_client_form', 'off'); $active_global_form = $display_client_form == 'on' ? $post_val('active_global_form', 'on') : 'off'; $abptb_form = ($active_global_form == 'on' || $display_client_form == 'off') ? [] : apply_filters('abptb_get_form_array', []); $display_faq = $post_val('display_faq', 'off'); $active_global_faq = $display_faq == 'on' ? $post_val('active_global_faq', 'on') : 'off'; $abptb_faq = ($active_global_faq == 'on' || $display_faq == 'off') ? [] : apply_filters('abptb_get_faq_array', []); $display_tc = $post_val('display_tc', 'off'); $active_global_tc = $display_tc == 'on' ? $post_val('active_global_tc', 'on') : 'off'; $abptb_tc = ($active_global_tc == 'on' || $display_tc == 'off') ? [] : $post_html('tc_content'); $meta_info = [ 'sale_continue' => $post_val('sale_continue', 'on'), 'abptb_template' => $post_val('abptb_template', 'default'), 'display_sku' => $post_val('display_sku', 'off'), 'post_sku' => $post_val('post_sku'), 'post_icon' => $post_val('post_icon'), 'sub_title' => $post_textarea('sub_title'), 'post_description' => $post_textarea('post_description'), 'display_organizer' => $post_val('display_organizer', 'off'), 'abptb_organizer' => $post_val('abptb_organizer'), 'display_brand' => $post_val('display_brand', 'off'), 'abptb_brand' => $post_val('abptb_brand'), 'display_capacity' => $post_val('display_capacity', 'on'), 'display_category' => $post_val('display_category', 'on'), 'abptb_category' => $post_val('abptb_category'), 'related_item' => $post_val('related_item'), 'post_feature' => $post_val('post_feature'), 'abptb_slider' => $post_val('abptb_slider'), //================// 'seat_type' => $seat_type, 'display_ticket_type' => $display_ticket_type, 'min_qty' => $post_int('min_qty'), 'max_qty' => $post_int('max_qty'), 'ticket_infos' => $ticket_infos, 'sp_infos' => $sp_infos, 'all_ticket_type' => $all_ticket_types, //================// 'routing_infos' => $route_infos, 'display_return' => $display_return, 'return_routing_infos' => $return_route_infos, 'route_data' => $route_data, //================// 'route_direction' => $route_direction, 'return_route_direction' => $return_route_direction, //================// 'price_infos' => $price_infos, 'return_price_infos' => $return_price_infos, 'price_data' => array_merge($price_infos, $return_price_infos), //================// 'active_global_dates' => $active_global_dates, 'abptb_dates' => $abptb_dates, 'time_infos' => $time_info, 'return_time_infos' => $return_time_info, 'display_additional_services' => $display_additional_services, 'active_global_additional' => $active_global_additional, 'additional_services' => $additional_services, 'display_client_form' => $display_client_form, 'active_global_form' => $active_global_form, 'display_single_form' => $post_val('display_single_form', 'on'), 'abptb_form' => $abptb_form, 'display_faq' => $display_faq, 'active_global_faq' => $active_global_faq, 'abptb_faq' => $abptb_faq, 'display_tc' => $display_tc, 'active_global_tc' => $active_global_tc, 'abptb_tc' => $abptb_tc, ]; //=============tax================// if (get_option('woocommerce_calc_taxes') == 'yes') { $meta_info['_tax_status'] = $post_val('_tax_status', 'none'); $meta_info['_tax_class'] = $post_val('_tax_class'); } //=============================// $meta_info = apply_filters('abptb_meta_info_update', $meta_info, $post_id); //echo '
';print_r($meta_info);echo '';die(); if (sizeof($meta_info) > 0) { foreach ($meta_info as $key => $value) { update_post_meta($post_id, sanitize_key($key), $value); } } } } public function post_permanent_remove(): void { if (!check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false) || !current_user_can('manage_options')) { wp_send_json_error(['msg' => __('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403); } $post_id = isset($_POST['post_id']) ? absint(wp_unslash($_POST['post_id'])) : 0; if ($post_id <= 0) { wp_send_json_error(['html' => '', 'msg' => __('Invalid ID ..... !! ', 'abp-transport-booking'), 'type' => 'warn'], 400); } $title = get_the_title($post_id); $link_wc_id = absint(ABPTB_Function::get_post_info($post_id, 'link_wc_id')); if ($link_wc_id > 0) { wp_delete_post($link_wc_id, true); } wp_delete_post($post_id, true); wp_send_json_success(['html' => '', 'msg' => $title . ' : ' . __('Permanently removed. ..... !! ', 'abp-transport-booking'), 'type' => 'error']); } public function post_move_trash(): void { if (!check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false) || !current_user_can('manage_options')) { wp_send_json_error(['msg' => __('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403); } $post_id = isset($_POST['post_id']) ? absint(wp_unslash($_POST['post_id'])) : 0; if ($post_id > 0) { $title = get_the_title($post_id); $link_wc_id = absint(ABPTB_Function::get_post_info($post_id, 'link_wc_id')); if ($link_wc_id > 0) { wp_trash_post($link_wc_id); } wp_trash_post($post_id); wp_send_json_success(['html' => '', 'msg' => $title . ' : ' . __('Moved to trash successfully...... !! ', 'abp-transport-booking'), 'type' => 'warn']); } wp_send_json_error(['html' => '', 'msg' => __('Invalid ID ..... !! ', 'abp-transport-booking'), 'type' => 'warn'], 400); } public function post_restore(): void { if (!check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false) || !current_user_can('manage_options')) { wp_send_json_error(['msg' => __('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403); } $post_id = isset($_POST['post_id']) ? absint(wp_unslash($_POST['post_id'])) : 0; if ($post_id > 0) { $link_wc_id = absint(ABPTB_Function::get_post_info($post_id, 'link_wc_id')); if ($link_wc_id > 0) { wp_untrash_post($link_wc_id); } wp_untrash_post($post_id); $updated_post = [ 'ID' => $post_id, 'post_status' => 'publish', ]; wp_update_post($updated_post); $title = get_the_title($post_id); wp_send_json_success(['html' => '', 'msg' => $title . ' : ' . __('Restored successfully...... !! ', 'abp-transport-booking'), 'type' => 'success']); } wp_send_json_error(['html' => '', 'msg' => __('Invalid ID ..... !! ', 'abp-transport-booking'), 'type' => 'warn'], 400); } public function reload_post_list(): void { if (!check_ajax_referer('abptb_admin_ajax_nonce', 'nonce', false) || !current_user_can('manage_options')) { wp_send_json_error(['msg' => __('Invalid security token or Insufficient permissions.', 'abp-transport-booking'), 'type' => 'warn'], 403); } $post_array = fn($key) => (isset($_POST[$key]) && is_array($_POST[$key])) ? array_map('sanitize_text_field', wp_unslash($_POST[$key])) : []; $filter_args = $post_array('filter_args'); ob_start(); $this->post_table($filter_args); $table_html = ob_get_clean(); wp_send_json_success([ 'html' => $table_html, 'type' => 'success', 'msg' => __('Post List Loaded successfully...... !! ', 'abp-transport-booking') ]); } } new ABPTB_Post(); }