/** * Display navigation to next/previous pages when applicable */ function ipt_kb_content_nav($nav_id) { global $wp_query, $post; // Give compatibility for wp-pagenavi if (function_exists('wp_pagenavi') && !is_single()) { $args = wp_parse_args(array(), array('before' => '', 'after' => '', 'options' => array(), 'query' => $GLOBALS['wp_query'], 'type' => 'posts', 'echo' => true)); extract($args, EXTR_SKIP); $options = wp_parse_args($options, PageNavi_Core::$options->get()); $instance = new PageNavi_Call($args); list($posts_per_page, $paged, $total_pages) = $instance->get_pagination_args(); if (1 == $total_pages && !$options['always_show']) { return; } $pages_to_show = absint($options['num_pages']); $larger_page_to_show = absint($options['num_larger_page_numbers']); $larger_page_multiple = absint($options['larger_page_numbers_multiple']); $pages_to_show_minus_1 = $pages_to_show - 1; $half_page_start = floor($pages_to_show_minus_1 / 2); $half_page_end = ceil($pages_to_show_minus_1 / 2); $start_page = $paged - $half_page_start; if ($start_page <= 0) { $start_page = 1; } $end_page = $paged + $half_page_end; if ($end_page - $start_page != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if ($end_page > $total_pages) { $start_page = $total_pages - $pages_to_show_minus_1; $end_page = $total_pages; } if ($start_page < 1) { $start_page = 1; } $out = ''; // Text if (!empty($options['pages_text'])) { $pages_text = str_replace(array("%CURRENT_PAGE%", "%TOTAL_PAGES%"), array(number_format_i18n($paged), number_format_i18n($total_pages)), $options['pages_text']); $out .= "<li class='disabled'><span class='pages'>{$pages_text}</span></li>"; } if ($start_page >= 2 && $pages_to_show < $total_pages) { // First $first_text = str_replace('%TOTAL_PAGES%', number_format_i18n($total_pages), $options['first_text']); $out .= '<li>' . $instance->get_single(1, '<i class="glyphicon glyphicon-fast-backward"></i>', array('class' => 'first bstooltip', 'title' => $first_text, 'data-container' => 'body'), '%TOTAL_PAGES%') . '</li>'; } // Previous if ($paged > 1 && !empty($options['prev_text'])) { $out .= '<li>' . $instance->get_single($paged - 1, '<i class="glyphicon glyphicon-backward"></i>', array('class' => 'previouspostslink bstooltip', 'title' => $options['prev_text'], 'data-container' => 'body')) . '</li>'; } if ($start_page >= 2 && $pages_to_show < $total_pages) { if (!empty($options['dotleft_text'])) { $out .= "<li class='disabled'><span class='extend'>{$options['dotleft_text']}</span></li>"; } } // Smaller pages $larger_pages_array = array(); if ($larger_page_multiple) { for ($i = $larger_page_multiple; $i <= $total_pages; $i += $larger_page_multiple) { $larger_pages_array[] = $i; } } $larger_page_start = 0; foreach ($larger_pages_array as $larger_page) { if ($larger_page < $start_page - $half_page_start && $larger_page_start < $larger_page_to_show) { $out .= '<li>' . $instance->get_single($larger_page, $options['page_text'], array('class' => 'smaller page')) . '</li>'; $larger_page_start++; } } if ($larger_page_start) { $out .= "<li class='disabled'><span class='extend'>{$options['dotleft_text']}</span></li>"; } // Page numbers $timeline = 'smaller'; foreach (range($start_page, $end_page) as $i) { if ($i == $paged && !empty($options['current_text'])) { $current_page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['current_text']); $out .= "<li class='active'><span class='current'>{$current_page_text}</span></li>"; $timeline = 'larger'; } else { $out .= '<li>' . $instance->get_single($i, $options['page_text'], array('class' => "page {$timeline}")) . '</li>'; } } // Large pages $larger_page_end = 0; $larger_page_out = ''; foreach ($larger_pages_array as $larger_page) { if ($larger_page > $end_page + $half_page_end && $larger_page_end < $larger_page_to_show) { $larger_page_out .= '<li>' . $instance->get_single($larger_page, $options['page_text'], array('class' => 'larger page')) . '</li>'; $larger_page_end++; } } if ($larger_page_out) { $out .= "<li class='disabled'><span class='extend'>{$options['dotright_text']}</span></li>"; } $out .= $larger_page_out; if ($end_page < $total_pages) { if (!empty($options['dotright_text'])) { $out .= "<li class='disabled'><span class='extend'>{$options['dotright_text']}</span></li>"; } } // Next if ($paged < $total_pages && !empty($options['next_text'])) { $out .= '<li>' . $instance->get_single($paged + 1, '<i class="glyphicon glyphicon-forward"></i>', array('class' => 'nextpostslink bstooltip', 'title' => $options['next_text'], 'data-container' => 'body')) . '</li>'; } if ($end_page < $total_pages) { // Last $out .= '<li>' . $instance->get_single($total_pages, '<i class="glyphicon glyphicon-fast-forward"></i>', array('class' => 'last bstooltip', 'title' => $options['last_text'], 'data-container' => 'body'), '%TOTAL_PAGES%') . '</li>'; } $out = $before . "<ul class='pagination pagination-lg'>\n{$out}\n</ul>" . $after; $out = apply_filters('wp_pagenavi', $out); if (!$echo) { return $out; } echo $out; return; } // Don't print empty markup on single pages if there's nowhere to navigate. if (is_single()) { $previous = is_attachment() ? get_post($post->post_parent) : get_adjacent_post(true, '', true); $next = get_adjacent_post(true, '', false); if (!$next && !$previous) { return; } } // Don't print empty markup in archives if there's only one page. if ($wp_query->max_num_pages < 2 && (is_home() || is_archive() || is_search())) { return; } $nav_class = is_single() ? 'post-navigation' : 'paging-navigation'; // Add support with bootstrap pager $nav_class .= ' pager'; ?> <ul role="navigation" id="<?php echo esc_attr($nav_id); ?> " class="<?php echo $nav_class; ?> "> <li class="screen-reader-text"><?php _e('Post navigation', 'ipt_kb'); ?> </li> <?php if (is_single()) { // navigation links for single posts ?> <?php previous_post_link('<li class="nav-previous previous">%link</li>', '<span class="meta-nav">' . _x('<span class="glyphicon glyphicon-arrow-left"></span>', 'Previous post link', 'ipt_kb') . '</span> %title', true); ?> <?php next_post_link('<li class="nav-next next">%link</li>', '%title <span class="meta-nav">' . _x('<span class="glyphicon glyphicon-arrow-right"></span>', 'Next post link', 'ipt_kb') . '</span>', true); ?> <?php } elseif ($wp_query->max_num_pages > 1 && (is_home() || is_archive() || is_search())) { // navigation links for home, archive, and search pages ?> <?php if (get_next_posts_link()) { ?> <li class="nav-previous previous"><?php next_posts_link(__('<span class="meta-nav"><span class="glyphicon glyphicon-arrow-left"></span></span> Older posts', 'ipt_kb')); ?> </li> <?php } ?> <?php if (get_previous_posts_link()) { ?> <li class="nav-next next"><?php previous_posts_link(__('Newer posts <span class="meta-nav"><span class="glyphicon glyphicon-arrow-right"></span></span>', 'ipt_kb')); ?> </li> <?php } ?> <?php } ?> </ul><!-- #<?php echo esc_html($nav_id); ?> --> <?php }
/** * Template tag: Boxed Style Paging * * @param array $args: * 'before': (string) * 'after': (string) * 'options': (string|array) Used to overwrite options set in WP-Admin -> Settings -> PageNavi * 'query': (object) A WP_Query instance */ function wp_pagenavi($args = array()) { if (!is_array($args)) { $argv = func_get_args(); $args = array(); foreach (array('before', 'after', 'options') as $i => $key) { $args[$key] = isset($argv[$i]) ? $argv[$i] : ""; } } $args = wp_parse_args($args, array('before' => '', 'after' => '', 'options' => array(), 'query' => $GLOBALS['wp_query'], 'type' => 'posts', 'echo' => true)); extract($args, EXTR_SKIP); $options = wp_parse_args($options, PageNavi_Core::$options->get()); $instance = new PageNavi_Call($args); list($posts_per_page, $paged, $total_pages) = $instance->get_pagination_args(); if (1 == $total_pages && !$options['always_show']) { return; } $pages_to_show = absint($options['num_pages']); $larger_page_to_show = absint($options['num_larger_page_numbers']); $larger_page_multiple = absint($options['larger_page_numbers_multiple']); $pages_to_show_minus_1 = $pages_to_show - 1; $half_page_start = floor($pages_to_show_minus_1 / 2); $half_page_end = ceil($pages_to_show_minus_1 / 2); $start_page = $paged - $half_page_start; if ($start_page <= 0) { $start_page = 1; } $end_page = $paged + $half_page_end; if ($end_page - $start_page != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if ($end_page > $total_pages) { $start_page = $total_pages - $pages_to_show_minus_1; $end_page = $total_pages; } if ($start_page < 1) { $start_page = 1; } // Support for filters to change class names $class_names = array('pages' => apply_filters('wp_pagenavi_class_pages', 'pages'), 'first' => apply_filters('wp_pagenavi_class_first', 'first'), 'previouspostslink' => apply_filters('wp_pagenavi_class_previouspostslink', 'previouspostslink'), 'extend' => apply_filters('wp_pagenavi_class_extend', 'extend'), 'smaller' => apply_filters('wp_pagenavi_class_smaller', 'smaller'), 'page' => apply_filters('wp_pagenavi_class_page', 'page'), 'current' => apply_filters('wp_pagenavi_class_current', 'current'), 'larger' => apply_filters('wp_pagenavi_class_larger', 'larger'), 'nextpostslink' => apply_filters('wp_pagenavi_class_nextpostslink', 'nextpostslink'), 'last' => apply_filters('wp_pagenavi_class_last', 'last')); $out = ''; switch (intval($options['style'])) { // Normal case 1: // Text if (!empty($options['pages_text'])) { $pages_text = str_replace(array("%CURRENT_PAGE%", "%TOTAL_PAGES%"), array(number_format_i18n($paged), number_format_i18n($total_pages)), __($options['pages_text'], 'wp-pagenavi')); $out .= "<span class='{$class_names['pages']}'>{$pages_text}</span>"; } if ($start_page >= 2 && $pages_to_show < $total_pages) { // First $first_text = str_replace('%TOTAL_PAGES%', number_format_i18n($total_pages), __($options['first_text'], 'wp-pagenavi')); $out .= $instance->get_single(1, $first_text, array('class' => $class_names['first']), '%TOTAL_PAGES%'); } // Previous if ($paged > 1 && !empty($options['prev_text'])) { $out .= $instance->get_single($paged - 1, $options['prev_text'], array('class' => $class_names['previouspostslink'], 'rel' => 'prev')); } if ($start_page >= 2 && $pages_to_show < $total_pages) { if (!empty($options['dotleft_text'])) { $out .= "<span class='{$class_names['extend']}'>{$options['dotleft_text']}</span>"; } } // Smaller pages $larger_pages_array = array(); if ($larger_page_multiple) { for ($i = $larger_page_multiple; $i <= $total_pages; $i += $larger_page_multiple) { $larger_pages_array[] = $i; } } $larger_page_start = 0; foreach ($larger_pages_array as $larger_page) { if ($larger_page < $start_page - $half_page_start && $larger_page_start < $larger_page_to_show) { $out .= $instance->get_single($larger_page, $options['page_text'], array('class' => "{$class_names['smaller']} {$class_names['page']}")); $larger_page_start++; } } if ($larger_page_start) { $out .= "<span class='{$class_names['extend']}'>{$options['dotleft_text']}</span>"; } // Page numbers $timeline = 'smaller'; foreach (range($start_page, $end_page) as $i) { if ($i == $paged && !empty($options['current_text'])) { $current_page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['current_text']); $out .= "<span class='{$class_names['current']}'>{$current_page_text}</span>"; $timeline = 'larger'; } else { $out .= $instance->get_single($i, $options['page_text'], array('class' => "{$class_names['page']} {$class_names[$timeline]}")); } } // Large pages $larger_page_end = 0; $larger_page_out = ''; foreach ($larger_pages_array as $larger_page) { if ($larger_page > $end_page + $half_page_end && $larger_page_end < $larger_page_to_show) { $larger_page_out .= $instance->get_single($larger_page, $options['page_text'], array('class' => "{$class_names['larger']} {$class_names['page']}")); $larger_page_end++; } } if ($larger_page_out) { $out .= "<span class='{$class_names['extend']}'>{$options['dotright_text']}</span>"; } $out .= $larger_page_out; if ($end_page < $total_pages) { if (!empty($options['dotright_text'])) { $out .= "<span class='{$class_names['extend']}'>{$options['dotright_text']}</span>"; } } // Next if ($paged < $total_pages && !empty($options['next_text'])) { $out .= $instance->get_single($paged + 1, $options['next_text'], array('class' => $class_names['nextpostslink'], 'rel' => 'next')); } if ($end_page < $total_pages) { // Last $out .= $instance->get_single($total_pages, __($options['last_text'], 'wp-pagenavi'), array('class' => $class_names['last']), '%TOTAL_PAGES%'); } break; // Dropdown // Dropdown case 2: $out .= '<form action="" method="get">' . "\n"; $out .= '<select size="1" onchange="document.location.href = this.options[this.selectedIndex].value;">' . "\n"; foreach (range(1, $total_pages) as $i) { $page_num = $i; if ($page_num == 1) { $page_num = 0; } if ($i == $paged) { $current_page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['current_text']); $out .= '<option value="' . esc_url($instance->get_url($page_num)) . '" selected="selected" class="' . $class_names['current'] . '">' . $current_page_text . "</option>\n"; } else { $page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['page_text']); $out .= '<option value="' . esc_url($instance->get_url($page_num)) . '">' . $page_text . "</option>\n"; } } $out .= "</select>\n"; $out .= "</form>\n"; break; } $out = $before . "<div class='wp-pagenavi'>\n{$out}\n</div>" . $after; $out = apply_filters('wp_pagenavi', $out); if (!$echo) { return $out; } echo $out; }
/** * Template tag: Boxed Style Paging * @version 2.83 */ function wp_pagenavi($args = array()) { $defaults = array('before' => '', 'after' => '', 'class_active' => 'current', 'container' => 'div', 'container_class' => 'pagination-container', 'menu_class' => 'pagination-menu', 'style' => 'list', 'options' => array('pages_text' => get_setting('pagination_pages_text', __('Page %CURRENT_PAGE% of %TOTAL_PAGES%', 'spyropress')), 'current_text' => get_setting('pagination_current_text', '%PAGE_NUMBER%'), 'page_text' => get_setting('pagination_page_text', '%PAGE_NUMBER%'), 'first_text' => get_setting('pagination_first_text', __('« First', 'spyropress')), 'last_text' => get_setting('pagination_last_text', __('Last »', 'spyropress')), 'prev_text' => get_setting('pagination_prev_text', __('«', 'spyropress')), 'next_text' => get_setting('pagination_next_text', __('»', 'spyropress')), 'dotleft_text' => get_setting('pagination_dotleft_text', __('…', 'spyropress')), 'dotright_text' => get_setting('pagination_dotright_text', __('…', 'spyropress')), 'num_pages' => get_setting('pagination_num_pages', 5), 'num_larger_page_numbers' => get_setting('pagination_num_larger_page_numbers', 3), 'larger_page_numbers_multiple' => get_setting('pagination_larger_page_numbers_multiple', 10), 'always_show' => get_setting('pagination_always_show', false)), 'query' => $GLOBALS['wp_query'], 'type' => 'posts', 'echo' => true); $args = wp_parse_args($args, apply_filters('spyropress_pagination_defaults', $defaults)); extract($args, EXTR_SKIP); $instance = new PageNavi_Call($args); list($posts_per_page, $paged, $total_pages) = $instance->get_pagination_args(); if (1 == $total_pages && !$options['always_show']) { return; } $pages_to_show = absint($options['num_pages']); $larger_page_to_show = absint($options['num_larger_page_numbers']); $larger_page_multiple = absint($options['larger_page_numbers_multiple']); $pages_to_show_minus_1 = $pages_to_show - 1; $half_page_start = floor($pages_to_show_minus_1 / 2); $half_page_end = ceil($pages_to_show_minus_1 / 2); $start_page = $paged - $half_page_start; if ($start_page <= 0) { $start_page = 1; } $end_page = $paged + $half_page_end; if ($end_page - $start_page != $pages_to_show_minus_1) { $end_page = $start_page + $pages_to_show_minus_1; } if ($end_page > $total_pages) { $start_page = $total_pages - $pages_to_show_minus_1; $end_page = $total_pages; } if ($start_page < 1) { $start_page = 1; } $out = ''; switch ($style) { // Normal case 'list': // Text if (!empty($options['pages_text'])) { $pages_text = str_replace(array("%CURRENT_PAGE%", "%TOTAL_PAGES%"), array(number_format_i18n($paged), number_format_i18n($total_pages)), $options['pages_text']); $out .= "<li><span class='pages'>{$pages_text}</span></li>"; } if ($start_page >= 2 && $pages_to_show < $total_pages) { // First $first_text = str_replace('%TOTAL_PAGES%', number_format_i18n($total_pages), $options['first_text']); $out .= '<li class="first">' . $instance->get_single(1, 'first', $first_text, '%TOTAL_PAGES%') . '</li>'; } // Previous if ($paged > 1 && !empty($options['prev_text'])) { $out .= '<li class="previouspostslink">' . $instance->get_single($paged - 1, 'previouspostslink', $options['prev_text']) . '</li>'; } if ($start_page >= 2 && $pages_to_show < $total_pages) { if (!empty($options['dotleft_text'])) { $out .= "<li><span class='extend'>{$options['dotleft_text']}</span></li>"; } } // Smaller pages $larger_pages_array = array(); if ($larger_page_multiple) { for ($i = $larger_page_multiple; $i <= $total_pages; $i += $larger_page_multiple) { $larger_pages_array[] = $i; } } $larger_page_start = 0; foreach ($larger_pages_array as $larger_page) { if ($larger_page < $start_page - $half_page_start && $larger_page_start < $larger_page_to_show) { $out .= '<li class="smaller page">' . $instance->get_single($larger_page, 'smaller page', $options['page_text']) . '</li>'; $larger_page_start++; } } if ($larger_page_start) { $out .= "<li><span class='extend'>{$options['dotleft_text']}</span></li>"; } // Page numbers $timeline = 'smaller'; foreach (range($start_page, $end_page) as $i) { if ($i == $paged && !empty($options['current_text'])) { $current_page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['current_text']); $out .= "<li class='{$class_active}'><span>{$current_page_text}</span></li>"; $timeline = 'larger'; } else { $out .= '<li class="page ' . $timeline . '">' . $instance->get_single($i, "page {$timeline}", $options['page_text']) . '</li>'; } } // Large pages $larger_page_end = 0; $larger_page_out = ''; foreach ($larger_pages_array as $larger_page) { if ($larger_page > $end_page + $half_page_end && $larger_page_end < $larger_page_to_show) { $larger_page_out .= '<li class="larger page">' . $instance->get_single($larger_page, 'larger page', $options['page_text']) . '</li>'; $larger_page_end++; } } if ($larger_page_out) { $out .= "<li><span class='extend'>{$options['dotright_text']}</span></li>"; } $out .= $larger_page_out; if ($end_page < $total_pages) { if (!empty($options['dotright_text'])) { $out .= "<li><span class='extend'>{$options['dotright_text']}</span></li>"; } } // Next if ($paged < $total_pages && !empty($options['next_text'])) { $out .= '<li class="nextpostslink">' . $instance->get_single($paged + 1, 'nextpostslink', $options['next_text']) . '</li>'; } if ($end_page < $total_pages) { // Last $out .= '<li class="last">' . $instance->get_single($total_pages, 'last', $options['last_text'], '%TOTAL_PAGES%') . '</li>'; } break; // Normal // Normal case 'simple': // Text if (!empty($options['pages_text'])) { $pages_text = str_replace(array("%CURRENT_PAGE%", "%TOTAL_PAGES%"), array(number_format_i18n($paged), number_format_i18n($total_pages)), $options['pages_text']); $out .= "<span class='pages'>{$pages_text}</span>"; } if ($start_page >= 2 && $pages_to_show < $total_pages) { // First $first_text = str_replace('%TOTAL_PAGES%', number_format_i18n($total_pages), $options['first_text']); $out .= $instance->get_single(1, 'first', $first_text, '%TOTAL_PAGES%'); } // Previous if ($paged > 1 && !empty($options['prev_text'])) { $out .= $instance->get_single($paged - 1, 'previouspostslink', $options['prev_text']); } if ($start_page >= 2 && $pages_to_show < $total_pages) { if (!empty($options['dotleft_text'])) { $out .= "<span class='extend'>{$options['dotleft_text']}</span>"; } } // Smaller pages $larger_pages_array = array(); if ($larger_page_multiple) { for ($i = $larger_page_multiple; $i <= $total_pages; $i += $larger_page_multiple) { $larger_pages_array[] = $i; } } $larger_page_start = 0; foreach ($larger_pages_array as $larger_page) { if ($larger_page < $start_page - $half_page_start && $larger_page_start < $larger_page_to_show) { $out .= $instance->get_single($larger_page, 'smaller page', $options['page_text']); $larger_page_start++; } } if ($larger_page_start) { $out .= "<span class='extend'>{$options['dotleft_text']}</span>"; } // Page numbers $timeline = 'smaller'; foreach (range($start_page, $end_page) as $i) { if ($i == $paged && !empty($options['current_text'])) { $current_page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['current_text']); $out .= "<span class='{$class_active}'>{$current_page_text}</span>"; $timeline = 'larger'; } else { $out .= $instance->get_single($i, "page {$timeline}", $options['page_text']); } } // Large pages $larger_page_end = 0; $larger_page_out = ''; foreach ($larger_pages_array as $larger_page) { if ($larger_page > $end_page + $half_page_end && $larger_page_end < $larger_page_to_show) { $larger_page_out .= $instance->get_single($larger_page, 'larger page', $options['page_text']); $larger_page_end++; } } if ($larger_page_out) { $out .= "<span class='extend'>{$options['dotright_text']}</span>"; } $out .= $larger_page_out; if ($end_page < $total_pages) { if (!empty($options['dotright_text'])) { $out .= "<span class='extend'>{$options['dotright_text']}</span>"; } } // Next if ($paged < $total_pages && !empty($options['next_text'])) { $out .= $instance->get_single($paged + 1, 'nextpostslink', $options['next_text']); } if ($end_page < $total_pages) { // Last $out .= $instance->get_single($total_pages, 'last', $options['last_text'], '%TOTAL_PAGES%'); } break; // Dropdown // Dropdown case 'dropdown': $out .= '<form action="" method="get">' . "\n"; $out .= '<select size="1" onchange="document.location.href = this.options[this.selectedIndex].value;">' . "\n"; foreach (range(1, $total_pages) as $i) { $page_num = $i; if ($page_num == 1) { $page_num = 0; } if ($i == $paged) { $current_page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['current_text']); $out .= '<option value="' . esc_url($instance->get_url($page_num)) . '" selected="selected" class="current">' . $current_page_text . "</option>\n"; } else { $page_text = str_replace('%PAGE_NUMBER%', number_format_i18n($i), $options['page_text']); $out .= '<option value="' . esc_url($instance->get_url($page_num)) . '">' . $page_text . "</option>\n"; } } $out .= "</select>\n"; $out .= "</form>\n"; break; } if ('list' == $style) { $out = $before . "<{$container} class='{$container_class}'>\n<ul class='{$menu_class}'>\n{$out}\n</ul>\n</{$container}>" . $after; } else { $out = $before . "<{$container} class='{$container_class}'>\n{$out}\n</{$container}>" . $after; } $out = apply_filters('wp_pagenavi', $out); if (!$echo) { return $out; } echo $out; }