Passed
Push — master ( 94b607...712e60 )
by Amit
02:36
created

pagination.php ➔ emm_paginate_loop()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 3
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
function podium_pagination()
4
{
5
    global $wp_query;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
6
7
    $next_arrow = is_rtl() ? '<i title="Next Posts" class="fas fa-chevron-left"></i>' : '<i title="Next Posts" class="fas fa-chevron-right"></i>';
8
    $prev_arrow = is_rtl() ? '<i title="Previous Posts" class="fas fa-chevron-right"></i>' : '<i title="Previous Posts"  class="fas fa-chevron-left"></i>';
9
10
    $total      = $wp_query->max_num_pages;
11
12
    $big = 999999999; // This neeFds to be an unlikely integer
13
14
    // For more options and info view the docs for paginate_links()
15
    // http://codex.wordpress.org/Function_Reference/paginate_links
16
    $paginate_links = paginate_links([
17
        'base'        => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
18
        'current'     => max(1, get_query_var('paged')),
19
        'total'       => $total,
20
        'show_all'    => false,
21
        'prev_text'   => $prev_arrow,
22
        'next_text'   => $next_arrow,
23
        'type' => 'list'
24
    ]);
25
26
    // Display the pagination if more than one page is found
27
    if ($paginate_links) {
28
        echo '<div class="pagination">';
29
        echo $paginate_links;
30
        echo '</div>';
31
    }
32
}
33