✏️ 正在编辑: pagination-style-1.php
路径:
/home/h359620/public_html/wp-content/themes/datis/template-parts/pagination/pagination-style-1.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php if (empty($args) || !is_array($args)) { return; } $current = isset($args['current']) ? (int) $args['current'] : 1; $total = isset($args['total']) ? (int) $args['total'] : 1; $conf = isset($args['args']) ? (array) $args['args'] : []; if ($total <= 1) { return; } $wrap_class = isset($conf['wrap_class']) ? $conf['wrap_class'] . ' datis-pagination-style-1' : 'datis-pagination datis-pagination-style-1'; $item_class = isset($conf['item_class']) ? $conf['item_class'] : 'datis-pagination-item'; $current_class = isset($conf['current_class']) ? $conf['current_class'] : 'is-current'; $text_domain = isset($conf['text_domain']) ? $conf['text_domain'] : 'datis'; /** * NEW: Support custom base_url/format (My Account endpoints friendly) */ $base_url = isset($args['base_url']) ? (string) $args['base_url'] : ''; $format = isset($args['format']) ? (string) $args['format'] : ''; $base_url = $base_url !== '' ? trailingslashit($base_url) : ''; $format = $format !== '' ? $format : 'page/%#%/'; /** * Build page URL: * - If base_url is provided: base_url + format (e.g. /orders/page/2/) * - Else fallback to get_pagenum_link() */ $page_link = function (int $page) use ($base_url, $format): string { $page = max(1, (int) $page); if ($base_url !== '') { if ($page === 1) { return $base_url; } $fmt = str_replace('%#%', (string) $page, $format); return trailingslashit($base_url . ltrim($fmt, '/')); } return get_pagenum_link($page); }; $format_number = function ($num) { return number_format_i18n($num); }; $prev_icon = function (bool $disabled) { if ($disabled) { ?> <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="0.5" y="0.5" width="63" height="63" rx="31.5" stroke="#090625" stroke-opacity="0.16" /> <circle cx="32" cy="32" r="28" fill="#090625" fill-opacity="0.16" /> <g clip-path="url(#clip0_4019_2851)"> <path d="M40.4852 32L34.1213 25.636M40.4852 32L34.1212 38.364M40.4852 32L31.2928 32M23.5146 32L27.0502 32" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <defs> <clipPath id="clip0_4019_2851"> <rect width="24" height="24" fill="white" transform="matrix(0.707107 0.707107 0.707107 -0.707107 15.0293 32)" /> </clipPath> </defs> </svg> <?php } else { ?> <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="0.5" y="0.5" width="63" height="63" rx="31.5" stroke="#090625" stroke-opacity="0.5" /> <circle cx="32" cy="32" r="28" fill="#090625" fill-opacity="0.5" /> <g clip-path="url(#clip0_prev_active)"> <path d="M40.4852 32L34.1213 25.636M40.4852 32L34.1212 38.364M40.4852 32L31.2928 32M23.5146 32L27.0502 32" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <defs> <clipPath id="clip0_prev_active"> <rect width="24" height="24" fill="white" transform="matrix(0.707107 0.707107 0.707107 -0.707107 15.0293 32)" /> </clipPath> </defs> </svg> <?php } }; $next_icon = function (bool $disabled) { if ($disabled) { ?> <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="-0.5" y="0.5" width="63" height="63" rx="31.5" transform="matrix(-1 0 0 1 63 0)" stroke="#090625" stroke-opacity="0.16" /> <circle cx="28" cy="28" r="28" transform="matrix(-1 0 0 1 60 4)" fill="#090625" fill-opacity="0.16" /> <g clip-path="url(#clip0_4019_2843_dis)"> <path d="M23.5145 32L29.8785 25.636M23.5145 32L29.8785 38.364M23.5145 32L32.7069 32M40.4851 32L36.9496 32" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <defs> <clipPath id="clip0_4019_2843_dis"> <rect width="24" height="24" fill="white" transform="translate(48.9705 32) rotate(135)" /> </clipPath> </defs> </svg> <?php } else { ?> <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <rect x="-0.5" y="0.5" width="63" height="63" rx="31.5" transform="matrix(-1 0 0 1 63 0)" stroke="#090625" stroke-opacity="0.5" /> <circle cx="28" cy="28" r="28" transform="matrix(-1 0 0 1 60 4)" fill="#090625" fill-opacity="0.5" /> <g clip-path="url(#clip0_4019_2843)"> <path d="M23.5145 32L29.8785 25.636M23.5145 32L29.8785 38.364M23.5145 32L32.7069 32M40.4851 32L36.9496 32" stroke="#F7F6FE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <defs> <clipPath id="clip0_4019_2843"> <rect width="24" height="24" fill="white" transform="translate(48.9705 32) rotate(135)" /> </clipPath> </defs> </svg> <?php } }; ?> <nav class="<?php echo esc_attr($wrap_class); ?>" aria-label="<?php echo esc_attr__('Pagination', $text_domain); ?>"> <ul class="datis-pagination-list style-1"> <?php $is_first = ($current <= 1); $is_last = ($current >= $total); ?> <li class="<?php echo esc_attr($item_class . ' datis-pagination-prev' . ($is_first ? ' is-disabled' : '')); ?>"> <?php if ($is_first) : ?> <span aria-disabled="true"> <?php $prev_icon(true); ?> </span> <?php else : ?> <a href="<?php echo esc_url($page_link($current - 1)); ?>"> <?php $prev_icon(false); ?> </a> <?php endif; ?> </li> <?php for ($i = 1; $i <= $total; $i++) : ?> <?php $is_current = ($i === $current); $classes = $item_class . ' datis-pagination-page'; if ($is_current) { $classes .= ' ' . $current_class; } ?> <li class="<?php echo esc_attr($classes); ?>"> <?php if ($is_current) : ?> <span><?php echo esc_html($format_number($i)); ?></span> <?php else : ?> <a href="<?php echo esc_url($page_link($i)); ?>"> <?php echo esc_html($format_number($i)); ?> </a> <?php endif; ?> </li> <?php endfor; ?> <li class="<?php echo esc_attr($item_class . ' datis-pagination-next' . ($is_last ? ' is-disabled' : '')); ?>"> <?php if ($is_last) : ?> <span aria-disabled="true"> <?php $next_icon(true); ?> </span> <?php else : ?> <a href="<?php echo esc_url($page_link($current + 1)); ?>"> <?php $next_icon(false); ?> </a> <?php endif; ?> </li> </ul> </nav>
💾 保存文件
← 返回文件管理器