Version Description
- Tested with WordPress 4.7
Download this release
Release Info
Developer | AlanP57 |
Plugin | WP-Paginate |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- readme.txt +59 -53
- wp-paginate.php +368 -367
readme.txt
CHANGED
@@ -1,19 +1,17 @@
|
|
1 |
=== WP-Paginate ===
|
2 |
-
Contributors:
|
3 |
Tags: paginate, pagination, navigation, page, wp-paginate, comments, rtl, seo, usability
|
4 |
Requires at least: 2.6.0 (2.7.0 for comments pagination)
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.3.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
-
|
10 |
WP-Paginate is a simple and flexible pagination plugin which provides users with better navigation on your WordPress site.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
= Latest News =
|
15 |
-
> I am happy to announce that, effective December 15, 2014, Noah Cinquini and the team at Studio Fuel (studiofuel.com) have offered to take over maintenance, support, and development of WP-Paginate! A huge thanks to Noah and all of the people that have used WP-Paginate over the last 5 years!
|
16 |
-
|
17 |
WP-Paginate is a simple and flexible pagination plugin which provides users with better navigation on your WordPress site.
|
18 |
|
19 |
In addition to increasing the user experience for your visitors, it has also been widely reported that pagination increases the SEO of your site by providing more links to your content.
|
@@ -21,7 +19,7 @@ In addition to increasing the user experience for your visitors, it has also bee
|
|
21 |
Starting in version 1.1, WP-Paginate can also be used to paginate post comments!
|
22 |
|
23 |
Translations: http://plugins.svn.wordpress.org/wp-paginate/I18n (check the version number for the correct file)
|
24 |
-
|
25 |
== Installation ==
|
26 |
|
27 |
*Install and Activate*
|
@@ -37,55 +35,74 @@ For posts pagination:
|
|
37 |
|
38 |
Examples:
|
39 |
|
40 |
-
For the `
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
|
44 |
With:
|
45 |
|
46 |
-
|
47 |
-
wp_paginate();
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
|
54 |
-
For the `
|
55 |
|
56 |
-
|
|
|
|
|
|
|
|
|
57 |
|
58 |
With:
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
67 |
|
68 |
-
For the `
|
69 |
|
70 |
-
|
|
|
|
|
|
|
|
|
71 |
|
72 |
With:
|
73 |
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
80 |
|
81 |
For comments pagination:
|
82 |
1) Open the theme file(s) where you'd like comments pagination to be used. Usually this is the `comments.php` file.
|
83 |
|
84 |
2) Replace your existing `previous_comments_link()` and `next_comments_link()` code block with the following:
|
85 |
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
|
90 |
|
91 |
*Configure*
|
@@ -130,28 +147,17 @@ You can even control the current page and number of pages with:
|
|
130 |
|
131 |
Example (also applies to `wp_paginate_comments()`):
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
|
137 |
|
138 |
= How can I style the comments pagination differently than the posts pagination? =
|
139 |
|
140 |
-
When calling `wp_paginate_comments()`, WP-Paginate adds an extra class to the `ol` element, `wp-paginate-comments
|
141 |
-
|
142 |
-
This allows you to use the `.wp-paginate-comments` styles, already in `wp-paginate.css`, to override the default styles.
|
143 |
-
|
144 |
-
== Screenshots ==
|
145 |
-
|
146 |
-
1. An example of the WP-Paginate display using the default options and styling
|
147 |
-
2. The WP-Paginate admin settings page
|
148 |
-
|
149 |
-
|
150 |
-
== Upgrade Notice ==
|
151 |
-
|
152 |
-
N/A
|
153 |
|
154 |
-
|
|
|
155 |
|
156 |
= 1.3.1 =
|
157 |
* Fixed bug that prevented a wp-paginate.css stylesheet from loading from a child theme (reported by sunamumaya)
|
1 |
=== WP-Paginate ===
|
2 |
+
Contributors: maxfoundry, emartin24, AlanP57
|
3 |
Tags: paginate, pagination, navigation, page, wp-paginate, comments, rtl, seo, usability
|
4 |
Requires at least: 2.6.0 (2.7.0 for comments pagination)
|
5 |
+
Tested up to: 4.7
|
6 |
+
Stable tag: 1.3.2
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
+
|
10 |
WP-Paginate is a simple and flexible pagination plugin which provides users with better navigation on your WordPress site.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
= Latest News =
|
|
|
|
|
15 |
WP-Paginate is a simple and flexible pagination plugin which provides users with better navigation on your WordPress site.
|
16 |
|
17 |
In addition to increasing the user experience for your visitors, it has also been widely reported that pagination increases the SEO of your site by providing more links to your content.
|
19 |
Starting in version 1.1, WP-Paginate can also be used to paginate post comments!
|
20 |
|
21 |
Translations: http://plugins.svn.wordpress.org/wp-paginate/I18n (check the version number for the correct file)
|
22 |
+
|
23 |
== Installation ==
|
24 |
|
25 |
*Install and Activate*
|
35 |
|
36 |
Examples:
|
37 |
|
38 |
+
For the `Twenty Seventeen` theme, in `index.php`, replace:
|
39 |
|
40 |
+
the_posts_pagination( array(
|
41 |
+
'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
|
42 |
+
'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
|
43 |
+
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',
|
44 |
+
) );
|
45 |
|
46 |
With:
|
47 |
|
48 |
+
if(function_exists('wp_paginate')):
|
49 |
+
wp_paginate();
|
50 |
+
else :
|
51 |
+
the_posts_pagination( array(
|
52 |
+
'prev_text' => twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '<span class="screen-reader-text">' . __( 'Previous page', 'twentyseventeen' ) . '</span>',
|
53 |
+
'next_text' => '<span class="screen-reader-text">' . __( 'Next page', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ),
|
54 |
+
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyseventeen' ) . ' </span>',
|
55 |
+
) );
|
56 |
+
endif;
|
57 |
|
58 |
+
For the `Twenty Sixteen` theme, in `index.php`, replace:
|
59 |
|
60 |
+
the_posts_pagination( array(
|
61 |
+
'prev_text' => __( 'Previous page', 'twentysixteen' ),
|
62 |
+
'next_text' => __( 'Next page', 'twentysixteen' ),
|
63 |
+
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
|
64 |
+
) );
|
65 |
|
66 |
With:
|
67 |
|
68 |
+
if(function_exists('wp_paginate')):
|
69 |
+
wp_paginate();
|
70 |
+
else :
|
71 |
+
the_posts_pagination( array(
|
72 |
+
'prev_text' => __( 'Previous page', 'twentysixteen' ),
|
73 |
+
'next_text' => __( 'Next page', 'twentysixteen' ),
|
74 |
+
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
|
75 |
+
) );
|
76 |
+
endif;
|
77 |
|
78 |
+
For the `Twenty Fifteen` theme, in `index.php`, replace:
|
79 |
|
80 |
+
the_posts_pagination( array(
|
81 |
+
'prev_text' => __( 'Previous page', 'twentyfifteen' ),
|
82 |
+
'next_text' => __( 'Next page', 'twentyfifteen' ),
|
83 |
+
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',
|
84 |
+
) );
|
85 |
|
86 |
With:
|
87 |
|
88 |
+
if(function_exists('wp_paginate')):
|
89 |
+
wp_paginate();
|
90 |
+
else :
|
91 |
+
the_posts_pagination( array(
|
92 |
+
'prev_text' => __( 'Previous page', 'twentyfifteen' ),
|
93 |
+
'next_text' => __( 'Next page', 'twentyfifteen' ),
|
94 |
+
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',
|
95 |
+
) );
|
96 |
+
endif;
|
97 |
|
98 |
For comments pagination:
|
99 |
1) Open the theme file(s) where you'd like comments pagination to be used. Usually this is the `comments.php` file.
|
100 |
|
101 |
2) Replace your existing `previous_comments_link()` and `next_comments_link()` code block with the following:
|
102 |
|
103 |
+
<?php if(function_exists('wp_paginate_comments')) {
|
104 |
+
wp_paginate_comments();
|
105 |
+
} ?>
|
106 |
|
107 |
|
108 |
*Configure*
|
147 |
|
148 |
Example (also applies to `wp_paginate_comments()`):
|
149 |
|
150 |
+
<?php if(function_exists('wp_paginate')) {
|
151 |
+
wp_paginate('range=4&anchor=2&nextpage=Next&previouspage=Previous');
|
152 |
+
} ?>
|
153 |
|
154 |
|
155 |
= How can I style the comments pagination differently than the posts pagination? =
|
156 |
|
157 |
+
When calling `wp_paginate_comments()`, WP-Paginate adds an extra class to the `ol` element, `wp-paginate-comments`.== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
|
159 |
+
= 1.3.2 =
|
160 |
+
* Tested with WordPress 4.7
|
161 |
|
162 |
= 1.3.1 =
|
163 |
* Fixed bug that prevented a wp-paginate.css stylesheet from loading from a child theme (reported by sunamumaya)
|
wp-paginate.php
CHANGED
@@ -1,299 +1,300 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP-Paginate
|
4 |
-
Plugin URI:
|
5 |
Description: A simple and flexible pagination plugin for WordPress posts and comments.
|
6 |
-
Version: 1.3.
|
7 |
-
Author:
|
8 |
-
Author URI: http://
|
9 |
*/
|
10 |
|
11 |
-
/* Copyright
|
12 |
|
13 |
-
Plugin originally created by Eric Martin (http://www.ericmmartin.com)
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
*/
|
29 |
|
30 |
/**
|
31 |
* Set the wp-content and plugin urls/paths
|
32 |
*/
|
33 |
if (!defined('WP_CONTENT_URL'))
|
34 |
-
|
35 |
if (!defined('WP_CONTENT_DIR'))
|
36 |
-
|
37 |
if (!defined('WP_PLUGIN_URL') )
|
38 |
-
|
39 |
if (!defined('WP_PLUGIN_DIR') )
|
40 |
-
|
41 |
|
42 |
if (!class_exists('WPPaginate')) {
|
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 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
?>
|
298 |
|
299 |
<div class="wrap">
|
@@ -301,128 +302,128 @@ if (!class_exists('WPPaginate')) {
|
|
301 |
<h2>WP-Paginate</h2>
|
302 |
<form method="post" id="wp_paginate_options">
|
303 |
<?php wp_nonce_field('wp-paginate-update-options'); ?>
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
</form>
|
379 |
<h2><?php _e('Need Support?', $this->localizationDomain); ?></h2>
|
380 |
<p><?php printf(__('For questions, issues or feature requests, please post them in the %s and make sure to tag the post with wp-paginate.', $this->localizationDomain), '<a href="https://wordpress.org/support/plugin/wp-paginate">WordPress Forum</a>'); ?></p>
|
381 |
<h2><?php _e('Want To Contribute?', $this->localizationDomain); ?></h2>
|
382 |
<p><?php _e('If you would like to contribute, the following is a list of ways you can help:', $this->localizationDomain); ?></p>
|
383 |
<ul>
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
</ul>
|
389 |
-
<h2><?php _e('
|
390 |
<ul>
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
</ul>
|
395 |
</div>
|
396 |
|
397 |
<?php
|
398 |
-
|
399 |
-
|
400 |
}
|
401 |
|
402 |
//instantiate the class
|
403 |
if (class_exists('WPPaginate')) {
|
404 |
-
|
405 |
}
|
406 |
|
407 |
/**
|
408 |
* Pagination function to use for posts
|
409 |
*/
|
410 |
function wp_paginate($args = false) {
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
}
|
415 |
|
416 |
/**
|
417 |
* Pagination function to use for post comments
|
418 |
*/
|
419 |
function wp_paginate_comments($args = false) {
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
}
|
424 |
|
425 |
/*
|
426 |
* The format of this plugin is based on the following plugin template:
|
427 |
* http://pressography.com/plugins/wordpress-plugin-template/
|
428 |
-
*/
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: WP-Paginate
|
4 |
+
Plugin URI: https://wordpress.org/plugins/wp-paginate/
|
5 |
Description: A simple and flexible pagination plugin for WordPress posts and comments.
|
6 |
+
Version: 1.3.2
|
7 |
+
Author: Max Foundry
|
8 |
+
Author URI: http://maxfoundry.com
|
9 |
*/
|
10 |
|
11 |
+
/* Copyright 2016 Max Foundry (http://www.maxfoundry.com)
|
12 |
|
13 |
+
Plugin originally created by Eric Martin (http://www.ericmmartin.com) and
|
14 |
+
and improved upon by Studio Fuels.
|
15 |
|
16 |
+
This program is free software; you can redistribute it and/or modify
|
17 |
+
it under the terms of the GNU General Public License as published by
|
18 |
+
the Free Software Foundation; either version 2 of the License, or
|
19 |
+
(at your option) any later version.
|
20 |
|
21 |
+
This program is distributed in the hope that it will be useful,
|
22 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
23 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
+
GNU General Public License for more details.
|
25 |
|
26 |
+
You should have received a copy of the GNU General Public License
|
27 |
+
along with this program; if not, write to the Free Software
|
28 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
29 |
*/
|
30 |
|
31 |
/**
|
32 |
* Set the wp-content and plugin urls/paths
|
33 |
*/
|
34 |
if (!defined('WP_CONTENT_URL'))
|
35 |
+
define('WP_CONTENT_URL', get_option('siteurl') . '/wp-content');
|
36 |
if (!defined('WP_CONTENT_DIR'))
|
37 |
+
define('WP_CONTENT_DIR', ABSPATH . 'wp-content');
|
38 |
if (!defined('WP_PLUGIN_URL') )
|
39 |
+
define('WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins');
|
40 |
if (!defined('WP_PLUGIN_DIR') )
|
41 |
+
define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins');
|
42 |
|
43 |
if (!class_exists('WPPaginate')) {
|
44 |
+
class WPPaginate {
|
45 |
+
/**
|
46 |
+
* @var string The plugin version
|
47 |
+
*/
|
48 |
+
var $version = '1.3.1';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @var string The options string name for this plugin
|
52 |
+
*/
|
53 |
+
var $optionsName = 'wp_paginate_options';
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @var string $localizationDomain Domain used for localization
|
57 |
+
*/
|
58 |
+
var $localizationDomain = 'wp-paginate';
|
59 |
+
|
60 |
+
/**
|
61 |
+
* @var string $pluginurl The url to this plugin
|
62 |
+
*/
|
63 |
+
var $pluginurl = '';
|
64 |
+
/**
|
65 |
+
* @var string $pluginpath The path to this plugin
|
66 |
+
*/
|
67 |
+
var $pluginpath = '';
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @var array $options Stores the options for this plugin
|
71 |
+
*/
|
72 |
+
var $options = array();
|
73 |
+
|
74 |
+
var $type = 'posts';
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Constructor
|
78 |
+
*/
|
79 |
+
function __construct() {
|
80 |
+
$name = dirname(plugin_basename(__FILE__));
|
81 |
+
|
82 |
+
//Language Setup
|
83 |
+
load_plugin_textdomain($this->localizationDomain, false, "$name/I18n/");
|
84 |
+
|
85 |
+
//"Constants" setup
|
86 |
+
$this->pluginurl = plugins_url($name) . "/";
|
87 |
+
$this->pluginpath = WP_PLUGIN_DIR . "/$name/";
|
88 |
+
|
89 |
+
//Initialize the options
|
90 |
+
$this->get_options();
|
91 |
+
|
92 |
+
//Actions
|
93 |
+
add_action('admin_menu', array(&$this, 'admin_menu_link'));
|
94 |
+
|
95 |
+
if ($this->options['css'])
|
96 |
+
add_action('wp_print_styles', array(&$this, 'wp_paginate_css'));
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Pagination based on options/args
|
101 |
+
*/
|
102 |
+
function paginate($args = false) {
|
103 |
+
if ($this->type === 'comments' && !get_option('page_comments'))
|
104 |
+
return;
|
105 |
+
|
106 |
+
$r = wp_parse_args($args, $this->options);
|
107 |
+
extract($r, EXTR_SKIP);
|
108 |
+
|
109 |
+
if (!isset($page) && !isset($pages)) {
|
110 |
+
global $wp_query;
|
111 |
+
|
112 |
+
if ($this->type === 'posts') {
|
113 |
+
$page = get_query_var('paged');
|
114 |
+
$posts_per_page = intval(get_query_var('posts_per_page'));
|
115 |
+
$pages = intval(ceil($wp_query->found_posts / $posts_per_page));
|
116 |
+
}
|
117 |
+
else {
|
118 |
+
$page = get_query_var('cpage');
|
119 |
+
$comments_per_page = get_option('comments_per_page');
|
120 |
+
$pages = get_comment_pages_count();
|
121 |
+
}
|
122 |
+
$page = !empty($page) ? intval($page) : 1;
|
123 |
+
}
|
124 |
+
|
125 |
+
$prevlink = ($this->type === 'posts')
|
126 |
+
? esc_url(get_pagenum_link($page - 1))
|
127 |
+
: get_comments_pagenum_link($page - 1);
|
128 |
+
$nextlink = ($this->type === 'posts')
|
129 |
+
? esc_url(get_pagenum_link($page + 1))
|
130 |
+
: get_comments_pagenum_link($page + 1);
|
131 |
+
|
132 |
+
$output = stripslashes($before);
|
133 |
+
if ($pages > 1) {
|
134 |
+
$output .= sprintf('<ol class="wp-paginate%s">', ($this->type === 'posts') ? '' : ' wp-paginate-comments');
|
135 |
+
if (strlen(stripslashes($title)) > 0) {
|
136 |
+
$output .= sprintf('<li><span class="title">%s</span></li>', stripslashes($title));
|
137 |
+
}
|
138 |
+
$ellipsis = "<li><span class='gap'>...</span></li>";
|
139 |
+
|
140 |
+
if ($page > 1 && !empty($previouspage)) {
|
141 |
+
$output .= sprintf('<li><a href="%s" class="prev">%s</a></li>', $prevlink, stripslashes($previouspage));
|
142 |
+
}
|
143 |
+
|
144 |
+
$min_links = $range * 2 + 1;
|
145 |
+
$block_min = min($page - $range, $pages - $min_links);
|
146 |
+
$block_high = max($page + $range, $min_links);
|
147 |
+
$left_gap = (($block_min - $anchor - $gap) > 0) ? true : false;
|
148 |
+
$right_gap = (($block_high + $anchor + $gap) < $pages) ? true : false;
|
149 |
+
|
150 |
+
if ($left_gap && !$right_gap) {
|
151 |
+
$output .= sprintf('%s%s%s',
|
152 |
+
$this->paginate_loop(1, $anchor),
|
153 |
+
$ellipsis,
|
154 |
+
$this->paginate_loop($block_min, $pages, $page)
|
155 |
+
);
|
156 |
+
}
|
157 |
+
else if ($left_gap && $right_gap) {
|
158 |
+
$output .= sprintf('%s%s%s%s%s',
|
159 |
+
$this->paginate_loop(1, $anchor),
|
160 |
+
$ellipsis,
|
161 |
+
$this->paginate_loop($block_min, $block_high, $page),
|
162 |
+
$ellipsis,
|
163 |
+
$this->paginate_loop(($pages - $anchor + 1), $pages)
|
164 |
+
);
|
165 |
+
}
|
166 |
+
else if ($right_gap && !$left_gap) {
|
167 |
+
$output .= sprintf('%s%s%s',
|
168 |
+
$this->paginate_loop(1, $block_high, $page),
|
169 |
+
$ellipsis,
|
170 |
+
$this->paginate_loop(($pages - $anchor + 1), $pages)
|
171 |
+
);
|
172 |
+
}
|
173 |
+
else {
|
174 |
+
$output .= $this->paginate_loop(1, $pages, $page);
|
175 |
+
}
|
176 |
+
|
177 |
+
if ($page < $pages && !empty($nextpage)) {
|
178 |
+
$output .= sprintf('<li><a href="%s" class="next">%s</a></li>', $nextlink, stripslashes($nextpage));
|
179 |
+
}
|
180 |
+
$output .= "</ol>";
|
181 |
+
}
|
182 |
+
$output .= stripslashes($after);
|
183 |
+
|
184 |
+
if ($pages > 1 || $empty) {
|
185 |
+
echo $output;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Helper function for pagination which builds the page links.
|
191 |
+
*/
|
192 |
+
function paginate_loop($start, $max, $page = 0) {
|
193 |
+
$output = "";
|
194 |
+
for ($i = $start; $i <= $max; $i++) {
|
195 |
+
$p = ($this->type === 'posts') ? esc_url(get_pagenum_link($i)) : get_comments_pagenum_link($i);
|
196 |
+
$output .= ($page == intval($i))
|
197 |
+
? "<li><span class='page current'>$i</span></li>"
|
198 |
+
: "<li><a href='$p' title='$i' class='page'>$i</a></li>";
|
199 |
+
}
|
200 |
+
return $output;
|
201 |
+
}
|
202 |
+
|
203 |
+
function wp_paginate_css() {
|
204 |
+
$name = "wp-paginate.css";
|
205 |
+
|
206 |
+
if (false !== @file_exists(STYLESHEETPATH . "/$name")) {
|
207 |
+
$css = get_stylesheet_directory_uri() . "/$name";
|
208 |
+
}
|
209 |
+
else {
|
210 |
+
$css = $this->pluginurl . $name;
|
211 |
+
}
|
212 |
+
wp_enqueue_style('wp-paginate', $css, false, $this->version, 'screen');
|
213 |
+
|
214 |
+
if (function_exists('is_rtl') && is_rtl()) {
|
215 |
+
$name = "wp-paginate-rtl.css";
|
216 |
+
if (false !== @file_exists(STYLESHEETPATH . "/$name")) {
|
217 |
+
$css = get_stylesheet_directory_uri() . "/$name";
|
218 |
+
}
|
219 |
+
else {
|
220 |
+
$css = $this->pluginurl . $name;
|
221 |
+
}
|
222 |
+
wp_enqueue_style('wp-paginate-rtl', $css, false, $this->version, 'screen');
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
/**
|
227 |
+
* Retrieves the plugin options from the database.
|
228 |
+
* @return array
|
229 |
+
*/
|
230 |
+
function get_options() {
|
231 |
+
if (!$options = get_option($this->optionsName)) {
|
232 |
+
$options = array(
|
233 |
+
'title' => 'Pages:',
|
234 |
+
'nextpage' => '»',
|
235 |
+
'previouspage' => '«',
|
236 |
+
'css' => true,
|
237 |
+
'before' => '<div class="navigation">',
|
238 |
+
'after' => '</div>',
|
239 |
+
'empty' => true,
|
240 |
+
'range' => 3,
|
241 |
+
'anchor' => 1,
|
242 |
+
'gap' => 3
|
243 |
+
);
|
244 |
+
update_option($this->optionsName, $options);
|
245 |
+
}
|
246 |
+
$this->options = $options;
|
247 |
+
}
|
248 |
+
/**
|
249 |
+
* Saves the admin options to the database.
|
250 |
+
*/
|
251 |
+
function save_admin_options(){
|
252 |
+
return update_option($this->optionsName, $this->options);
|
253 |
+
}
|
254 |
+
|
255 |
+
/**
|
256 |
+
* @desc Adds the options subpanel
|
257 |
+
*/
|
258 |
+
function admin_menu_link() {
|
259 |
+
add_options_page('WP-Paginate', 'WP-Paginate', 'manage_options', basename(__FILE__), array(&$this, 'admin_options_page'));
|
260 |
+
add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'filter_plugin_actions'), 10, 2 );
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* @desc Adds the Settings link to the plugin activate/deactivate page
|
265 |
+
*/
|
266 |
+
function filter_plugin_actions($links, $file) {
|
267 |
+
$settings_link = '<a href="options-general.php?page=' . basename(__FILE__) . '">' . __('Settings', $this->localizationDomain) . '</a>';
|
268 |
+
array_unshift($links, $settings_link); // before other links
|
269 |
+
|
270 |
+
return $links;
|
271 |
+
}
|
272 |
+
|
273 |
+
/**
|
274 |
+
* Adds settings/options page
|
275 |
+
*/
|
276 |
+
function admin_options_page() {
|
277 |
+
if (isset($_POST['wp_paginate_save'])) {
|
278 |
+
if (wp_verify_nonce($_POST['_wpnonce'], 'wp-paginate-update-options')) {
|
279 |
+
$this->options['title'] = $_POST['title'];
|
280 |
+
$this->options['previouspage'] = $_POST['previouspage'];
|
281 |
+
$this->options['nextpage'] = $_POST['nextpage'];
|
282 |
+
$this->options['before'] = $_POST['before'];
|
283 |
+
$this->options['after'] = $_POST['after'];
|
284 |
+
$this->options['empty'] = (isset($_POST['empty']) && $_POST['empty'] === 'on') ? true : false;
|
285 |
+
$this->options['css'] = (isset($_POST['css']) && $_POST['css'] === 'on') ? true : false;
|
286 |
+
$this->options['range'] = intval($_POST['range']);
|
287 |
+
$this->options['anchor'] = intval($_POST['anchor']);
|
288 |
+
$this->options['gap'] = intval($_POST['gap']);
|
289 |
+
|
290 |
+
$this->save_admin_options();
|
291 |
+
|
292 |
+
echo '<div class="updated"><p>' . __('Success! Your changes were successfully saved!', $this->localizationDomain) . '</p></div>';
|
293 |
+
}
|
294 |
+
else {
|
295 |
+
echo '<div class="error"><p>' . __('Whoops! There was a problem with the data you posted. Please try again.', $this->localizationDomain) . '</p></div>';
|
296 |
+
}
|
297 |
+
}
|
298 |
?>
|
299 |
|
300 |
<div class="wrap">
|
302 |
<h2>WP-Paginate</h2>
|
303 |
<form method="post" id="wp_paginate_options">
|
304 |
<?php wp_nonce_field('wp-paginate-update-options'); ?>
|
305 |
+
<table class="form-table">
|
306 |
+
<tr valign="top">
|
307 |
+
<th scope="row"><?php _e('Pagination Label:', $this->localizationDomain); ?></th>
|
308 |
+
<td><input name="title" type="text" id="title" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['title'])); ?>"/>
|
309 |
+
<span class="description"><?php _e('The text/HTML to display before the list of pages.', $this->localizationDomain); ?></span></td>
|
310 |
+
</tr>
|
311 |
+
<tr valign="top">
|
312 |
+
<th scope="row"><?php _e('Previous Page:', $this->localizationDomain); ?></th>
|
313 |
+
<td><input name="previouspage" type="text" id="previouspage" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['previouspage'])); ?>"/>
|
314 |
+
<span class="description"><?php _e('The text/HTML to display for the previous page link.', $this->localizationDomain); ?></span></td>
|
315 |
+
</tr>
|
316 |
+
<tr valign="top">
|
317 |
+
<th scope="row"><?php _e('Next Page:', $this->localizationDomain); ?></th>
|
318 |
+
<td><input name="nextpage" type="text" id="nextpage" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['nextpage'])); ?>"/>
|
319 |
+
<span class="description"><?php _e('The text/HTML to display for the next page link.', $this->localizationDomain); ?></span></td>
|
320 |
+
</tr>
|
321 |
+
</table>
|
322 |
+
<p> </p>
|
323 |
+
<h3><?php _e('Advanced Settings', $this->localizationDomain); ?></h3>
|
324 |
+
<table class="form-table">
|
325 |
+
<tr valign="top">
|
326 |
+
<th scope="row"><?php _e('Before Markup:', $this->localizationDomain); ?></th>
|
327 |
+
<td><input name="before" type="text" id="before" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['before'])); ?>"/>
|
328 |
+
<span class="description"><?php _e('The HTML markup to display before the pagination code.', $this->localizationDomain); ?></span></td>
|
329 |
+
</tr>
|
330 |
+
<tr valign="top">
|
331 |
+
<th scope="row"><?php _e('After Markup:', $this->localizationDomain); ?></th>
|
332 |
+
<td><input name="after" type="text" id="after" size="40" value="<?php echo stripslashes(htmlspecialchars($this->options['after'])); ?>"/>
|
333 |
+
<span class="description"><?php _e('The HTML markup to display after the pagination code.', $this->localizationDomain); ?></span></td>
|
334 |
+
</tr>
|
335 |
+
<tr valign="top">
|
336 |
+
<th scope="row"><?php _e('Markup Display:', $this->localizationDomain); ?></th>
|
337 |
+
<td><label for="empty">
|
338 |
+
<input type="checkbox" id="empty" name="empty" <?php echo ($this->options['empty'] === true) ? "checked='checked'" : ""; ?>/> <?php _e('Show Before Markup and After Markup, even if the page list is empty?', $this->localizationDomain); ?></label></td>
|
339 |
+
</tr>
|
340 |
+
<tr valign="top">
|
341 |
+
<th scope="row"><?php _e('WP-Paginate CSS File:', $this->localizationDomain); ?></th>
|
342 |
+
<td><label for="css">
|
343 |
+
<input type="checkbox" id="css" name="css" <?php echo ($this->options['css'] === true) ? "checked='checked'" : ""; ?>/> <?php printf(__('Include the default stylesheet wp-paginate.css? WP-Paginate will first look for <code>wp-paginate.css</code> in your theme directory (<code>themes/%s</code>).', $this->localizationDomain), get_template()); ?></label></td>
|
344 |
+
</tr>
|
345 |
+
<tr valign="top">
|
346 |
+
<th scope="row"><?php _e('Page Range:', $this->localizationDomain); ?></th>
|
347 |
+
<td>
|
348 |
+
<select name="range" id="range">
|
349 |
+
<?php for ($i=1; $i<=10; $i++) : ?>
|
350 |
+
<option value="<?php echo $i; ?>" <?php echo ($i == $this->options['range']) ? "selected='selected'" : ""; ?>><?php echo $i; ?></option>
|
351 |
+
<?php endfor; ?>
|
352 |
+
</select>
|
353 |
+
<span class="description"><?php _e('The number of page links to show before and after the current page. Recommended value: 3', $this->localizationDomain); ?></span></td>
|
354 |
+
</tr>
|
355 |
+
<tr valign="top">
|
356 |
+
<th scope="row"><?php _e('Page Anchors:', $this->localizationDomain); ?></th>
|
357 |
+
<td>
|
358 |
+
<select name="anchor" id="anchor">
|
359 |
+
<?php for ($i=0; $i<=10; $i++) : ?>
|
360 |
+
<option value="<?php echo $i; ?>" <?php echo ($i == $this->options['anchor']) ? "selected='selected'" : ""; ?>><?php echo $i; ?></option>
|
361 |
+
<?php endfor; ?>
|
362 |
+
</select>
|
363 |
+
<span class="description"><?php _e('The number of links to always show at beginning and end of pagination. Recommended value: 1', $this->localizationDomain); ?></span></td>
|
364 |
+
</tr>
|
365 |
+
<tr valign="top">
|
366 |
+
<th scope="row"><?php _e('Page Gap:', $this->localizationDomain); ?></th>
|
367 |
+
<td>
|
368 |
+
<select name="gap" id="gap">
|
369 |
+
<?php for ($i=1; $i<=10; $i++) : ?>
|
370 |
+
<option value="<?php echo $i; ?>" <?php echo ($i == $this->options['gap']) ? "selected='selected'" : ""; ?>><?php echo $i; ?></option>
|
371 |
+
<?php endfor; ?>
|
372 |
+
</select>
|
373 |
+
<span class="description"><?php _e('The minimum number of pages in a gap before an ellipsis (...) is added. Recommended value: 3', $this->localizationDomain); ?></span></td>
|
374 |
+
</tr>
|
375 |
+
</table>
|
376 |
+
<p class="submit">
|
377 |
+
<input type="submit" value="Save Changes" name="wp_paginate_save" class="button-primary" />
|
378 |
+
</p>
|
379 |
</form>
|
380 |
<h2><?php _e('Need Support?', $this->localizationDomain); ?></h2>
|
381 |
<p><?php printf(__('For questions, issues or feature requests, please post them in the %s and make sure to tag the post with wp-paginate.', $this->localizationDomain), '<a href="https://wordpress.org/support/plugin/wp-paginate">WordPress Forum</a>'); ?></p>
|
382 |
<h2><?php _e('Want To Contribute?', $this->localizationDomain); ?></h2>
|
383 |
<p><?php _e('If you would like to contribute, the following is a list of ways you can help:', $this->localizationDomain); ?></p>
|
384 |
<ul>
|
385 |
+
<li>» <?php _e('Translate WP-Paginate into your language', $this->localizationDomain); ?></li>
|
386 |
+
<li>» <?php _e('Blog about or link to WP-Paginate so others can find out about it', $this->localizationDomain); ?></li>
|
387 |
+
<li>» <?php _e('Report issues, provide feedback, request features, etc.', $this->localizationDomain); ?></li>
|
388 |
+
<li>» <a href="https://wordpress.org/support/view/plugin-reviews/wp-paginate"><?php _e('Review WP-Paginate on the WordPress Plugins Page', $this->localizationDomain); ?></a></li>
|
389 |
</ul>
|
390 |
+
<h2><?php _e('Max Foundry WordPress Plugins', $this->localizationDomain); ?></h2>
|
391 |
<ul>
|
392 |
+
<li>» <a href="https://maxbuttons.com">MaxButtons WordPress Button Plugin</a></li>
|
393 |
+
<li>» <a href="https://maxgalleria.com">MaxGalleria WordPress Gallery Plugin</a></li>
|
394 |
+
<li>» <a href="https://maxgalleria.com/media-library-plus/">Media Library Plus</a>
|
395 |
</ul>
|
396 |
</div>
|
397 |
|
398 |
<?php
|
399 |
+
}
|
400 |
+
}
|
401 |
}
|
402 |
|
403 |
//instantiate the class
|
404 |
if (class_exists('WPPaginate')) {
|
405 |
+
$wp_paginate = new WPPaginate();
|
406 |
}
|
407 |
|
408 |
/**
|
409 |
* Pagination function to use for posts
|
410 |
*/
|
411 |
function wp_paginate($args = false) {
|
412 |
+
global $wp_paginate;
|
413 |
+
$wp_paginate->type = 'posts';
|
414 |
+
return $wp_paginate->paginate($args);
|
415 |
}
|
416 |
|
417 |
/**
|
418 |
* Pagination function to use for post comments
|
419 |
*/
|
420 |
function wp_paginate_comments($args = false) {
|
421 |
+
global $wp_paginate;
|
422 |
+
$wp_paginate->type = 'comments';
|
423 |
+
return $wp_paginate->paginate($args);
|
424 |
}
|
425 |
|
426 |
/*
|
427 |
* The format of this plugin is based on the following plugin template:
|
428 |
* http://pressography.com/plugins/wordpress-plugin-template/
|
429 |
+
*/
|