Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to Bootstrap 4 #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions wp_bootstrap_pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
/**
* WordPress Bootstrap Pagination
*/

function wp_bootstrap_pagination( $args = array() ) {

$defaults = array(
'range' => 4,
'custom_query' => FALSE,
'previous_string' => __( 'Previous', 'text-domain' ),
'next_string' => __( 'Next', 'text-domain' ),
'before_output' => '<div class="post-nav"><ul class="pager">',
'after_output' => '</ul></div>'
'before_output' => ' <ul class="pagination justify-content-center">',
'after_output' => '</ul>'
);

$args = wp_parse_args(
Expand Down Expand Up @@ -54,29 +54,32 @@ function wp_bootstrap_pagination( $args = array() ) {

$firstpage = esc_attr( get_pagenum_link(1) );
if ( $firstpage && (1 != $page) )
$echo .= '<li class="previous"><a href="' . $firstpage . '">' . __( 'First', 'text-domain' ) . '</a></li>';
$echo .= ' <li class="page-item"><a class="page-link" href="' . $firstpage . '" aria-label="Previous"><span aria-hidden="true">' . __( 'First', 'text-domain' ) . '</span></a></li>';


if ( $previous && (1 != $page) )
$echo .= '<li><a href="' . $previous . '" title="' . __( 'previous', 'text-domain') . '">' . $args['previous_string'] . '</a></li>';
$echo .= '<li class="page-item"><a class="page-link" href="' . $previous . '" title="' . __( 'previous', 'text-domain') . '">' . $args['previous_string'] . '</a></li>';

if ( !empty($min) && !empty($max) ) {

if ( !empty($min) && !empty($max) ) {
for( $i = $min; $i <= $max; $i++ ) {
if ($page == $i) {
$echo .= '<li class="active"><span class="active">' . str_pad( (int)$i, 2, '0', STR_PAD_LEFT ) . '</span></li>';
$echo .= '<li class="page-item active"><a class="page-link" href="%s"><span class="sr-only">(current)</span>' . str_pad( (int)$i, 2, '0', STR_PAD_LEFT ) . '</span></li>';
} else {
$echo .= sprintf( '<li><a href="%s">%002d</a></li>', esc_attr( get_pagenum_link($i) ), $i );
$echo .= sprintf( '<li class="page-item"><a class="page-link" href="%s">%002d<span class="sr-only">(current)</span></a></li>', esc_attr( get_pagenum_link($i) ), $i );
}
}
}



$next = intval($page) + 1;
$next = esc_attr( get_pagenum_link($next) );
if ($next && ($count != $page) )
$echo .= '<li><a href="' . $next . '" title="' . __( 'next', 'text-domain') . '">' . $args['next_string'] . '</a></li>';
$echo .= '<li class="page-item"><a class="page-link" href="' . $next . '" title="' . __( 'next', 'text-domain') . '">' . $args['next_string'] . '</a></li>';

$lastpage = esc_attr( get_pagenum_link($count) );
if ( $lastpage ) {
$echo .= '<li class="next"><a href="' . $lastpage . '">' . __( 'Last', 'text-domain' ) . '</a></li>';
$echo .= '<li class="page-item"><a class="page-link" href="' . $lastpage . '" aria-label="Next"><span aria-hidden="true">' . __( 'Last', 'text-domain' ) . '</span></a></li>';
}

if ( isset($echo) )
Expand Down