✏️ 正在编辑: pagination-style-2.php
路径:
/home/h359620/public_html/wp-content/themes/datis/template-parts/pagination/pagination-style-2.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="4" y="4" width="56" height="56" rx="16" fill="#0A2647" fill-opacity="0.04" /> <g clip-path="url(#clip0_734_2381)"> <path d="M40.4852 32L34.1213 25.636M40.4852 32L34.1212 38.364M40.4852 32L31.2928 32M23.5146 32L27.0502 32" stroke="#0A2647" stroke-opacity="0.64" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <rect x="0.5" y="0.5" width="63" height="63" rx="15.5" stroke="#0A2647" stroke-opacity="0.04" /> <defs> <clipPath id="clip0_734_2381"> <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="4" y="4" width="56" height="56" rx="16" fill="var(--datis-secondary-color)" /> <g clip-path="url(#clip0_734_2371)"> <path d="M40.4852 32L34.1213 25.636M40.4852 32L34.1212 38.364M40.4852 32L31.2928 32M23.5146 32L27.0502 32" stroke="#0A2647" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <rect x="0.5" y="0.5" width="63" height="63" rx="15.5" stroke="var(--datis-secondary-color)" /> <defs> <clipPath id="clip0_734_2371"> <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 width="56" height="56" rx="16" transform="matrix(-1 0 0 1 60 4)" fill="#0A2647" fill-opacity="0.04" /> <g clip-path="url(#clip0_734_2381)"> <path d="M23.5148 32L29.8787 25.636M23.5148 32L29.8788 38.364M23.5148 32L32.7072 32M40.4854 32L36.9498 32" stroke="#0A2647" stroke-opacity="0.64" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <rect x="-0.5" y="0.5" width="63" height="63" rx="15.5" transform="matrix(-1 0 0 1 63 0)" stroke="#0A2647" stroke-opacity="0.04" /> <defs> <clipPath id="clip0_734_2381"> <rect width="24" height="24" fill="white" transform="translate(48.9707 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 width="56" height="56" rx="16" transform="matrix(-1 0 0 1 60 4)" fill="var(--datis-secondary-color)" /> <g clip-path="url(#clip0_734_2371)"> <path d="M23.5148 32L29.8787 25.636M23.5148 32L29.8788 38.364M23.5148 32L32.7072 32M40.4854 32L36.9498 32" stroke="#0A2647" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> </g> <rect x="-0.5" y="0.5" width="63" height="63" rx="15.5" transform="matrix(-1 0 0 1 63 0)" stroke="var(--datis-secondary-color)" /> <defs> <clipPath id="clip0_734_2371"> <rect width="24" height="24" fill="white" transform="translate(48.9707 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-2"> <?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>
💾 保存文件
← 返回文件管理器