Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function the_core_paging_navigation( $wp_query = null ) {
- if ( ! $wp_query ) {
- $wp_query = $GLOBALS['wp_query'];
- }
- // Don't print empty markup if there's only one page.
- if ( $wp_query->max_num_pages < 2 ) {
- return;
- }
- $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
- $pagenum_link = html_entity_decode( get_pagenum_link() );
- $query_args = array();
- $url_parts = explode( '?', $pagenum_link );
- if ( isset( $url_parts[1] ) ) {
- wp_parse_str( $url_parts[1], $query_args );
- }
- $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
- $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
- $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
- $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
- $the_core_pagination_type = function_exists('fw_get_db_settings_option') ? fw_get_db_settings_option('blog_pagination', 'paging-navigation-type-1') : 'paging-navigation-type-1';
- if( $the_core_pagination_type == 'paging-navigation-type-2' ) {
- $prev_text = esc_html__( 'Prev Page', 'the-core' );
- $next_text = esc_html__( 'Next Page', 'the-core' );
- $prev_icon = '<i>←</i>';
- $next_icon = '<i>→</i>';
- }
- else {
- $prev_text = esc_html__( 'Newer', 'the-core' );
- $next_text = esc_html__( 'Older', 'the-core' );
- $prev_icon = '<i class="fa fa-angle-left"></i>';
- $next_icon = '<i class="fa fa-angle-right"></i>';
- }
- // Set up paginated links.
- $links = paginate_links( array(
- 'base' => $pagenum_link,
- 'format' => $format,
- 'total' => $wp_query->max_num_pages,
- 'current' => $paged,
- 'mid_size' => 1,
- 'type' => 'array',
- 'add_args' => array_map( 'urlencode', $query_args ),
- 'prev_text' => $prev_icon.'<strong>' . $prev_text . '</strong>',
- 'next_text' => '<strong>' . $next_text . '</strong>'.$next_icon,
- ) );
- if ( $links ) : ?>
- <nav class="navigation paging-navigation <?php echo esc_attr($the_core_pagination_type); ?>" role="navigation">
- <div class="pagination loop-pagination">
- <?php
- $next = get_next_posts_link();
- $prev = get_previous_posts_link();
- if ( empty( $prev ) ) {
- echo '<a href="javascript:void(0)" class="prev page-numbers disabled">'.$prev_icon.'<strong>' . $prev_text . '</strong></a>';
- $begin_for = 0;
- }
- else {
- $begin_for = 1;
- }
- if ( empty( $next ) ) {
- $end_for = count($links) - 1;
- }
- else {
- $end_for = count($links) - 2;
- }
- // parse link in foreach for make a wrap only for numbers
- foreach( $links as $key => $value ) {
- if( $key == $begin_for ) {
- echo '<div class="before-hr"></div>';
- echo '<div class="pagination-numbers-wrap">';
- }
- echo ($value);
- if( $key == $end_for ) {
- echo '</div>';
- echo '<div class="after-hr"></div>';
- }
- }
- if ( empty( $next ) ) {
- echo '<a href="javascript:void(0)" class="next page-numbers disabled"><strong>' . $next_text . '</strong>'.$next_icon.'</a>';
- }
- ?>
- </div><!-- .pagination -->
- </nav><!-- .navigation -->
- <?php endif;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement