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

pagination.php ➔ emm_paginate()   F

Complexity

Conditions 18
Paths 390

Size

Total Lines 94
Code Lines 52

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 18
eloc 52
nc 390
nop 1
dl 0
loc 94
rs 3.6714
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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