forked from fukata/wp-flickr-press
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFpPager.php
32 lines (29 loc) · 793 Bytes
/
FpPager.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
<?php
class FpPager {
private $page;
private $total;
private $perPage;
private $htmlCache = '';
public function __construct($total, $page=1, $perPage=20) {
$this->total = $total;
$this->page = $page;
$this->perPage = $perPage;
}
public function generate($force=false) {
if (!$force && strlen($this->htmlCache)>0) {
return $this->htmlCache;
}
$html = paginate_links(array(
'base' => add_query_arg('paged', '%#%'),
'format' => '',
'prev_text' => __('«', FlickrPress::TEXT_DOMAIN),
'next_text' => __('»', FlickrPress::TEXT_DOMAIN),
'total' => $this->total > 0 ? ceil($this->total / $this->perPage) : 0,
'current' => $this->page
));
$html = "<div class='tablenav-pages'>{$html}</div>";
$this->htmlCache = $html;
return $html;
}
}
?>