post_table($filter_args); ?>
' . esc_html($label), array($this, 'settings'), esc_attr(ABPRF_Function::get_cpt()), 'normal', 'high'); } //=============================// public function post_table($filter_args): void { //echo '
';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) ?: ABPRF_Function::get_option('abprf_per_page_item', 20)); $count = ($page_number - 1) * $limit + 1; $cpt = ABPRF_Function::get_cpt(); $filters['status'] = $status; $filters['posts_per_page'] = $limit; $filters['paged'] = $page_number - 1; $post_ids = ABPRF_Query::get_post_id($filters); if (!empty($post_ids) && sizeof($post_ids) > 0) { $total_post = sizeof(ABPRF_Query::get_post_id(['status' => $status])); $property_counts = ABPRF_Query::get_property_counts($post_ids); $new_post_url = admin_url('post-new.php?post_type=' . $cpt); ?> $post_id, '_abprf_nonce' => wp_create_nonce('abprf_copy_post_action'),), $new_post_url); ?>
.

[abprf-post post_id=""]

[abprf-property post_id=""]

$limit, 'page_number' => $page_number, 'total' => $total_post, 'style' => 'ajax']); } else { ABPRF_Layout::layout_warning_info('not_post_found'); } } public function settings(): void { $post_id = get_the_id(); $copy_post_id = isset($_GET['copy_post']) ? absint($_GET['copy_post']) : ''; if (!empty($copy_post_id) && isset($_GET['_abprf_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_GET['_abprf_nonce'])), 'abprf_copy_post_action') && current_user_can('edit_post', $copy_post_id)) { ?>
  • 🏠
  • 🗓️
  • 💰
  • 📋
  • 📚
general_configuration($abprf_infos); do_action('abprf_post_content', $abprf_infos); ?>

isset( $_POST[ $key ] ) ? absint( $_POST[ $key ] ) : $default; $post_val = fn($key, $default = '') => isset($_POST[$key]) ? sanitize_text_field(wp_unslash($_POST[$key])) : $default; $post_textarea = fn($key, $default = '') => isset($_POST[$key]) ? sanitize_textarea_field(wp_unslash($_POST[$key])) : $default; $post_html = fn($key, $default = '') => isset($_POST[$key]) ? wp_kses_post(wp_unslash($_POST[$key])) : $default; $post_int_array = fn($key) => (isset($_POST[$key]) && is_array($_POST[$key])) ? array_map('absint', wp_unslash($_POST[$key])) : []; //$post_array = fn( $key ) => ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST[ $key ] ) ) : []; //$post_textarea_array = fn( $key ) => ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) ? array_map( 'sanitize_textarea_field', wp_unslash( $_POST[ $key ] ) ) : []; //$post_html_array = fn( $key ) => ( isset( $_POST[ $key ] ) && is_array( $_POST[ $key ] ) ) ? array_map( 'wp_kses_post', wp_unslash( $_POST[ $key ] ) ) : []; //$format_date = fn( $date ) => $date ? gmdate( 'Y-m-d', strtotime( $date ) ) : ''; $templates = ['grid', 'group']; $abprf_template = $post_val('abprf_template', 'grid'); $meta_info = [ 'rent_continue' => $post_val('rent_continue', 'on'), 'display_sub_title' => $post_val('display_sub_title', 'off'), 'sub_title' => $post_textarea('sub_title'), 'display_sku' => $post_val('display_sku', 'off'), 'post_sku' => $post_val('post_sku'), 'post_icon' => $post_val('post_icon'), 'post_description' => $post_textarea('post_description'), 'abprf_template' => in_array($abprf_template, $templates) ? $abprf_template : 'grid', 'related_item' => $post_val('related_item'), 'display_category' => $post_val('display_category', 'off'), 'abprf_category' => $post_val('abprf_category'), 'display_location' => $post_val('display_location', 'off'), 'abprf_location' => $post_val('abprf_location'), 'rent_rule' => $post_val('rent_rule', 'hourly'), 'day_time_start' => $post_val('day_time_start'), 'day_time_end' => $post_val('day_time_end'), 'hour_threshold' => $post_val('hour_threshold', '24'), 'cut_off_date' => $post_val('cut_off_date', '10'), 'day_threshold' => $post_val('day_threshold', '30'), 'active_global_dates' => $post_val('active_global_dates', 'on'), 'abprf_dates' => apply_filters('abprf_get_date_array', []), 'display_additional_services' => $post_val('display_additional_services', 'off'), 'active_global_additional' => $post_val('active_global_additional', 'on'), 'additional_services' => apply_filters('abprf_get_additional_array', []), 'display_client_form' => $post_val('display_client_form', 'off'), 'active_global_form' => $post_val('active_global_form', 'on'), 'abprf_forms' => apply_filters('abprf_get_form_array', []), 'display_faq' => $post_val('display_faq', 'on'), 'active_global_faq' => $post_val('active_global_faq', 'on'), 'abprf_faqs' => apply_filters('abprf_get_faq_array', []), 'display_tc' => $post_val('display_tc', 'on'), 'active_global_tc' => $post_val('active_global_tc', 'on'), 'abprf_tc' => $post_html('tc_content'), ]; //=============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'); } //=============================// $old_rent_continue = ABPRF_Function::get_post_info($post_id, 'rent_continue', 'on'); //=============================// $meta_info = apply_filters('abprf_meta_info_update', $meta_info, $post_id); if (sizeof($meta_info) > 0) { foreach ($meta_info as $key => $value) { update_post_meta($post_id, sanitize_key($key), $value); } } //=============================// if (!empty(get_the_title($post_id))) { global $wpdb; $table_name = $wpdb->prefix . 'abprf_property'; $copy_post_id = isset($_POST['abprf_copy_post']) ? sanitize_text_field(wp_unslash($_POST['abprf_copy_post'])) : ''; if (!empty($copy_post_id) && current_user_can('edit_post', $copy_post_id)) { $copy_property_ids = $post_int_array('copy_property_id'); if (!empty($copy_property_ids) && sizeof($copy_property_ids) > 0) { foreach ($copy_property_ids as $property_id) { $properties = ABPRF_Query::get_property(['property_id' => $property_id]); if (!empty($properties) && is_array($properties) && sizeof($properties) > 0) { $property = current($properties); $data = [ 'post_id' => intval($post_id), 'rent_continue' => $property['rent_continue'] ?? '', 'name' => $property['name'] ?? '', 'brand' => $property['brand'] ?? '', 'category' => $property['category'] ?? '', 'location' => $property['location'] ?? '', 'features' => $property['features'] ?? '', 'rent_rule' => $property['rent_rule'] ?? '', 'price_qty_info' => $property['price_qty_info'] ?? '', 'gallery' => $property['gallery'] ?? '', 'status' => get_post_status($post_id), 'others' => $property['others'] ?? '', 'updated_at' => current_time('Y-m-d H:i') ]; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->insert($table_name, $data); } } } } else { if ($old_rent_continue !== $meta_info['rent_continue']) { $data['rent_continue'] = $meta_info['rent_continue']; } $data['status'] = get_post_status($post_id); $data['rent_rule'] = $meta_info['rent_rule']; $data['category'] = $meta_info['abprf_category']; $data['location'] = $meta_info['abprf_location']; $where = ['post_id' => $post_id]; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->update($table_name, $data, $where, array_fill(0, count($data), '%s'), ['%d']); } //=============================// ABPRF_Function::update_dates($post_id); ABPRF_Function::update_time_slot($post_id); ABPRF_Function::update_global_data($post_id); } } } public function post_permanent_remove(): void { if (!check_ajax_referer('abprf_admin_ajax_nonce', 'nonce', false)) { wp_send_json_error(['html' => '', 'msg' => __('Invalid security token.', 'abp-rentalforge')], 403); } if (!current_user_can('manage_options')) { wp_send_json_error(['html' => '', 'msg' => __('Insufficient permissions.', 'abp-rentalforge')], 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 Post ID ..... !! ', 'abp-rentalforge')], 400); } $link_wc_id = absint(ABPRF_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); global $wpdb; $table_name = $wpdb->prefix . 'abprf_property'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->delete($table_name, ['post_id' => $post_id], ['%d']); wp_send_json_success(['html' => '', 'msg' => __('Post permanently removed. ..... !! ', 'abp-rentalforge')]); } public function post_move_trash(): void { if (!check_ajax_referer('abprf_admin_ajax_nonce', 'nonce', false)) { wp_send_json_error(['html' => '', 'msg' => __('Invalid security token.', 'abp-rentalforge')], 403); } if (!current_user_can('manage_options')) { wp_send_json_error(['html' => '', 'msg' => __('Insufficient permissions.', 'abp-rentalforge')], 403); } $post_id = isset($_POST['post_id']) ? absint(wp_unslash($_POST['post_id'])) : 0; if ($post_id > 0) { $link_wc_id = absint(ABPRF_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); global $wpdb; $table_name = $wpdb->prefix . 'abprf_property'; $current_status = get_post_status($post_id) ? get_post_status($post_id) : 'trash'; $data = ['status' => $current_status]; $where = ['post_id' => $post_id]; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->update($table_name, $data, $where, ['%s', '%s', '%s'], ['%d']); wp_send_json_success(['html' => '', 'msg' => __('Post moved to trash successfully...... !! ', 'abp-rentalforge')]); } wp_send_json_error(['html' => '', 'msg' => __('Invalid Post ID ..... !! ', 'abp-rentalforge')], 400); } public function post_restore(): void { if (!check_ajax_referer('abprf_admin_ajax_nonce', 'nonce', false)) { wp_send_json_error(['html' => '', 'msg' => __('Invalid security token.', 'abp-rentalforge')], 403); } if (!current_user_can('manage_options')) { wp_send_json_error(['html' => '', 'msg' => __('Insufficient permissions.', 'abp-rentalforge')], 403); } $post_id = isset($_POST['post_id']) ? absint(wp_unslash($_POST['post_id'])) : 0; if ($post_id > 0) { $link_wc_id = absint(ABPRF_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); global $wpdb; $table_name = $wpdb->prefix . 'abprf_property'; $current_status = get_post_status($post_id) ? get_post_status($post_id) : 'publish'; $data = ['status' => $current_status]; $where = ['post_id' => $post_id]; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->update($table_name, $data, $where, ['%s', '%s', '%s'], ['%d']); wp_send_json_success(['html' => '', 'msg' => __('Property restored successfully...... !! ', 'abp-rentalforge')]); } wp_send_json_error(['html' => '', 'msg' => __('Invalid Post ID ..... !! ', 'abp-rentalforge')], 400); } public function reload_post_list(): void { if (!check_ajax_referer('abprf_admin_ajax_nonce', 'nonce', false)) { wp_send_json_error(['html' => '', 'msg' => __('Invalid security token.', 'abp-rentalforge'), 'type' => 'warn'], 403); } if (!current_user_can('manage_options')) { wp_send_json_error(['html' => '', 'msg' => __('Insufficient permissions.', 'abp-rentalforge'), '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-rentalforge') ]); } } new ABPRF_Post(); }