✏️ 正在编辑: comments.php
路径:
/home/h359620/public_html/wp-content/themes/datis/woocommerce/myaccount/comments.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_comments_per_page', 6, $user_id); /** * Query comments (filterable) * - By default: approved comments * - You can switch to 'all' if you want pending/spam too */ $query_args = apply_filters( 'datis_myaccount_comments_query_args', array( 'user_id' => $user_id, 'status' => 'approve', 'number' => $per_page, 'offset' => ($current_page - 1) * $per_page, 'orderby' => 'comment_date_gmt', 'order' => 'DESC', 'type' => 'comment', ), $user_id, $current_page, $per_page ); $comments = get_comments($query_args); // total for pagination $count_args = $query_args; unset($count_args['number'], $count_args['offset'], $count_args['orderby'], $count_args['order']); $count_args['count'] = true; $total_comments = (int) get_comments($count_args); $total_pages = (int) ceil($total_comments / max(1, $per_page)); $excerpt = function ($text, $len = 110) { $text = wp_strip_all_tags((string) $text); $text = preg_replace('/\s+/u', ' ', $text); $text = trim($text); if (mb_strlen($text) > $len) { $text = mb_substr($text, 0, $len) . '…'; } return $text; }; $demo = get_option('datis_active_demo'); ?> <div class="comments-shell"> <div class="comments-card"> <?php if (! empty($comments)) : ?> <div class="comments-titlebar"> <h2 class="comments-title"> <?php echo esc_html_x('My comments', 'Comments title', 'datis'); ?> </h2> </div> <div class="comments-table"> <div class="comments-headrow"> <div class="comments-col comments-col-on"><?php echo esc_html_x('On', 'Comments head', 'datis'); ?></div> <div class="comments-col comments-col-date"><?php echo esc_html_x('Date', 'Comments head', 'datis'); ?></div> <div class="comments-col comments-col-text"><?php echo esc_html_x('Comment', 'Comments head', 'datis'); ?></div> <div class="comments-col comments-col-actions"><?php echo esc_html_x('Actions', 'Comments head', 'datis'); ?></div> </div> <div class="comments-body"> <?php foreach ($comments as $comment) : if (! $comment instanceof WP_Comment) { continue; } $post_id = (int) $comment->comment_post_ID; $post = get_post($post_id); if (! $post) { continue; } $post_title = get_the_title($post_id); $post_type = get_post_type($post_id); $pt_obj = get_post_type_object($post_type); $pt_label = ($pt_obj && ! empty($pt_obj->labels->singular_name)) ? $pt_obj->labels->singular_name : $post_type; $date_ts = (int) get_comment_date('U', $comment); $date_text = $date_ts ? date_i18n(get_option('date_format'), $date_ts) : ''; $comment_text = $excerpt($comment->comment_content, 110); // best URL for exact comment (handles pagination) $view_url = apply_filters( 'datis_myaccount_comment_view_url', get_comment_link($comment), $comment, $user_id ); ?> <div class="comments-row"> <div class="comments-cell comments-col-on" data-label="<?php echo esc_attr_x('On', 'Comments label', 'datis'); ?>"> <span class="comments-text comments-on"> <?php echo esc_html(sprintf( /* translators: 1: post type label, 2: post title */ _x('%1$s: %2$s', 'Comment "On" text', 'datis'), $pt_label, $post_title )); ?> </span> </div> <div class="comments-cell comments-col-date" data-label="<?php echo esc_attr_x('Date', 'Comments label', 'datis'); ?>"> <span class="comments-text"><?php echo esc_html($date_text); ?></span> </div> <div class="comments-cell comments-col-text" data-label="<?php echo esc_attr_x('Comment', 'Comments label', 'datis'); ?>"> <span class="comments-text comments-content"><?php echo esc_html($comment_text); ?></span> </div> <div class="comments-cell comments-col-actions" data-label="<?php echo esc_attr_x('Actions', 'Comments label', 'datis'); ?>"> <a class="comments-btn" href="<?php echo esc_url($view_url); ?>"> <?php echo esc_html_x('View', 'Comments action', 'datis'); ?> </a> </div> </div> <?php endforeach; ?> </div> </div> <?php if ($total_pages > 1 && class_exists('Datis_Pagination')) : ?> <div class="comments-pagination mt-4"> <?php echo Datis_Pagination::get_instance()->render(null, array( 'total' => $total_pages, 'current' => $current_page, 'base_url' => wc_get_account_endpoint_url('comments'), 'format' => 'page/%#%/', 'wrap_class' => 'datis-pagination', 'item_class' => 'datis-pagination-item', 'current_class' => 'is-current', )); ?> </div> <?php endif; ?> <?php else : ?> <div class="comments-empty 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.08" /> <path d="M54.5 38.9081C51.8524 37.3765 48.7786 36.5 45.5 36.5C35.5589 36.5 27.5 44.5589 27.5 54.5C27.5 57.3794 28.1761 60.1009 29.3782 62.5144C29.6977 63.1558 29.804 63.8889 29.6188 64.5811L28.5467 68.588C28.0813 70.3274 29.6726 71.9187 31.412 71.4533L35.4189 70.3812C36.1111 70.196 36.8442 70.3023 37.4856 70.6218C39.8991 71.8239 42.6206 72.5 45.5 72.5C55.4411 72.5 63.5 64.4411 63.5 54.5C63.5 51.2214 62.6235 48.1476 61.0919 45.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" /> <path d="M63.5 55.6291C63.6496 55.5668 63.7979 55.502 63.9449 55.4348C64.7596 55.0627 65.6737 54.9235 66.5389 55.155L67.61 55.4416C69.7842 56.0234 71.7734 54.0342 71.1916 51.86L70.905 50.7889C70.6735 49.9236 70.8127 49.0096 71.1848 48.1949C72.0294 46.346 72.5 44.2904 72.5 42.125C72.5 39.2583 71.6752 36.5843 70.25 34.3272M44.375 36.4901C46.5814 31.2102 51.7949 27.5 57.875 27.5C60.7744 27.5 63.4768 28.3437 65.75 29.7991" stroke="currentColor" stroke-width="2" stroke-linecap="round" /> <path d="M37.6645 54.5H37.6848M45.5187 54.5H45.5389M53.3734 54.5H53.3937" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" /> </svg> <p><?php echo esc_html_x('You have not posted any comments yet.', 'Comments empty', 'datis'); ?></p> <a class="comments-empty-action" href="<?php echo esc_url(function_exists('wc_get_account_endpoint_url') ? wc_get_account_endpoint_url('dashboard') : home_url('/')); ?>"> <?php if ($demo == 'industry') : ?> <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M21.9844 10C21.9473 8.68893 21.8226 7.85305 21.4026 7.13974C20.8052 6.12523 19.7294 5.56066 17.5777 4.43152L15.5777 3.38197C13.8221 2.46066 12.9443 2 12 2C11.0557 2 10.1779 2.46066 8.42229 3.38197L6.42229 4.43152C4.27063 5.56066 3.19479 6.12523 2.5974 7.13974C2 8.15425 2 9.41667 2 11.9415V12.0585C2 14.5833 2 15.8458 2.5974 16.8603C3.19479 17.8748 4.27063 18.4393 6.42229 19.5685L8.42229 20.618C10.1779 21.5393 11.0557 22 12 22C12.9443 22 13.8221 21.5393 15.5777 20.618L17.5777 19.5685C19.7294 18.4393 20.8052 17.8748 21.4026 16.8603C21.8226 16.1469 21.9473 15.3111 21.9844 14" stroke="white" stroke-width="1.5" stroke-linecap="round" /> <path d="M21 7.5L17 9.5M12 12L3 7.5M12 12V21.5M12 12C12 12 14.7426 10.6287 16.5 9.75C16.6953 9.65237 17 9.5 17 9.5M17 9.5V13M17 9.5L7.5 4.5" stroke="white" stroke-width="1.5" stroke-linecap="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 : endif; ?> <?php echo esc_html_x('Go to dashboard', 'Notifications empty action', 'datis'); ?> </a> </div> <?php endif; ?> </div> </div>
💾 保存文件
← 返回文件管理器