✏️ 正在编辑: downloads.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/myaccount/downloads.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php defined('ABSPATH') || exit; $user_id = get_current_user_id(); $current_page = max(1, absint(get_query_var('paged'))); $per_page = (int) apply_filters('datis_myaccount_downloads_per_page', 6, $user_id); /** * Woo downloads */ $all_downloads = function_exists('wc_get_customer_available_downloads') ? wc_get_customer_available_downloads($user_id) : []; $all_downloads = is_array($all_downloads) ? $all_downloads : []; $all_downloads = apply_filters('datis_myaccount_downloads_items', $all_downloads, $user_id); $total_items = count($all_downloads); $total_pages = (int) ceil($total_items / max(1, $per_page)); $offset = ($current_page - 1) * $per_page; $downloads = array_slice($all_downloads, $offset, $per_page); $demo = get_option('datis_active_demo'); ?> <div class="orders-shell"> <div class="orders-card"> <?php if (!empty($downloads)) : ?> <div class="orders-titlebar"> <h2 class="orders-title"><?php echo esc_html_x('My downloads', 'Downloads title', 'datis'); ?></h2> </div> <div class="orders-table"> <div class="orders-headrow"> <div class="orders-col orders-col-track"><?php echo esc_html_x('Tracking code', 'Downloads head', 'datis'); ?></div> <div class="orders-col orders-col-date"><?php echo esc_html_x('Order date', 'Downloads head', 'datis'); ?></div> <div class="orders-col orders-col-status"><?php echo esc_html_x('Status', 'Downloads head', 'datis'); ?></div> <div class="orders-col orders-col-total"><?php echo esc_html_x('Total', 'Downloads head', 'datis'); ?></div> <div class="orders-col orders-col-actions"><?php echo esc_html_x('Actions', 'Downloads head', 'datis'); ?></div> </div> <div class="orders-body"> <?php foreach ($downloads as $item) : $order_id = !empty($item['order_id']) ? absint($item['order_id']) : 0; $product_id = !empty($item['product_id']) ? absint($item['product_id']) : 0; $product_name = !empty($item['product_name']) ? (string) $item['product_name'] : ''; $download_name = !empty($item['download_name']) ? (string) $item['download_name'] : ''; $download_url = !empty($item['download_url']) ? (string) $item['download_url'] : ''; $order = $order_id ? wc_get_order($order_id) : false; $order_number = ($order instanceof WC_Order) ? $order->get_order_number() : '—'; $date_obj = ($order instanceof WC_Order) ? $order->get_date_created() : null; $date_text = $date_obj ? wc_format_datetime($date_obj) : '—'; /** * Status in downloads page (Remaining downloads) */ $remaining_raw = isset($item['downloads_remaining']) ? $item['downloads_remaining'] : ''; if ($remaining_raw === '' || $remaining_raw === null) { $remaining_text = esc_html_x('Unlimited', 'Downloads remaining', 'datis'); } elseif ((string)$remaining_raw === '0') { $remaining_text = '0'; } else { $remaining_text = (string) $remaining_raw; } /** * Total column in downloads UI (Expires) */ $expires = isset($item['access_expires']) ? $item['access_expires'] : null; if (empty($expires)) { $expires_text = esc_html_x('Never', 'Downloads expiry', 'datis'); } else { $ts = is_numeric($expires) ? (int) $expires : strtotime((string) $expires); $expires_text = $ts ? date_i18n(get_option('date_format'), $ts) : esc_html_x('—', 'Downloads expiry fallback', 'datis'); } /** * Product thumb (right side like image) */ $thumb_html = ''; if ($product_id && function_exists('wc_get_product')) { $product = wc_get_product($product_id); if ($product) { $thumb_html = $product->get_image('thumbnail'); } } if ($thumb_html === '') { // small placeholder (same role as image in your screenshot) $thumb_html = '<span class="download-product-thumb-placeholder" aria-hidden="true"></span>'; } // Optional "trash" action placeholder (you can wire it later) $trash_url = apply_filters('datis_myaccount_downloads_trash_url', '', $item, $user_id); ?> <div class="orders-row"> <div class="orders-cell orders-col-track" data-label="<?php echo esc_attr_x('Tracking code', 'Downloads label', 'datis'); ?>"> <span class="orders-text orders-track"><?php echo esc_html($order_number); ?></span> </div> <div class="orders-cell orders-col-date" data-label="<?php echo esc_attr_x('Order date', 'Downloads label', 'datis'); ?>"> <span class="orders-text"><?php echo esc_html($date_text); ?></span> </div> <div class="orders-cell orders-col-status" data-label="<?php echo esc_attr_x('Status', 'Downloads label', 'datis'); ?>"> <span class="order-status status-default"> <span class="order-status-dot" aria-hidden="true"></span> <span class="order-status-text"> <?php echo esc_html($remaining_text); ?> </span> </span> </div> <div class="orders-cell orders-col-total" data-label="<?php echo esc_attr_x('Total', 'Downloads label', 'datis'); ?>"> <span class="orders-text"><?php echo esc_html($expires_text); ?></span> </div> <div class="orders-cell orders-col-actions" data-label="<?php echo esc_attr_x('Actions', 'Downloads label', 'datis'); ?>"> <!-- keep it close to screenshot: download button + trash icon + product name + thumb --> <div class="download-actions-inline"> <a class="orders-btn" href="<?php echo esc_url($download_url); ?>"> <?php echo esc_html_x('Download file', 'Downloads action', 'datis'); ?> </a> </div> </div> </div> <?php endforeach; ?> </div> </div> <?php if ($total_pages > 1 && class_exists('Datis_Pagination')) : ?> <div class="orders-pagination mt-4"> <?php echo Datis_Pagination::get_instance()->render(null, [ 'total' => $total_pages, 'current' => $current_page, 'base_url' => wc_get_account_endpoint_url('downloads'), 'format' => 'page/%#%/', 'wrap_class' => 'datis-pagination-list', 'item_class' => 'datis-pagination-item', 'current_class' => 'is-current', ]); ?> </div> <?php endif; ?> <?php else : ?> <!-- Empty state similar to your orders empty (simple) --> <div class="empty-orders d-flex flex-column align-items-center justify-content-center gap-3 w-100"> <svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect width="100" height="100" rx="20" fill="currentColor" fill-opacity="0.06" /> <path d="M43.25 36.5V34.25C43.25 30.5221 46.2721 27.5 50 27.5C53.7279 27.5 56.75 30.5221 56.75 34.25V36.5" stroke="currentColor" stroke-width="3" stroke-linecap="round" /> <path d="M43.6348 56.75C44.5614 59.3717 47.0617 61.25 50.0007 61.25C52.9397 61.25 55.44 59.3717 56.3666 56.75" stroke="currentColor" stroke-width="3" stroke-linecap="round" /> <path d="M68.5025 51.1828C67.1857 44.1602 66.5274 40.6488 64.0278 38.5744C61.5283 36.5 57.9558 36.5 50.8108 36.5H49.1881C42.0431 36.5 38.4706 36.5 35.9711 38.5744C33.4716 40.6488 32.8132 44.1602 31.4964 51.1828C29.6449 61.0579 28.7191 65.9955 31.4182 69.2477C34.1174 72.5 39.141 72.5 49.1881 72.5H50.8108C60.858 72.5 65.8816 72.5 68.5807 69.2477C70.1467 67.3608 70.4925 64.9066 70.1452 61.25" stroke="currentColor" stroke-width="3" stroke-linecap="round" /> </svg> <p><?php echo esc_html_x('Your downloads list is empty.', 'Downloads empty', 'datis'); ?></p> <a href="<?php echo esc_url(function_exists('wc_get_page_permalink') ? wc_get_page_permalink('shop') : home_url('/')); ?>"> <?php if ($demo == 'industry') : ?> <svg width="14" height="13" viewBox="0 0 14 13" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M12.7701 11.8579L10.8921 10.2077M0.750669 1.29699L9.2183 0.750029M0.750669 1.29699L1.29763 9.76463M0.750669 1.29699L8.63844 8.22758" stroke="#F5F5F5" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php elseif ($demo == 'business'): ?> <svg width="44" height="40" viewBox="0 0 44 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M10 40C4.47715 40 -1.95703e-07 35.5228 -4.37114e-07 30L-1.31134e-06 10C-1.55275e-06 4.47715 4.47715 -1.95703e-07 10 -4.37114e-07L33.1922 -1.45088e-06C39.6979 -1.73525e-06 44.4715 6.11389 42.8937 12.4254L37.8937 32.4254C36.7807 36.877 32.7809 40 28.1922 40L10 40Z" fill="#F9E65C" /> <path d="M15.3433 15.3139H22.3286M15.3433 15.3139V22.2992M15.3433 15.3139L21.4554 21.4261M24.657 24.6276L23.2017 23.1724" stroke="#0A2647" stroke-width="1.23483" stroke-linecap="round" stroke-linejoin="round" /> </svg> <?php else : ?> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M6 6H15M6 6V15M6 6L12.5 12.5M18 18L15.5 15.5" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> </svg> <?php endif; ?> <?php if ($demo == 'industry' || $demo == 'business') : echo esc_html_x('Shop', 'Downloads empty action', 'datis'); else : ?> <span><?php echo esc_html_x('Shop', 'Downloads empty action', 'datis'); ?></span> <?php endif; ?> </a> </div> <?php endif; ?> </div> </div>
💾 保存文件
← 返回文件管理器