✏️ 正在编辑: consultations.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/myaccount/consultations.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php defined('ABSPATH') || exit; $user_id = get_current_user_id(); if (!$user_id) { echo '<div class="orders-shell"><div class="orders-card">'; echo esc_html__('You must be logged in to view your consultation requests.', 'datis'); echo '</div></div>'; return; } /** * Current page (My Account custom endpoint pagination) * /my-account/consultations/page/2/ => get_query_var('consultations') === "page/2" */ $current_page = max(1, absint(get_query_var('paged'))); $per_page = (int) apply_filters('datis_myaccount_consultations_per_page', 6, $user_id); if ($per_page <= 0) { $per_page = 6; } $cpt = 'consultation_request'; $status_map = [ 'pending' => __('Waiting for review', 'datis'), 'in_progress' => __('In progress', 'datis'), 'approved' => __('Done', 'datis'), 'rejected' => __('Rejected', 'datis'), 'draft' => __('Draft', 'datis'), ]; $tabs = [ 'all' => __('All requests', 'datis'), 'pending' => __('Waiting for review', 'datis'), 'in_progress' => __('In progress', 'datis'), 'approved' => __('Done', 'datis'), ]; /** * Query (IMPORTANT) * - Do NOT use offset with paged. * - Keep no_found_rows = false so max_num_pages works. */ $args = [ 'post_type' => $cpt, 'post_status' => ['publish', 'private', 'draft', 'pending', 'future', 'auto-draft'], 'posts_per_page' => $per_page, 'paged' => $current_page, 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true, 'no_found_rows' => false, 'meta_query' => [ [ 'key' => '_datis_cr_user_id', 'value' => $user_id, 'compare' => '=', 'type' => 'NUMERIC', ], ], ]; $q = new WP_Query($args); /** * Fallback: old items by author (if some records were saved without meta user_id) * Still paginated properly. */ if (!$q->have_posts()) { unset($args['meta_query']); $args['author'] = $user_id; $q = new WP_Query($args); } /** * Date helper (Jalali optional) */ if (!function_exists('datis_cr_display_date')) { function datis_cr_display_date($post_id) { $submitted_at_g = get_post_field('post_date', $post_id); // Y-m-d H:i:s $date_g = $submitted_at_g ? substr($submitted_at_g, 0, 10) : ''; if (!$date_g) { return '—'; } $calendar_mode = (class_exists('Datis_Consultation_Settings')) ? Datis_Consultation_Settings::get_calendar_mode_for_language() : (is_rtl() ? 'jalali' : 'gregorian'); if ($calendar_mode !== 'jalali') { return $date_g; } if (class_exists('Datis_Consultation_Requests') && method_exists('Datis_Consultation_Requests', 'gregorian_to_jalali')) { $parts = explode('-', $date_g); if (count($parts) === 3) { return Datis_Consultation_Requests::gregorian_to_jalali((int) $parts[0], (int) $parts[1], (int) $parts[2], '/'); } } if (function_exists('jdate')) { return jdate('Y/m/d', strtotime($date_g)); } return $date_g; } } $total_pages = (int) $q->max_num_pages; $base_url = function_exists('wc_get_account_endpoint_url') ? wc_get_account_endpoint_url('consultations') : home_url('/'); ?> <div class="orders-shell"> <div class="orders-card"> <div class="orders-titlebar" style="display:flex;align-items:center;justify-content:space-between;gap:16px;"> <h2 class="orders-title"><?php echo esc_html__('Consultation requests', 'datis'); ?></h2> <div class="consult-req-tabs" role="tablist" aria-label="<?php echo esc_attr__('Consultation filters', 'datis'); ?>"> <?php foreach ($tabs as $k => $label) : ?> <button type="button" class="consult-req-tab <?php echo $k === 'all' ? 'is-active' : ''; ?>" data-filter="<?php echo esc_attr($k); ?>" role="tab" aria-selected="<?php echo $k === 'all' ? 'true' : 'false'; ?>" > <?php echo esc_html($label); ?> </button> <?php endforeach; ?> </div> </div> <?php if ($q->have_posts()) : ?> <div class="orders-table datis-cr-table"> <div class="orders-headrow"> <div class="orders-col orders-col-track"><?php echo esc_html__('Applicant name', 'datis'); ?></div> <div class="orders-col orders-col-date"><?php echo esc_html__('Consultation type', 'datis'); ?></div> <div class="orders-col orders-col-status"><?php echo esc_html__('Order status', 'datis'); ?></div> <div class="orders-col orders-col-total"><?php echo esc_html__('Order date', 'datis'); ?></div> <div class="orders-col orders-col-actions"><?php echo esc_html__('Actions', 'datis'); ?></div> </div> <div class="orders-body datis-cr-body"> <?php while ($q->have_posts()) : $q->the_post(); $post_id = get_the_ID(); $full_name = get_post_meta($post_id, '_datis_cr_full_name', true); $consult_type = get_post_meta($post_id, '_datis_cr_project_type', true); $status = get_post_meta($post_id, '_datis_cr_status', true); if (!$status) { $wp_status = get_post_status($post_id); $status = $wp_status ? $wp_status : 'pending'; } $status_label = isset($status_map[$status]) ? $status_map[$status] : $status; $status_class = 'status-' . sanitize_html_class($status); $date_text = datis_cr_display_date($post_id); $details_url = apply_filters('datis_myaccount_consult_request_details_url', '', $post_id, $user_id); ?> <div class="orders-row datis-cr-row" data-status="<?php echo esc_attr($status); ?>"> <div class="orders-cell orders-col-track" data-label="<?php echo esc_attr__('Applicant name', 'datis'); ?>"> <span class="orders-text"><?php echo esc_html($full_name ?: '—'); ?></span> </div> <div class="orders-cell orders-col-date" data-label="<?php echo esc_attr__('Consultation type', 'datis'); ?>"> <span class="orders-text"><?php echo esc_html($consult_type ?: '—'); ?></span> </div> <div class="orders-cell orders-col-status" data-label="<?php echo esc_attr__('Order status', 'datis'); ?>"> <span class="order-status <?php echo esc_attr($status_class); ?>"> <span class="order-status-dot" aria-hidden="true"></span> <span class="order-status-text"><?php echo esc_html($status_label); ?></span> </span> </div> <div class="orders-cell orders-col-total" data-label="<?php echo esc_attr__('Order date', 'datis'); ?>"> <span class="orders-text"><?php echo esc_html($date_text); ?></span> </div> <div class="orders-cell orders-col-actions" data-label="<?php echo esc_attr__('Actions', 'datis'); ?>"> <div class="download-actions-inline"> <?php if (!empty($details_url)) : ?> <a class="orders-btn" href="<?php echo esc_url($details_url); ?>"> <?php echo esc_html__('View details', 'datis'); ?> </a> <?php else : ?> <span class="orders-btn" style="opacity:.6;cursor:not-allowed;"> <?php echo esc_html__('View details', 'datis'); ?> </span> <?php endif; ?> </div> </div> </div> <?php endwhile; wp_reset_postdata(); ?> </div> </div> <?php if ($total_pages > 1 && class_exists('Datis_Pagination')) : ?> <div class="orders-pagination mt-4"> <?php echo Datis_Pagination::get_instance()->render($q, [ 'total' => $total_pages, 'current' => $current_page, 'base_url' => trailingslashit($base_url), 'format' => 'page/%#%/', 'wrap_class' => 'datis-pagination-list', 'item_class' => 'datis-pagination-item', 'current_class' => 'is-current', ]); ?> </div> <?php endif; ?> <?php else : ?> <div class="empty-orders d-flex flex-column align-items-center justify-content-center gap-3 w-100"> <p><?php echo esc_html__('Your consultation requests list is empty.', 'datis'); ?></p> </div> <?php endif; ?> </div> </div>
💾 保存文件
← 返回文件管理器