| Conditions | 4 |
| Paths | 3 |
| Total Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | function spurs_pagination( $args = [], $class = 'pagination' ) { |
||
| 14 | |||
| 15 | if ( $GLOBALS['wp_query']->max_num_pages <= 1 ) { |
||
| 16 | return; |
||
| 17 | } |
||
| 18 | |||
| 19 | $args = wp_parse_args( $args, |
||
|
|
|||
| 20 | array( |
||
| 21 | 'mid_size' => 2, |
||
| 22 | 'prev_next' => true, |
||
| 23 | 'prev_text' => __( '«', 'spurs' ), |
||
| 24 | 'next_text' => __( '»', 'spurs' ), |
||
| 25 | 'screen_reader_text' => __( 'Posts navigation', 'spurs' ), |
||
| 26 | 'type' => 'array', |
||
| 27 | 'current' => max( 1, get_query_var( 'paged' ) ), |
||
| 28 | ) |
||
| 29 | ); |
||
| 30 | |||
| 31 | $links = paginate_links( $args ); |
||
| 32 | |||
| 33 | ?> |
||
| 34 | |||
| 35 | <nav aria-label="<?php echo $args['screen_reader_text']; ?>"> |
||
| 36 | <div class="container"> |
||
| 37 | <ul class="pagination justify-content-center mt-5"> |
||
| 38 | |||
| 39 | <?php |
||
| 40 | foreach ( $links as $key => $link ) { |
||
| 41 | ?> |
||
| 42 | <li class="page-item <?php echo strpos( $link, 'current' ) ? 'active' : '' ?>"> |
||
| 43 | <?php echo str_replace( 'page-numbers', 'page-link', $link ); ?> |
||
| 44 | </li> |
||
| 45 | <?php |
||
| 46 | } |
||
| 47 | ?> |
||
| 48 | |||
| 49 | </ul> |
||
| 50 | </div> |
||
| 51 | </nav> |
||
| 52 | |||
| 53 | <?php |
||
| 54 | } |
||
| 55 | } |
||
| 56 |