public function pagination($header = false)
{
if (false !== $this->callback('pagination', $header)) {
return null;
}
$total_pages = ceil($this->total_found / $this->limit);
$request_uri = pods_query_arg(array('pg' . $this->num => ''), array('limit' . $this->num, 'orderby' . $this->num, 'orderby_dir' . $this->num, 'search' . $this->num, 'filter_*', 'view' . $this->num, 'page' . $this->num), $this->exclusion());
$append = false;
if (false !== strpos($request_uri, '?')) {
$append = true;
}
if (false !== $this->pagination_total && ($header || 1 != $this->total_found)) {
$singular_label = strtolower($this->item);
$plural_label = strtolower($this->items);
?>
<span class="displaying-num"><?php
echo number_format_i18n($this->total_found) . ' ' . _n($singular_label, $plural_label, $this->total_found, 'pods') . $this->extra['total'];
?>
</span>
<?php
}
if (false !== $this->pagination) {
if (1 < $total_pages) {
?>
<a class="first-page<?php
echo esc_attr(1 < $this->page ? '' : ' disabled');
?>
" title="<?php
esc_attr_e('Go to the first page', 'pods');
?>
" href="<?php
echo esc_url($request_uri . ($append ? '&' : '?') . 'pg' . $this->num . '=1');
?>
">«</a>
<a class="prev-page<?php
echo esc_attr(1 < $this->page ? '' : ' disabled');
?>
" title="<?php
esc_attr_e('Go to the previous page', 'pods');
?>
" href="<?php
echo esc_url($request_uri . ($append ? '&' : '?') . 'pg' . $this->num . '=' . max($this->page - 1, 1));
?>
">‹</a>
<?php
if (true == $header) {
?>
<span class="paging-input"><input class="current-page" title="<?php
esc_attr_e('Current page', 'pods');
?>
" type="text" name="pg<?php
echo esc_attr($this->num);
?>
" value="<?php
echo esc_attr($this->page);
?>
" size="<?php
echo esc_attr(strlen($total_pages));
?>
"> <?php
_e('of', 'pods');
?>
<span class="total-pages"><?php
echo $total_pages;
?>
</span></span>
<script>
jQuery( document ).ready( function ( $ ) {
var pageInput = $( 'input.current-page' );
var currentPage = pageInput.val();
pageInput.closest( 'form' ).submit( function ( e ) {
if (
( 1 > $( 'select[name="action<?php
echo esc_attr($this->num);
?>
"]' ).length
|| $( 'select[name="action<?php
echo esc_attr($this->num);
?>
"]' ).val() == -1 )
&& ( 1 > $( 'select[name="action_bulk<?php
echo esc_attr($this->num);
?>
"]' ).length
|| $( 'select[name="action_bulk<?php
echo esc_attr($this->num);
?>
"]' ).val() == -1 )
&& pageInput.val() == currentPage ) {
pageInput.val( '1' );
}
} );
} );
</script>
<?php
} else {
?>
<span class="paging-input"><?php
echo $this->page;
?>
<?php
_e('of', 'pods');
?>
<span class="total-pages"><?php
echo number_format_i18n($total_pages);
?>
</span></span>
<?php
}
?>
<a class="next-page<?php
echo esc_attr($this->page < $total_pages ? '' : ' disabled');
?>
" title="<?php
esc_attr_e('Go to the next page', 'pods');
?>
" href="<?php
echo esc_url($request_uri . ($append ? '&' : '?') . 'pg' . $this->num . '=' . min($this->page + 1, $total_pages));
?>
">›</a>
<a class="last-page<?php
echo esc_attr($this->page < $total_pages ? '' : ' disabled');
?>
" title="<?php
esc_attr_e('Go to the last page', 'pods');
?>
'" href="<?php
echo esc_url($request_uri . ($append ? '&' : '?') . 'pg' . $this->num . '=' . $total_pages);
?>
">»</a>
<?php
}
}
}