Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @link https://kriesi.at/support/topic/pagination-show-last-page/#post-1254266
- */
- function enfold_pagination_output($output, $paged, $pages, $wrapper, $query_arg) {
- $output = '';
- $prev = $paged - 1;
- $next = $paged + 1;
- $range = 2;
- $showitems = ( $range * 2 )+1;
- $method = is_single() ? 'avia_post_pagination_link' : 'get_pagenum_link';
- $method = apply_filters( 'avf_pagination_link_method', $method, $pages, $wrapper, $query_arg );
- if( 1 != $pages )
- {
- $output .= "<{$wrapper} class='pagination'>";
- $output .= "<span class='pagination-meta'>" . sprintf( __( "Page %d of %d", 'avia_framework' ), $paged, $pages ) . "</span>";
- $output .= ( $paged > 2 && $paged > $range + 1 && $showitems < $pages )? "<a href='" . avia_extended_pagination_link( $method, 1, $query_arg ) . "'>«</a>":'';
- $output .= ( $paged > 1 && $showitems < $pages )? "<a href='" . avia_extended_pagination_link( $method, $prev, $query_arg ) . "'>‹</a>":'';
- $output .= ( $paged > 2 && $paged > $range + 1 && $showitems < $pages )? "<a href='" . avia_extended_pagination_link( $method, 1, $query_arg ) . "'>1</a>":'';
- $output .= ( $paged > 2 && $paged - $range > 2 && $showitems < $pages )? "<span>…</span>":'';
- for( $i = 1; $i <= $pages; $i++ )
- {
- if( 1 != $pages &&( ! ( $i >= $paged+$range + 1 || $i <= $paged - $range-1 ) || $pages <= $showitems ) )
- {
- switch( $i )
- {
- case ( $paged == $i ):
- $class = 'current';
- break;
- case ( ( $paged - 1 ) == $i ):
- $class = 'inactive previous_page';
- break;
- case ( ( $paged + 1 ) == $i ):
- $class = 'inactive next_page';
- break;
- default:
- $class = 'inactive';
- break;
- }
- $output .= ( $paged == $i ) ? "<span class='{$class}'>{$i}</span>" : "<a href='" . avia_extended_pagination_link( $method, $i, $query_arg ) . "' class='{$class}' >{$i}</a>";
- }
- }
- $output .= ( $paged < $pages && $paged + $range < $pages - 1 && $showitems < $pages ) ? "<span>…</span>" :'';
- $output .= ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages ) ? "<a href='" . avia_extended_pagination_link( $method, $pages, $query_arg ) . "'>" . $pages . "</a>":'';
- $output .= ( $paged < $pages && $showitems < $pages ) ? "<a href='" . avia_extended_pagination_link( $method, $next, $query_arg ) . "'>›</a>" :'';
- $output .= ( $paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages ) ? "<a href='" . avia_extended_pagination_link( $method, $pages, $query_arg ) . "'>»</a>":'';
- $output .= "</{$wrapper}>\n";
- }
- return $output;
- }
- add_filter('avf_pagination_output', 'enfold_pagination_output', 10, 5);
Add Comment
Please, Sign In to add comment