Skip to content

Commit

Permalink
Bringing in version 0.1.6 of the script for fixes with pagination.
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Tadlock committed Oct 18, 2012
1 parent 94cc99e commit ee59369
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions extensions/loop-pagination.php
Expand Up @@ -13,12 +13,12 @@
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* @package LoopPagination
* @version 0.1.5
* @author Justin Tadlock <justin@justintadlock.com>
* @package LoopPagination
* @version 0.1.6
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2010 - 2012, Justin Tadlock
* @link http://devpress.com/blog/loop-pagination-for-theme-developers
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* @link http://themehybrid.com/docs/tutorials/loop-pagination
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/

/**
Expand Down Expand Up @@ -46,34 +46,37 @@ function loop_pagination( $args = array() ) {

/* Set up some default arguments for the paginate_links() function. */
$defaults = array(
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
'total' => $max_num_pages,
'current' => $current,
'prev_next' => true,
//'prev_text' => __( '&laquo; Previous' ), // This is the WordPress default.
//'next_text' => __( 'Next &raquo;' ), // This is the WordPress default.
'show_all' => false,
'end_size' => 1,
'mid_size' => 1,
'base' => add_query_arg( 'paged', '%#%' ),
'format' => '',
'total' => $max_num_pages,
'current' => $current,
'prev_next' => true,
//'prev_text' => __( '&laquo; Previous' ), // This is the WordPress default.
//'next_text' => __( 'Next &raquo;' ), // This is the WordPress default.
'show_all' => false,
'end_size' => 1,
'mid_size' => 1,
'add_fragment' => '',
'type' => 'plain',
'before' => '<div class="pagination loop-pagination">', // Begin loop_pagination() arguments.
'after' => '</div>',
'echo' => true,
'type' => 'plain',

// Begin loop_pagination() arguments.
'before' => '<div class="pagination loop-pagination">',
'after' => '</div>',
'echo' => true,
);

/* Add the $base argument to the array if the user is using permalinks. */
if ( $wp_rewrite->using_permalinks() )
$defaults['base'] = str_replace( 2, '%#%', esc_url( get_pagenum_link( 2 ) ) );
//$defaults['base'] = user_trailingslashit( trailingslashit( get_pagenum_link() ) . 'page/%#%' );
if ( $wp_rewrite->using_permalinks() && !is_search() )
$defaults['base'] = user_trailingslashit( trailingslashit( get_pagenum_link() ) . 'page/%#%' );

/* If we're on a search results page, we need to change this up a bit. */
/* @todo Find a way to make pretty links work for search in all cases. */
/**
if ( is_search() ) {
$search_permastruct = $wp_rewrite->get_search_permastruct();
if ( !empty( $search_permastruct ) )
$defaults['base'] = user_trailingslashit( trailingslashit( get_search_link() ) . 'page/%#%' );
}
/**/

/* Allow developers to overwrite the arguments with a filter. */
$args = apply_filters( 'loop_pagination_args', $args );
Expand Down

0 comments on commit ee59369

Please sign in to comment.