C:\xampp\htdocs\landing\wp-content\plugins\penci-framework\inc\pagination.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php

class Penci_Pagination {

    
/**
     * Displays a paginated navigation to next/previous set of posts, when applicable.
     *
     * @param $total
     */
    
public static function the_posts_pagination$total$class$add_args ) {
        
$navigation '';

        
$links self::paginate_links( array(
            
'prev_text' => '<i class="fa fa-angle-left"></i>',
            
'next_text' => '<i class="fa fa-angle-right"></i>',
            
'current'   => self::get_current_paged(),
            
'total'     => $total,
            
//'add_args' => $add_args
        
) );


        if ( 
$links ) {
            
$navigation self::_navigation_markup$links'penci-pagination' . ( $class ' ' $class '' ), '' );
        }

        echo 
$navigation;
    }

    public static function 
get_current_paged() {
        global 
$wp_query;

        
$current $wp_query->get'paged' );

        if ( empty( 
$current ) ) {

            if ( isset( 
$wp_query->query['paged'] ) ) {
                
$current $wp_query->query['paged'];
            } else {
                
$current 1;
            }
        }

        return 
$current;
    }

    public static function 
paginate_links$args '' ) {
        global 
$wp_query$wp_rewrite;

        
// Setting up default values based on the current URL.
        
$pagenum_link html_entity_decodeget_pagenum_link() );
        
$url_parts    explode'?'$pagenum_link );

        
// Get max pages and current page out of the current query, if available.
        
$total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages 1;
        
$current get_query_var'paged' ) ? intvalget_query_var'paged' ) ) : 1;

        
// Append the format placeholder to the base URL.
        
$pagenum_link trailingslashit$url_parts[0] ) . '%_%';

        
// URL base depends on permalink settings.
        
$format $wp_rewrite->using_index_permalinks() && ! strpos$pagenum_link'index.php' ) ? 'index.php/' '';
        
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit$wp_rewrite->pagination_base '/%#%''paged' ) : '?paged=%#%';

        
$defaults = array(
            
'base'               => $pagenum_link// http://example.com/all_posts.php%_% : %_% is replaced by format (below)
            
'format'             => $format// ?page=%#% : %#% is replaced by the page number
            
'total'              => $total,
            
'current'            => $current,
            
'show_all'           => false,
            
'prev_next'          => true,
            
'prev_text'          => __'&laquo; Previous' ),
            
'next_text'          => __'Next &raquo;' ),
            
'end_size'           => 1,
            
'mid_size'           => 2,
            
'type'               => 'plain',
            
'add_args'           => array(), // array of query args to add
            
'add_fragment'       => '',
            
'before_page_number' => '',
            
'after_page_number'  => ''
        
);

        
$args wp_parse_args$args$defaults );

        if ( ! 
is_array$args['add_args'] ) ) {
            
$args['add_args'] = array();
        }

        
// Merge additional query vars found in the original URL into 'add_args' array.
        
if ( isset( $url_parts[1] ) ) {
            
// Find the format argument.
            
$format       explode'?'str_replace'%_%'$args['format'], $args['base'] ) );
            
$format_query = isset( $format[1] ) ? $format[1] : '';
            
wp_parse_str$format_query$format_args );

            
// Find the query args of the requested URL.
            
wp_parse_str$url_parts[1], $url_query_args );

            
// Remove the format argument from the array of query arguments, to avoid overwriting custom format.
            
foreach ( $format_args as $format_arg => $format_arg_value ) {
                unset( 
$url_query_args$format_arg ] );
            }

            
$args['add_args'] = array_merge$args['add_args'], urlencode_deep$url_query_args ) );
        }

        
// Who knows what else people pass in $args
        
$total = (int) $args['total'];
        if ( 
$total ) {
            return;
        }
        
$current  = (int) $args['current'];
        
$end_size = (int) $args['end_size']; // Out of bounds?  Make it the default.
        
if ( $end_size ) {
            
$end_size 1;
        }
        
$mid_size = (int) $args['mid_size'];
        if ( 
$mid_size ) {
            
$mid_size 2;
        }
        
$add_args   $args['add_args'];
        
$r          '';
        
$page_links = array();
        
$dots       false;

        if ( 
$args['prev_next'] && $current && $current ) :
            
$link str_replace'%_%'== $current '' $args['format'], $args['base'] );
            
$link str_replace'%#%'$current 1$link );
            if ( 
$add_args ) {
                
$link add_query_arg$add_args$link );
            }
            
$link .= $args['add_fragment'];

            
/**
             * Filters the paginated links for the given archive pages.
             *
             * @since 3.0.0
             *
             * @param string $link The paginated link URL.
             */
            
$page_links[] = '<a class="prev page-numbers" href="' esc_urlapply_filters'paginate_links'$link ) ) . '">' $args['prev_text'] . '</a>';
        endif;
        for ( 
$n 1$n <= $total$n ++ ) :
            if ( 
$n == $current ) :
                
$page_links[] = "<span class='page-numbers current'>" $args['before_page_number'] . number_format_i18n$n ) . $args['after_page_number'] . "</span>";
                
$dots         true;
            else :
                if ( 
$args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current $mid_size && $n <= $current $mid_size ) || $n $total $end_size ) ) :
                    
$link str_replace'%_%'== $n '' $args['format'], $args['base'] );
                    
$link str_replace'%#%'$n$link );
                    if ( 
$add_args && != $n ) {
                        
$link add_query_arg$add_args$link );
                    }
                    
$link .= $args['add_fragment'];

                    
/** This filter is documented in wp-includes/general-template.php */
                    
$page_links[] = "<a class='page-numbers' href='" esc_urlapply_filters'paginate_links'$link ) ) . "'>" $args['before_page_number'] . number_format_i18n$n ) . $args['after_page_number'] . "</a>";
                    
$dots         true;
                elseif ( 
$dots && ! $args['show_all'] ) :
                    
$page_links[] = '<span class="page-numbers dots">' __'&hellip;' ) . '</span>';
                    
$dots         false;
                endif;
            endif;
        endfor;
        if ( 
$args['prev_next'] && $current && $current $total ) :
            
$link str_replace'%_%'$args['format'], $args['base'] );
            
$link str_replace'%#%'$current 1$link );
            if ( 
$add_args ) {
                
$link add_query_arg$add_args$link );
            }
            
$link .= $args['add_fragment'];

            
/** This filter is documented in wp-includes/general-template.php */
            
$page_links[] = '<a class="next page-numbers" href="' esc_urlapply_filters'paginate_links'$link ) ) . '">' $args['next_text'] . '</a>';
        endif;
        switch ( 
$args['type'] ) {
            case 
'array' :
                return 
$page_links;

            case 
'list' :
                
$r .= "<ul class='page-numbers'>\n\t<li>";
                
$r .= join"</li>\n\t<li>"$page_links );
                
$r .= "</li>\n</ul>\n";
                break;

            default :
                
$r join"\n"$page_links );
                break;
        }

        return 
$r;
    }

    
/**
     * Wraps passed links in navigational markup.
     *
     */
    
public static function _navigation_markup$links$class 'posts-navigation'$screen_reader_text '' ) {
        if ( empty( 
$screen_reader_text ) ) {
            
$screen_reader_text __'Posts navigation' );
        }

        
$template '
        <nav class="navigation %1$s" role="navigation">
            <div class="nav-links">%3$s</div>
        </nav>'
;

        
$template apply_filters'navigation_markup_template'$template$class );

        return 
sprintf$template$classesc_html$screen_reader_text ), $links );
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586