function wp_foundation_six_custom_link_pages($args = '') { $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; $output .= '<ul class="pagination">'; for ($i = 1; $i < $numpages + 1; $i = $i + 1) { $j = str_replace('%', $i, $pagelink); if ($i == $page) { $output .= '<li class="current"><a href="#">'; } else { $output .= '<li>'; } if ($i != $page || !$more && $page == 1) { $output .= _wp_link_page($i); } $output .= $link_before . $j . $link_after; if ($i != $page || !$more && $page == 1) { $output .= '</a>'; } } $output .= '</li>'; $output .= $after; } else { if ($more) { $output .= $before; $i = $page - 1; if ($i && $more) { $output .= _wp_link_page($i); $output .= $link_before . $previouspagelink . $link_after . '</a>'; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= _wp_link_page($i); $output .= $link_before . $nextpagelink . $link_after . '</a>'; } $output .= '</ul>'; $output .= $after; } } } if ($echo) { echo $output; } return $output; }
/** * Modification of wp_link_pages to enclose page links in an unordered list. * * Special thanks to http://wpbungee.webstractions.com/bungee-development/pagination-hybrid-core-theme-templates-twitter-bootstrap/ * */ function puresimple_multi_pages($args = '') { $defaults = array('before' => '<div class="pagination-wrapper clearfix"><label>' . __('Pages: ', 'pure-simple') . '</label><ul class="pagination">', 'after' => '</ul></div>', 'link_before' => '<li>', 'link_after' => '</li>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'pure-simple'), 'previouspagelink' => __('Previous page', 'pure-simple'), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('puresimple_multi_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; for ($i = 1; $i < $numpages + 1; $i = $i + 1) { $j = str_replace('%', $i, $pagelink); if ($i != $page || !$more && $page == 1) { $output .= ' ' . str_replace('%', 'normal', $link_before); $output .= _wp_link_page($i); $output .= $j; $output .= '</a>'; } else { $output .= ' ' . str_replace('%', 'disabled', $link_before); $output .= '<span class="active">' . $j . '</span>'; } $output .= $link_after; } $output .= $after; } else { if ($more) { $output .= $before; $i = $page - 1; if ($i && $more) { $output .= $link_before; $output .= _wp_link_page($i); $output .= $previouspagelink . '</a>'; $output .= $link_after; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= $link_before; $output .= _wp_link_page($i); $output .= $nextpagelink . '</a>'; $output .= $link_after; } $output .= $after; } } } if ($echo) { echo $output; } return $output; }
/** * Can be used instead of wp_link_pages() for showing article-specific pagination. For paginated posts ( posts which * use <!--nextpage--> ), this method implements Foundation's pagination structure instead of WordPress's. * * The following arguments are accepted... * * 'before' - Start of generated HTML object * 'after' - End of generated HTML object * 'page_before' - Element to place before page link. * 'link_before' - Place inside link at start of visible text * 'link_after' - Place inside link at end of visible text * 'page_after' - Closing element to place after page link * 'echo' - Whether to echo the generated object * * @see wp_link_pages() * * @param string|array $args Optional. Overwrite the defaults. * * @deprecated Will be replaced or removed in next version. Use custom method instead. * * @return string Formatted output in HTML. */ public static function article_page_nav($args = array()) { $defaults = array('before' => '<dl class="page-link sub-nav">' . '<dt>' . __('Pages:', 'nvLangScope') . '</dt>', 'page_before' => '<dd%>', 'page_after' => '</dd>', 'link_before' => '', 'link_after' => '', 'after' => '</dl>', 'max_size' => 6, 'echo' => true); $r = wp_parse_args($args, $defaults); //Plugin compatibility $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); /** @var $before string */ /** @var $page_before string */ /** @var $page_after string */ /** @var $link_before string */ /** @var $link_after string */ /** @var $after string */ /** @var $max_size string */ /** @var $echo string */ global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { $output .= $before; //Loop through and count pages... for ($i = 1; $i < $numpages + 1; $i = $i + 1) { //Set the page number $pagenum = $i; //Add a white space... $output .= ' '; //Generate a link only if it isn't the current page if ($i != $page || !$more && $page == 1) { //Is NOT the current page $output .= preg_replace('/%/', '', $page_before); } else { //Current page... $output .= preg_replace('/%/', ' class="active" ', $page_before); } $output .= _wp_link_page($i); //$link_start; $output .= $link_before; $output .= $pagenum; $output .= $link_after; $output .= '</a>'; //$link_end; $output .= $page_after; } $output .= $after; } if ($echo) { echo $output; } return $output; }
function custom_wp_link_pages($args = '') { $defaults = array('before' => '<div id="post_pagination" class="clearfix"><h5>' . __('Pages:') . '</h5>', 'after' => '</div>', 'text_before' => '', 'text_after' => '', 'next_or_number' => 'number', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; for ($i = 1; $i < $numpages + 1; $i = $i + 1) { $j = str_replace('%', $i, $pagelink); $output .= ' '; if ($i != $page || !$more && $page == 1) { $output .= _wp_link_page($i); } else { $output .= '<p class="current-post-page">'; } $output .= $text_before . $j . $text_after; if ($i != $page || !$more && $page == 1) { $output .= '</a>'; } else { $output .= '</p>'; } } $output .= $after; } else { if ($more) { $output .= $before; $i = $page - 1; if ($i && $more) { $output .= _wp_link_page($i); $output .= $text_before . $previouspagelink . $text_after . '</a>'; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= _wp_link_page($i); $output .= $text_before . $nextpagelink . $text_after . '</a>'; } $output .= $after; } } } if ($echo) { echo $output; } return $output; }
function custom_wp_link_pages($args = '') { $defaults = array('before' => '<ul class="pagination number text-center" role="navigation" aria-label="Pagination">', 'after' => '</ul>', 'text_before' => '', 'text_after' => '', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', 'kindel'), 'previouspagelink' => __('Previous page', 'kindel'), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; for ($i = 1; $i < $numpages + 1; $i = $i + 1) { $j = str_replace('%', $i, $pagelink); $output .= ' '; if ($i != $page || !$more && $page == 1) { $output .= '<li>' . _wp_link_page($i); } else { $output .= '<li class="current"><span class="show-for-sr">You are on page:</span>'; } $output .= $text_before . $j . $text_after; if ($i != $page || !$more && $page == 1) { $output .= '</a>'; } else { $output .= '</li>'; } } $output .= $after; } else { if ($more) { $output .= $before; $i = $page - 1; if ($i && $more) { $output .= _wp_link_page($i); $output .= $text_before . $previouspagelink . $text_after . '</a></li>'; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= _wp_link_page($i); $output .= $text_before . $nextpagelink . $text_after . '</a></li>'; } $output .= $after; } } } if ($echo) { echo $output; } return $output; }
public static function add_next_and_number($args) { global $page, $numpages, $multipage, $more; if (!$multipage || !$more || $args['next_or_number'] !== 'next_and_number') { return $args; } $args['next_or_number'] = 'number'; $prev = $next = ''; $i = $page - 1; $prev .= _wp_link_page($i); $prev .= $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>'; $i = $page + 1; if ($i <= $numpages) { $next .= _wp_link_page($i); $next .= $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'; } $args['before'] = $args['before'] . ($page == 1 ? '' : $prev); $args['after'] = $next . $args['after']; return $args; }
function test_wp_link_pages() { $contents = array('One', 'Two', 'Three'); $content = join('<!--nextpage-->', $contents); $post_id = self::factory()->post->create(array('post_content' => $content)); $this->go_to('?p=' . $post_id); setup_postdata(get_post($post_id)); $permalink = sprintf('<a href="%s">', get_permalink()); $page2 = _wp_link_page(2); $page3 = _wp_link_page(3); $expected = "<p>Pages: 1 {$page2}2</a> {$page3}3</a></p>"; $output = wp_link_pages(array('echo' => 0)); $this->assertEquals($expected, $output); $before_after = " 1 {$page2}2</a> {$page3}3</a>"; $output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '')); $this->assertEquals($before_after, $output); $separator = " 1{$page2}2</a>{$page3}3</a>"; $output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '')); $this->assertEquals($separator, $output); $link = " <em>1</em>{$page2}<em>2</em></a>{$page3}<em>3</em></a>"; $output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'link_before' => '<em>', 'link_after' => '</em>')); $this->assertEquals($link, $output); $next = "{$page2}<em>Next page</em></a>"; $output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'link_before' => '<em>', 'link_after' => '</em>', 'next_or_number' => 'next')); $this->assertEquals($next, $output); $GLOBALS['page'] = 2; $next_prev = "{$permalink}<em>Previous page</em></a>{$page3}<em>Next page</em></a>"; $output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'link_before' => '<em>', 'link_after' => '</em>', 'next_or_number' => 'next')); $this->assertEquals($next_prev, $output); $next_prev_link = "{$permalink}Woo page</a>{$page3}Hoo page</a>"; $output = wp_link_pages(array('echo' => 0, 'before' => '', 'after' => '', 'separator' => '', 'next_or_number' => 'next', 'nextpagelink' => 'Hoo page', 'previouspagelink' => 'Woo page')); $this->assertEquals($next_prev_link, $output); $GLOBALS['page'] = 1; $separator = "<p>Pages: 1 | {$page2}2</a> | {$page3}3</a></p>"; $output = wp_link_pages(array('echo' => 0, 'separator' => ' | ')); $this->assertEquals($separator, $output); $pagelink = " Page 1 | {$page2}Page 2</a> | {$page3}Page 3</a>"; $output = wp_link_pages(array('echo' => 0, 'separator' => ' | ', 'before' => '', 'after' => '', 'pagelink' => 'Page %')); $this->assertEquals($pagelink, $output); }
/** * Add prev and next links to a numbered page link list */ function wp_link_pages_args_prevnext_add($args) { global $page, $numpages, $more, $pagenow; if (!$args['next_or_number'] == 'next_and_number') { return $args; } # exit early $args['next_or_number'] = 'number'; # keep numbering for the main part if (!$more) { return $args; } # exit early if ($page - 1) { # there is a previous page $args['before'] .= _wp_link_page($page - 1) . $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>'; } if ($page < $numpages) { # there is a next page $args['after'] = _wp_link_page($page + 1) . $args['link_before'] . ' ' . $args['nextpagelink'] . $args['link_after'] . '</a>' . $args['after']; } return $args; }
/** * Link Pages. * * Modification of wp_link_pages() with an extra element to highlight the current page. * * @author toscho * @link http://wordpress.stackexchange.com/questions/14406/how-to-style-current-page-number-wp-link-pages * * @param Array $args Arguments. */ function bootstrap_link_pages($args = array()) { $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'before_link' => '', 'after_link' => '', 'current_before' => '', 'current_after' => '', 'link_before' => '', 'link_after' => '', 'pagelink' => '%', 'echo' => 1); $args = wp_parse_args($args, $defaults); $args = apply_filters('wp_link_pages_args', $args); $before = $args['before']; $after = $args['after']; $before_link = $args['before_link']; $after_link = $args['after_link']; $current_before = $args['current_before']; $current_after = $args['current_after']; $link_before = $args['link_before']; $link_after = $args['link_after']; $pagelink = $args['pagelink']; $echo = $args['echo']; global $page, $numpages, $multipage, $more, $pagenow; if (!$multipage) { return; } $output = $before; for ($i = 1; $i < $numpages + 1; $i++) { $j = str_replace('%', $i, $pagelink); $output .= ' '; if ($i != $page || !$more && 1 == $page) { $output .= sprintf('%1$s%2$s%3$s%4$s%5$s</a>%6$s', $before_link, _wp_link_page($i), $link_before, $j, $link_after, $after_link); } else { $output .= sprintf('%1$s%2$s<a>%3$s</a>%4$s%5$s', $current_before, $link_before, $j, $link_after, $current_after); } } $output .= $after; if ($echo) { print $output; // WPCS: xss ok. } else { return $output; } }
function zee_link_pages($args = '') { $defaults = array('before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', ZEETEXTDOMAIN), 'previouspagelink' => __('Previous page', ZEETEXTDOMAIN), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before . '<ul class="pagination">'; $laquo = $page == 1 ? 'class="disabled"' : ''; $output .= '<li ' . $laquo . '>' . _wp_link_page($page - 1) . '«</li>'; for ($i = 1; $i < $numpages + 1; $i = $i + 1) { $j = str_replace('%', $i, $pagelink); if ($i != $page || !$more && $page == 1) { $output .= '<li>'; $output .= _wp_link_page($i); } else { $output .= '<li class="active">'; $output .= _wp_link_page($i); } $output .= $link_before . $j . $link_after; $output .= '</li>'; } $raquo = $page == $numpages ? 'class="disabled"' : ''; $output .= '<li ' . $raquo . '>' . _wp_link_page($page + 1) . '»</li>'; $output .= '</ul>' . $after; } else { if ($more) { $output .= $before . '<ul class="pager">'; $i = $page - 1; if ($i && $more) { $output .= '<li class="previous">' . _wp_link_page($i); $output .= $link_before . $previouspagelink . $link_after . '</li>'; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= '<li class="next">' . _wp_link_page($i); $output .= $link_before . $nextpagelink . $link_after . '</li>'; } $output .= '</ul>' . $after; } } } if ($echo) { echo $output; } else { return $output; } }
function wpbootstrap_link_pages($args = '') { $defaults = array('before' => '<ul class="pagination">', 'after' => '</ul>', 'next_or_number' => 'number', 'nextpagelink' => __('Next page', "toolset_starter"), 'previouspagelink' => __('Previous page', "toolset_starter"), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; for ($i = 1; $i < $numpages + 1; $i = $i + 1) { $j = str_replace('%', $i, $pagelink); $output .= ' '; if ($i != $page || !$more && $page == 1) { $output .= '<li>' . _wp_link_page($i); } else { $output .= '<li class="active"><a href="#">'; } $output .= $j; if ($i != $page || !$more && $page == 1) { $output .= '</a>'; } else { $output .= '</a></li>'; } } $output .= $after; } else { if ($more) { $output .= $before; $i = $page - 1; if ($i && $more) { $output .= _wp_link_page($i); $output .= $previouspagelink . '</a>'; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= _wp_link_page($i); $output .= $nextpagelink . '</a>'; } $output .= $after; } } } if ($echo) { echo $output; } return $output; }
private static function get_wp_link_page($i) { $link = _wp_link_page($i); $link = new SimpleXMLElement($link . '</a>'); if (isset($link['href'])) { return $link['href']; } return ''; }
function mts_wp_link_pages_args_prevnext_add($args) { global $page, $numpages, $more, $pagenow; if (!$args['next_or_number'] == 'next_and_number') { return $args; } $args['next_or_number'] = 'number'; if (!$more) { return $args; } if ($page - 1) { $args['before'] .= _wp_link_page($page - 1) . $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>'; } if ($page < $numpages) { $args['after'] = _wp_link_page($page + 1) . $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>' . $args['after']; } return $args; }
function wise_custom_wp_link_pages($args = '') { $defaults = array('before' => '<div class="post-navigation-outer"><nav class="post-navigation-wrapper"><ul class="post-pagination">', 'after' => '</ul></nav></div>', 'text_before' => '', 'text_after' => '', 'next_or_number' => 'number', 'nextpagelink' => esc_html__('Next page', 'wise-blog'), 'previouspagelink' => esc_html__('Previous page', 'wise-blog'), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; for ($i = 1; $i < $numpages + 1; $i = $i + 1) { $j = str_replace('%', $i, $pagelink); $output .= '<li> '; if ($i != $page || !$more && $page == 1) { $output .= _wp_link_page($i); } else { $output .= '<span class="post-pagination current-post-page">'; } $output .= $text_before . $j . $text_after; if ($i != $page || !$more && $page == 1) { $output .= '</a>'; } else { $output .= '</span></li>'; } } $output .= $after; } else { if ($more) { $output .= $before; $i = $page - 1; if ($i && $more) { $output .= _wp_link_page($i); $output .= $text_before . $previouspagelink . $text_after . '</a>'; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= _wp_link_page($i); $output .= $text_before . $nextpagelink . $text_after . '</a>'; } $output .= $after; } } } if ($echo) { echo wp_kses_post($output); } return $output; }
/** * Modification of wp_link_pages() with an extra element to highlight the current page. * * @param array $args * @return void */ function cleanyetibasic_numerical_link_pages($args = array()) { $defaults = array('before' => '<p>' . __('Pages:', 'cleanyetibasic'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; if (!$multipage) { return; } $output = $before; for ($i = 1; $i < $numpages + 1; $i++) { $j = str_replace('%', $i, $pagelink); $output .= ' '; if ($i != $page || !$more && 1 == $page) { $output .= "<li>" . _wp_link_page($i) . "{$link_before}{$j}{$link_after}</a></li>"; } else { // highlight the current page // not sure if we need $link_before and $link_after $output .= "<li><span class=\"page-numbers current\">{$link_before}{$j}{$link_after}</span></li>"; } } $echo and print $output . $after; return $output . $after; }
function wm_nextpage_table_of_contents($content) { //Helper variables global $page, $numpages, $multipage, $post; $title_text = apply_filters('wmhook_wm_nextpage_table_of_contents_title_text', sprintf(__('"%s" table of contents', 'wm_domain'), get_the_title())); $title = apply_filters('wmhook_wm_nextpage_table_of_contents_title', '<h2 class="screen-reader-text">' . $title_text . '</h2>'); //Requirements check if (!$multipage || !is_single()) { return $content; } $atts = apply_filters('wmhook_wm_nextpage_table_of_contents_atts', array('disable_first' => true, 'links' => array(1 => '<li>' . _wp_link_page(1) . get_the_title() . '</a></li>'), 'post_content' => isset($post->post_content) ? $post->post_content : '', 'tag' => 'h2')); //Post part counter $i = 0; //Prepare output $atts['post_content'] = explode('<!--nextpage-->', $atts['post_content']); //Get post parts titles foreach ($atts['post_content'] as $part) { $i++; if (absint($atts['disable_first']) < $i) { //Get heading from post part preg_match('/<' . $atts['tag'] . '(.*?)>(.*?)<\\/' . $atts['tag'] . '>/', $part, $matches); //Fallback to "Part #" if no post part heading found if (!isset($matches[2]) || !$matches[2]) { $matches[2] = sprintf(__('Part %d', 'wm_domain'), $i); } $atts['links'][$i] = apply_filters('wmhook_wm_nextpage_table_of_contents_part', '<li>' . _wp_link_page($i) . $matches[2] . '</a></li>', $matches, $i); } } //Set active part in table of contents if (isset($atts['links'][$page])) { $atts['links'][$page] = str_replace('<li>', '<li class="active">', $atts['links'][$page]); } //Add table of contents into the post/page content $atts['links'] = implode('', $atts['links']); $links = apply_filters('wmhook_wm_nextpage_table_of_contents_links', array('before' => 1 === $page ? '<div class="post-table-of-contents top" title="' . esc_attr(strip_tags($title_text)) . '">' . $title . '<ol>' . $atts['links'] . '</ol></div>' : '', 'after' => '<div class="post-table-of-contents bottom" title="' . esc_attr(strip_tags($title_text)) . '">' . $title . '<ol>' . $atts['links'] . '</ol></div>'), $atts); $content = $links['before'] . $content . $links['after']; //Output return apply_filters('wmhook_wm_nextpage_table_of_contents_output', $content); }
/** * the function which will be called every time on finding shortcode in post content * @global type $post the current post with pagination * @param type $atts the shortcode attributes * @param type $content the shortcode content * @return type generated html content */ public function nextpage_shortcode($atts, $content) { if (is_singular()) { global $post; $loading_type = esc_attr(get_post_meta($post->ID, '_acp_loading_type', true)); if ($loading_type) { $this->loading_type = intval($loading_type); } $btn_visual_style = intval($this->acp_options_serialized->acp_buttons_visual_style); $current_post_button_style = esc_attr(get_post_meta($post->ID, '_acp_button_style', true)); if ($current_post_button_style) { $btn_visual_style = intval($current_post_button_style); } $pages_count; $this->query_page = get_query_var('page') ? get_query_var('page') : 1; $this->page++; extract(shortcode_atts(array('title' => __('Title', ACP_Core::$TEXT_DOMAIN)), $atts), EXTR_OVERWRITE); $link; $anchor = ''; if ($this->page == 1) { $link = get_permalink(); } else { $link = get_permalink() . '&page=' . $this->page; } $link = _wp_link_page($this->page); $pattern = '\\[(\\[?)(nextpage)(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*+(?:\\[(?!\\/\\2\\])[^\\[]*+)*+)\\[\\/\\2\\])?)(\\]?)'; $link = substr_replace($link, $anchor . '">', -2); if (preg_match_all('/' . $pattern . '/s', $post->post_content, $matches) && array_key_exists(2, $matches) && in_array('nextpage', $matches[2])) { $pages_count = 0; foreach ($matches[2] as $match) { if ($match == 'nextpage') { $pages_count++; } } } $html = ''; $active_item = ''; if ($this->curr_page === $this->query_page - 1) { $this->shortcode_content = $content; $active_item = ' active'; $link = ''; } if ($btn_visual_style === 4) { $this->shorcodes_array[] = array('title' => $title, 'shortcode_content' => $pages_count == 1 ? $content : $this->shortcode_content, 'curr_page' => $this->curr_page, 'url_page_number' => $this->page, 'link' => $link); if ($pages_count === count($this->shorcodes_array)) { $html = $this->build_only_prev_next_pagination_html($this->shorcodes_array, $this->loading_type); } } else { if (!$this->acp_options_serialized->acp_buttons_prev_next) { if ($pages_count == 1) { $html = $this->build_pagination_html($this->curr_page, $pages_count, $active_item, $this->page, $link, trim($title), do_shortcode($content)); } else { $html = $this->build_pagination_html($this->curr_page, $pages_count, $active_item, $this->page, $link, trim($title), do_shortcode($this->shortcode_content)); } } else { $this->shorcodes_array[] = array('title' => $title, 'shortcode_content' => $pages_count == 1 ? $content : $this->shortcode_content, 'curr_page' => $this->curr_page, 'url_page_number' => $this->page, 'link' => $link); if ($pages_count === count($this->shorcodes_array)) { $html = $this->build_prev_next_pagination_html($this->shorcodes_array); } } } $this->curr_page++; return $html; } else { return do_shortcode($content); } }
/** * Link Pages * @author toscha * @since 2.0.0 * @link http://wordpress.stackexchange.com/questions/14406/how-to-style-current-page-number-wp-link-pages * @param array $args * @return void * Modification of wp_link_pages() with an extra element to highlight the current page. */ function ap_core_link_pages($args = array()) { $defaults = array('before' => '<p>' . __('Pages:', 'museum-core'), 'after' => '</p>', 'before_link' => '', 'after_link' => '', 'current_before' => '', 'current_after' => '', 'link_before' => '', 'link_after' => '', 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; if (!$multipage) { return; } $output = $before; for ($i = 1; $i < $numpages + 1; $i++) { $j = str_replace('%', $i, $pagelink); $output .= ' '; if ($i != $page || !$more && 1 == $page) { $output .= "{$before_link}" . _wp_link_page($i) . "{$link_before}{$j}{$link_after}</a>{$after_link}"; } else { $output .= "{$current_before}{$link_before}<a>{$j}</a>{$link_after}{$current_after}"; } } print wp_kses_post($output) . $after; }
$params = $get; $params[$key] = $current + $x + 1; ?> <li class="number"><?php echo _wp_link_page($current + $x + 1) . ($current + $x + 1); ?> </a></li> <?php } } /** * Next Link */ // anchor classes and target $classes = array('copy', 'next'); $params = $get; $params[$key] = $current + 1; if ($current === $pages) { array_push($classes, 'disabled'); } ?> <li class="<?php echo implode(' ', $classes); ?> "><?php echo _wp_link_page($current + 1) . $next; ?> </a></li> </ul> <?php }
/** * The formatted output of a list of pages. * * Displays page links for paginated posts (i.e. includes the <!--nextpage-->. * Quicktag one or more times). This tag must be within The Loop. * * The defaults for overwriting are: * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to * each bookmarks. * 'after' - Default is '</p>' (string). The html or text to append to each * bookmarks. * 'link_before' - Default is '' (string). The html or text to prepend to each * Pages link inside the <a> tag. Also prepended to the current item, which * is not linked. * 'link_after' - Default is '' (string). The html or text to append to each * Pages link inside the <a> tag. Also appended to the current item, which * is not linked. * 'next_or_number' - Default is 'number' (string). Indicates whether page * numbers should be used. Valid values are number and next. * 'separator' - Default is ' ' (string). Text used between pagination links. * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page. * of the bookmark. * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to * previous page, if available. * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in * the parameter string will be replaced with the page number, so Page % * generates "Page 1", "Page 2", etc. Defaults to %, just the page number. * 'echo' - Default is 1 (integer). When not 0, this triggers the HTML to be * echoed and then returned. * * @since 1.2.0 * * @param string|array $args Optional. Overwrite the defaults. * @return string Formatted output in HTML. */ function wp_link_pages($args = '') { $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); /** * Filter the arguments used in retrieving page links for paginated posts. * * @since 3.0.0 * * @param array $r An array of arguments for page links for paginated posts. */ $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; for ($i = 1; $i <= $numpages; $i++) { $link = $link_before . str_replace('%', $i, $pagelink) . $link_after; if ($i != $page || !$more && 1 == $page) { $link = _wp_link_page($i) . $link . '</a>'; } /** * Filter the HTML output of individual page number links. * * @since 3.6.0 * * @param string $link The page number HTML output. * @param int $i Page number for paginated posts' page links. */ $link = apply_filters('wp_link_pages_link', $link, $i); $output .= $separator . $link; } $output .= $after; } elseif ($more) { $output .= $before; $i = $page - 1; if ($i) { $link = _wp_link_page($i) . $link_before . $previouspagelink . $link_after . '</a>'; /** This filter is documented in wp-includes/post-template.php */ $link = apply_filters('wp_link_pages_link', $link, $i); $output .= $separator . $link; } $i = $page + 1; if ($i <= $numpages) { $link = _wp_link_page($i) . $link_before . $nextpagelink . $link_after . '</a>'; /** This filter is documented in wp-includes/post-template.php */ $link = apply_filters('wp_link_pages_link', $link, $i); $output .= $separator . $link; } $output .= $after; } } /** * Filter the HTML output of page links for paginated posts. * * @since 3.6.0 * * @param string $output HTML output of paginated posts' page links. * @param array $args An array of arguments. */ $output = apply_filters('wp_link_pages', $output, $args); if ($echo) { echo $output; } return $output; }
function wm_nextpage_table_of_contents($content) { //Helper variables global $page, $numpages, $multipage, $post; //translators: %s will be replaced with parted post title. Copy it, do not translate. $title_text = apply_filters('wmhook_wm_nextpage_table_of_contents_title_text', sprintf(_x('"%s" table of contents', 'Parted/paginated post table of content title.', 'wm_domain'), get_the_title())); $title = apply_filters('wmhook_wm_nextpage_table_of_contents_title', '<h2 class="screen-reader-text">' . $title_text . '</h2>'); //Requirements check if (!$multipage || !is_single()) { return $content; } $args = apply_filters('wmhook_wm_nextpage_table_of_contents_atts', array('disable_first' => true, 'links' => array(), 'post_content' => isset($post->post_content) ? $post->post_content : '', 'tag' => 'h2')); //Post part counter $i = 0; //Prepare output $args['post_content'] = explode('<!--nextpage-->', $args['post_content']); //Get post parts titles foreach ($args['post_content'] as $part) { //Current post part number $i++; //Get title for post part if ($args['disable_first'] && 1 === $i) { $part_title = the_title_attribute('echo=0'); } else { preg_match('/<' . $args['tag'] . '(.*?)>(.*?)<\\/' . $args['tag'] . '>/', $part, $matches); if (!isset($matches[2]) || !$matches[2]) { $part_title = sprintf(__('Page %s', 'wm_domain'), $i); } else { $part_title = $matches[2]; } } //Set post part class if ($page === $i) { $class = ' class="current"'; } elseif ($page > $i) { $class = ' class="passed"'; } else { $class = ''; } //Post part item output $args['links'][$i] = apply_filters('wmhook_wm_nextpage_table_of_contents_part', '<li' . $class . '>' . _wp_link_page($i) . $part_title . '</a></li>', $i, $part_title, $class, $args); } //Add table of contents into the post/page content $args['links'] = implode('', $args['links']); $links = apply_filters('wmhook_wm_nextpage_table_of_contents_links', array('before' => 1 === $page ? '<div class="post-table-of-contents top" title="' . esc_attr(strip_tags($title_text)) . '">' . $title . '<ol>' . $args['links'] . '</ol></div>' : '', 'after' => '<div class="post-table-of-contents bottom" title="' . esc_attr(strip_tags($title_text)) . '">' . $title . '<ol>' . $args['links'] . '</ol></div>'), $args); $content = $links['before'] . $content . $links['after']; //Output return apply_filters('wmhook_wm_nextpage_table_of_contents_output', $content, $args); }
function counterpoint_link_pages_args($args) { $cp_defaults = array('next_or_number' => 'next_and_number', 'before' => '<nav class="post-pagination">', 'after' => '</nav>', 'pagelink' => '<span>%</span>', 'nextpagelink' => '<span>' . __('Next', 'counterpoint') . '</span>', 'previouspagelink' => '<span>' . __('Prev', 'counterpoint') . '</span>'); $args = wp_parse_args($cp_defaults, $args); // overwrites $args with $cp_defaults // if ($args['next_or_number'] == 'next_and_number') { global $page, $numpages, $multipage, $more; $args['next_or_number'] = 'number'; $prev = ''; $next = ''; if ($multipage && $more) { $i = $page - 1; if ($i && $more) { $prev .= _wp_link_page($i); $prev .= $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>'; } $i = $page + 1; if ($i <= $numpages && $more) { $next .= _wp_link_page($i); $next .= $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'; } } $args['before'] = $args['before'] . $prev; $args['after'] = $next . $args['after']; } return $args; }
/** * @param null $post * * @return array */ function get_prev_next_links($post = null) { $prev = $next = ''; $page = $this->get_page_number(); if (is_home() || is_archive() || is_paged()) { global $wp_query; $max_page = $wp_query->max_num_pages; if ($page > 1) { $prev = get_previous_posts_page_link(); } if ($page < $max_page) { $paged = $GLOBALS['paged']; if (!is_single()) { if (!$paged) { $paged = 1; } $nextpage = intval($paged) + 1; if (!$max_page || $max_page >= $nextpage) { $next = get_pagenum_link($nextpage); } } } } else { if (is_page() || is_single()) { $numpages = 1; $multipage = 0; $page = get_query_var('page'); if (!$page) { $page = 1; } if (is_single() || is_page() || is_feed()) { $more = 1; } $content = $post->post_content; if (false !== strpos($content, '<!--nextpage-->')) { if ($page > 1) { $more = 1; } $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content); $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content); $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content); // Ignore nextpage at the beginning of the content. if (0 === strpos($content, '<!--nextpage-->')) { $content = substr($content, 15); } $pages = explode('<!--nextpage-->', $content); $numpages = count($pages); if ($numpages > 1) { $multipage = 1; } } if (!empty($page)) { if ($page > 1) { $prev = _wp_link_page($page - 1); } if ($page + 1 <= $numpages) { $next = _wp_link_page($page + 1); } } if (!empty($prev)) { $prev = $this->substr($prev, 9, -2); } if (!empty($next)) { $next = $this->substr($next, 9, -2); } } } return array('prev' => $prev, 'next' => $next); }
function bb_add_next_and_number($args) { if ($args['next_or_number'] == 'next_and_number') { global $page, $numpages, $multipage, $more, $pagenow; $args['next_or_number'] = 'number'; $prev = ''; $next = ''; if ($multipage) { if ($more) { $i = $page - 1; if ($i && $more) { $prev .= _wp_link_page($i); $prev .= $args['link_before'] . $args['previouspagelink'] . $args['link_after'] . '</a>'; } $i = $page + 1; if ($i <= $numpages && $more) { $next .= _wp_link_page($i); $next .= $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'; } } } $args['before'] = $args['before'] . $prev; $args['after'] = $next . $args['after']; } return $args; }
function wp_head() { if (is_feed()) { return; } if (aioseop_mrt_exclude_this_page()) { return; } static $aioseop_dup_counter = 0; $aioseop_dup_counter++; if ($aioseop_dup_counter > 1) { echo "\n<!-- Debug Warning: All in One SEO Pack Pro meta data was included again from " . current_filter() . " filter. Called {$aioseop_dup_counter} times! -->\n"; return; } if (is_home() && !is_front_page()) { $post = $this->get_blog_page(); } else { $post = $this->get_queried_object(); } global $wp_query; global $aioseop_options; $meta_string = null; $description = ''; if (is_single() || is_page()) { $aiosp_disable = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_disable', true))); if ($aiosp_disable) { return; } if (empty($aioseop_options['aiosp_enablecpost'])) { $wp_post_types = get_post_types(array('_builtin' => true)); // don't display meta if SEO isn't enabled on custom post types -- pdb if (!is_singular($wp_post_types) && !is_front_page()) { return; } } else { if (!empty($aioseop_options['aiosp_cpostadvanced'])) { $wp_post_types = $aioseop_options['aiosp_cpostactive']; if (empty($aioseop_options['aiosp_cpostactive'])) { return; } if (!is_singular($wp_post_types) && !is_front_page()) { return; } } } } $force_rewrites = 1; if (isset($aioseop_options['aiosp_force_rewrites'])) { $force_rewrites = $aioseop_options['aiosp_force_rewrites']; } if (!empty($aioseop_options['aiosp_rewrite_titles']) && $force_rewrites) { // make the title rewrite as short as possible if (function_exists('ob_list_handlers')) { $active_handlers = ob_list_handlers(); } else { $active_handlers = array(); } if (sizeof($active_handlers) > 0 && $this->strtolower($active_handlers[sizeof($active_handlers) - 1]) == $this->strtolower('All_in_One_SEO_Pack::output_callback_for_title')) { ob_end_flush(); } else { $this->log("another plugin interfering?"); // if we get here there *could* be trouble with another plugin :( $this->ob_start_detected = true; if (function_exists('ob_list_handlers')) { foreach (ob_list_handlers() as $handler) { $this->log("detected output handler {$handler}"); } } } } echo "\n<!-- All in One SEO Pack {$this->version} by Michael Torbert of Semper Fi Web Design"; if ($this->ob_start_detected) { echo "ob_start_detected "; } echo "[{$this->title_start},{$this->title_end}] "; echo "-->\n"; $is_front_page = is_front_page(); $is_front_page_keywords = $is_front_page && $aioseop_options['aiosp_home_keywords'] && !$this->is_static_posts_page() || $this->is_static_front_page(); $blog_page = $this->get_blog_page($post); if ($is_front_page_keywords) { $keywords = trim($this->internationalize($aioseop_options['aiosp_home_keywords'])); } elseif ($this->is_static_posts_page() && !$aioseop_options['aiosp_dynamic_postspage_keywords']) { // and if option = use page set keywords instead of keywords from recent posts $keywords = stripslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_keywords", true))); } elseif (!empty($blog_page) && !$aioseop_options['aiosp_dynamic_postspage_keywords']) { $keywords = stripslashes($this->internationalize(get_post_meta($blog_page->ID, "_aioseop_keywords", true))); } else { $keywords = $this->get_all_keywords(); } if (is_category() && $this->show_page_description()) { $description = $this->internationalize(category_description()); } elseif (is_tag() && $this->show_page_description()) { $description = $this->internationalize(tag_description()); } elseif (is_tax() && $this->show_page_description()) { $description = $this->internationalize(term_description()); } elseif (is_author() && $this->show_page_description()) { $description = $this->internationalize(get_the_author_meta('description')); } else { if ($is_front_page) { $description = trim(stripslashes($this->internationalize($aioseop_options['aiosp_home_description']))); } else { if (is_single() || is_page() || is_home() || $this->is_static_posts_page()) { $description = $this->get_aioseop_description($post); } } } /* if ( $this->is_static_front_page() ) $description = trim( stripslashes( $this->internationalize( $aioseop_options['aiosp_home_description'] ) ) ); elseif ( !empty( $blog_page ) ) $description = $this->get_post_description( $blog_page ); if ( empty( $description ) && is_object( $post ) && !is_archive() && empty( $blog_page ) ) $description = $this->get_post_description( $post ); $description = apply_filters( 'aioseop_description', $description ); */ if (isset($description) && $this->strlen($description) > $this->minimum_description_length && !($is_front_page && is_paged())) { $description = trim(strip_tags($description)); $description = str_replace('"', '"', $description); // replace newlines on mac / windows? $description = str_replace("\r\n", ' ', $description); // maybe linux uses this alone $description = str_replace("\n", ' ', $description); if (!isset($meta_string)) { $meta_string = ''; } // description format $description_format = $aioseop_options['aiosp_description_format']; if (!isset($description_format) || empty($description_format)) { $description_format = "%description%"; } $description = str_replace('%description%', apply_filters('aioseop_description_override', $description), $description_format); $description = str_replace('%blog_title%', get_bloginfo('name'), $description); $description = str_replace('%blog_description%', get_bloginfo('description'), $description); $description = str_replace('%wp_title%', $this->get_original_title(), $description); if ($aioseop_options['aiosp_can'] && is_attachment()) { $url = $this->aiosp_mrt_get_url($wp_query); if ($url) { $matches = array(); preg_match_all('/(\\d+)/', $url, $matches); if (is_array($matches)) { $uniqueDesc = join('', $matches[0]); } } $description .= ' ' . $uniqueDesc; } $meta_string .= sprintf("<meta name=\"description\" content=\"%s\" />\n", $description); } $keywords = apply_filters('aioseop_keywords', $keywords); if (isset($aioseop_options['aiosp_togglekeywords'])) { $togglekeywords = $aioseop_options['aiosp_togglekeywords']; } else { $togglekeywords = 0; } if (isset($keywords) && $togglekeywords == 0 && !empty($keywords) && !(is_home() && is_paged())) { if (isset($meta_string)) { $meta_string .= "\n"; } $keywords = wp_filter_nohtml_kses(str_replace('"', '', $keywords)); $meta_string .= sprintf("<meta name=\"keywords\" content=\"%s\" />\n", $keywords); } $is_tag = is_tag(); $robots_meta = ''; if (is_category() && !empty($aioseop_options['aiosp_category_noindex']) || !is_category() && is_archive() && !$is_tag && (is_date() && !empty($aioseop_options['aiosp_archive_date_noindex']) || is_author() && !empty($aioseop_options['aiosp_archive_author_noindex'])) || $is_tag && !empty($aioseop_options['aiosp_tags_noindex']) || is_search() && !empty($aioseop_options['aiosp_search_noindex'])) { $robots_meta = 'noindex,follow'; } else { if (is_single() || is_page()) { $post_type = get_post_type(); $aiosp_noindex = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_noindex', true))); $aiosp_nofollow = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_nofollow', true))); $aiosp_noodp = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_noodp', true))); $aiosp_noydir = htmlspecialchars(stripslashes(get_post_meta($post->ID, '_aioseop_noydir', true))); if ($aiosp_noindex || $aiosp_nofollow || $aiosp_noodp || $aiosp_noydir || !empty($aioseop_options['aiosp_cpostnoindex']) || !empty($aioseop_options['aiosp_cpostnofollow'])) { $noindex = "index"; $nofollow = "follow"; $noodp = $noydir = ''; if ($aiosp_noindex == 'on' || $aiosp_noindex == '' && !empty($aioseop_options['aiosp_cpostnoindex']) && in_array($post_type, $aioseop_options['aiosp_cpostnoindex'])) { $noindex = "no" . $noindex; } if ($aiosp_nofollow == 'on' || $aiosp_nofollow == '' && !empty($aioseop_options['aiosp_cpostnofollow']) && in_array($post_type, $aioseop_options['aiosp_cpostnofollow'])) { $nofollow = "no" . $nofollow; } if ($aiosp_noodp) { $nofollow .= ',noodp'; } if ($aiosp_noydir) { $nofollow .= ',noydir'; } $robots_meta = $noindex . ',' . $nofollow; } } } $robots_meta = apply_filters('aioseop_robots_meta', $robots_meta); if (!empty($robots_meta)) { $meta_string .= '<meta name="robots" content="' . esc_attr($robots_meta) . '" />' . "\n"; } if ($is_front_page) { foreach (array('google' => 'google-site-verification', 'bing' => 'msvalidate.01', 'pinterest' => 'p:domain_verify') as $k => $v) { if (!empty($aioseop_options["aiosp_{$k}_verify"])) { $meta_string .= '<meta name="' . $v . '" content="' . trim(strip_tags($aioseop_options["aiosp_{$k}_verify"])) . '" />' . "\n"; } } } foreach (array('page_meta', 'post_meta', 'home_meta', 'front_meta') as $meta) { if (!empty($aioseop_options["aiosp_{$meta}_tags"])) { ${$meta} = html_entity_decode(stripslashes($aioseop_options["aiosp_{$meta}_tags"])); } else { ${$meta} = ''; } } if (is_page() && isset($page_meta) && !empty($page_meta) && (!$is_front_page || empty($front_meta))) { if (isset($meta_string)) { $meta_string .= "\n"; } $meta_string .= $page_meta; } if (is_single() && isset($post_meta) && !empty($post_meta)) { if (isset($meta_string)) { $meta_string .= "\n"; } $meta_string .= $post_meta; } $googleplus = $publisher = $author = ''; if (!empty($post) && isset($post->post_author) && empty($aioseop_options['aiosp_google_disable_profile'])) { $googleplus = get_the_author_meta('googleplus', $post->post_author); } if (empty($googleplus) && !empty($aioseop_options['aiosp_google_publisher'])) { $googleplus = $aioseop_options['aiosp_google_publisher']; } if ($is_front_page && !empty($aioseop_options['aiosp_google_publisher'])) { $publisher = $aioseop_options['aiosp_google_publisher']; } $publisher = apply_filters('aioseop_google_publisher', $publisher); if (!empty($publisher)) { $meta_string = '<link rel="publisher" href="' . esc_url($publisher) . '" />' . "\n" . $meta_string; } if (is_singular() && !empty($googleplus)) { $author = $googleplus; } else { if (!empty($aioseop_options['aiosp_google_publisher'])) { $author = $aioseop_options['aiosp_google_publisher']; } } $author = apply_filters('aioseop_google_author', $author); if (!empty($author)) { $meta_string = '<link rel="author" href="' . esc_url($author) . '" />' . "\n" . $meta_string; } if ($is_front_page && !empty($front_meta)) { if (isset($meta_string)) { $meta_string .= "\n"; } $meta_string .= $front_meta; } else { if (is_home() && !empty($home_meta)) { if (isset($meta_string)) { $meta_string .= "\n"; } $meta_string .= $home_meta; } } $prev = $next = ''; if (is_home() || is_archive() || is_paged()) { global $wp_query; $max_page = $wp_query->max_num_pages; $page = $this->get_page_number(); if ($page > 1) { $prev = get_previous_posts_page_link(); } if ($page < $max_page) { // $next = get_next_posts_page_link( $max_page ); $paged = $GLOBALS['paged']; if (!is_single()) { if (!$paged) { $paged = 1; } $nextpage = intval($paged) + 1; if (!$max_page || $max_page >= $nextpage) { $next = get_pagenum_link($nextpage); } } } } else { if (is_page() || is_single()) { $numpages = 1; $multipage = 0; $page = get_query_var('page'); if (!$page) { $page = 1; } if (is_single() || is_page() || is_feed()) { $more = 1; } $content = $post->post_content; if (false !== strpos($content, '<!--nextpage-->')) { if ($page > 1) { $more = 1; } $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content); $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content); $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content); // Ignore nextpage at the beginning of the content. if (0 === strpos($content, '<!--nextpage-->')) { $content = substr($content, 15); } $pages = explode('<!--nextpage-->', $content); $numpages = count($pages); if ($numpages > 1) { $multipage = 1; } } if (!empty($page)) { if ($page > 1) { $prev = _wp_link_page($page - 1); } if ($page + 1 <= $numpages) { $next = _wp_link_page($page + 1); } } if (!empty($prev)) { $prev = $this->substr($prev, 9, -2); } if (!empty($next)) { $next = $this->substr($next, 9, -2); } } } $prev = apply_filters('aioseop_prev_link', $prev); $next = apply_filters('aioseop_next_link', $next); if (!empty($prev)) { $meta_string .= "<link rel='prev' href='" . esc_url($prev) . "' />\n"; } if (!empty($next)) { $meta_string .= "<link rel='next' href='" . esc_url($next) . "' />\n"; } if ($meta_string != null) { echo "{$meta_string}\n"; } if ($aioseop_options['aiosp_can'] && ($url = $this->aiosp_mrt_get_url($wp_query))) { $url = apply_filters('aioseop_canonical_url', $url); if (!empty($url)) { echo '<link rel="canonical" href="' . esc_url($url) . '" />' . "\n"; } } do_action('aioseop_modules_wp_head'); echo "<!-- /all in one seo pack -->\n"; }
/** * The formatted output of a list of pages. * * Displays page links for paginated posts (i.e. includes the <!--nextpage-->. * Quicktag one or more times). This tag must be within The Loop. * * The defaults for overwriting are: * 'before' - Default is '<p> Pages:' (string). The html or text to prepend to * each bookmarks. * 'after' - Default is '</p>' (string). The html or text to append to each * bookmarks. * 'link_before' - Default is '' (string). The html or text to prepend to each * Pages link inside the <a> tag. Also prepended to the current item, which * is not linked. * 'link_after' - Default is '' (string). The html or text to append to each * Pages link inside the <a> tag. Also appended to the current item, which * is not linked. * 'next_or_number' - Default is 'number' (string). Indicates whether page * numbers should be used. Valid values are number and next. * 'separator' - Default is ' ' (string). Text used between pagination links. * 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page. * of the bookmark. * 'previouspagelink' - Default is 'Previous Page' (string). Text for link to * previous page, if available. * 'pagelink' - Default is '%' (String).Format string for page numbers. The % in * the parameter string will be replaced with the page number, so Page % * generates "Page 1", "Page 2", etc. Defaults to %, just the page number. * 'echo' - Default is 1 (integer). When not 0, this triggers the HTML to be * echoed and then returned. * * @since 1.2.0 * * @param string|array $args Optional. Overwrite the defaults. * @return string Formatted output in HTML. */ function wp_link_pages($args = '') { $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1); $r = wp_parse_args($args, $defaults); $r = apply_filters('wp_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= $before; for ($i = 1; $i <= $numpages; $i++) { $link = $link_before . str_replace('%', $i, $pagelink) . $link_after; if ($i != $page || !$more && 1 == $page) { $link = _wp_link_page($i) . $link . '</a>'; } $link = apply_filters('wp_link_pages_link', $link, $i); $output .= $separator . $link; } $output .= $after; } elseif ($more) { $output .= $before; $i = $page - 1; if ($i) { $link = _wp_link_page($i) . $link_before . $previouspagelink . $link_after . '</a>'; $link = apply_filters('wp_link_pages_link', $link, $i); $output .= $separator . $link; } $i = $page + 1; if ($i <= $numpages) { $link = _wp_link_page($i) . $link_before . $nextpagelink . $link_after . '</a>'; $link = apply_filters('wp_link_pages_link', $link, $i); $output .= $separator . $link; } $output .= $after; } } $output = apply_filters('wp_link_pages', $output, $args); if ($echo) { echo $output; } return $output; }
function avia_post_pagination_link($link) { $url = preg_replace('!">$!', '', _wp_link_page($link)); $url = preg_replace('!^<a href="!', '', $url); return $url; }
/** * Displays page links for paginated posts * * It's basically the wp_link_pages() function, altered to fit to the Bootstrap * markup needs for paginations (unordered list). * @see wp_link_pages() * * @author Konstantin Obenland * @since 1.1.0 - 09.03.2012 * * @param array $args * * @return string */ function the_bootstrap_link_pages($args = array()) { wp_link_pages(array('echo' => 0)); $defaults = array('next_or_number' => 'number', 'nextpagelink' => __('Next page', 'the-bootstrap'), 'previouspagelink' => __('Previous page', 'the-bootstrap'), 'pagelink' => '%', 'echo' => true); $r = wp_parse_args($args, $defaults); $r = apply_filters('the_bootstrap_link_pages_args', $r); extract($r, EXTR_SKIP); global $page, $numpages, $multipage, $more, $pagenow; $output = ''; if ($multipage) { if ('number' == $next_or_number) { $output .= '<nav class="pagination clear"><ul><li><span class="dots">' . __('Pages:', 'the-bootstrap') . '</span></li>'; for ($i = 1; $i < $numpages + 1; $i++) { $j = str_replace('%', $i, $pagelink); if ($i != $page || !$more && $page != 1) { $output .= '<li>' . _wp_link_page($i) . $j . '</a></li>'; } if ($i == $page) { $output .= '<li class="current"><span>' . $j . '</span></li>'; } } $output .= '</ul></nav>'; } else { if ($more) { $output .= '<nav class="pagination clear"><ul><li><span class="dots">' . __('Pages:', 'the-bootstrap') . '</span></li>'; $i = $page - 1; if ($i && $more) { $output .= '<li>' . _wp_link_page($i) . $previouspagelink . '</a></li>'; } $i = $page + 1; if ($i <= $numpages && $more) { $output .= '<li>' . _wp_link_page($i) . $nextpagelink . '</a></li>'; } $output .= '</ul></nav>'; } } } if ($echo) { echo $output; } return $output; }
/** * The formatted output of a list of pages. * * Displays page links for paginated posts (i.e. includes the <!--nextpage-->. * Quicktag one or more times). This tag must be within The Loop. * * @since 1.2.0 * * @global int $page * @global int $numpages * @global int $multipage * @global int $more * * @param string|array $args { * Optional. Array or string of default arguments. * * @type string $before HTML or text to prepend to each link. Default is `<p> Pages:`. * @type string $after HTML or text to append to each link. Default is `</p>`. * @type string $link_before HTML or text to prepend to each link, inside the `<a>` tag. * Also prepended to the current item, which is not linked. Default empty. * @type string $link_after HTML or text to append to each Pages link inside the `<a>` tag. * Also appended to the current item, which is not linked. Default empty. * @type string $next_or_number Indicates whether page numbers should be used. Valid values are number * and next. Default is 'number'. * @type string $separator Text between pagination links. Default is ' '. * @type string $nextpagelink Link text for the next page link, if available. Default is 'Next Page'. * @type string $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'. * @type string $pagelink Format string for page numbers. The % in the parameter string will be * replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc. * Defaults to '%', just the page number. * @type int|bool $echo Whether to echo or not. Accepts 1|true or 0|false. Default 1|true. * } * @return string Formatted output in HTML. */ function wp_link_pages($args = '') { global $page, $numpages, $multipage, $more; $defaults = array('before' => '<p>' . __('Pages:'), 'after' => '</p>', 'link_before' => '', 'link_after' => '', 'next_or_number' => 'number', 'separator' => ' ', 'nextpagelink' => __('Next page'), 'previouspagelink' => __('Previous page'), 'pagelink' => '%', 'echo' => 1); $params = wp_parse_args($args, $defaults); /** * Filters the arguments used in retrieving page links for paginated posts. * * @since 3.0.0 * * @param array $params An array of arguments for page links for paginated posts. */ $r = apply_filters('wp_link_pages_args', $params); $output = ''; if ($multipage) { if ('number' == $r['next_or_number']) { $output .= $r['before']; for ($i = 1; $i <= $numpages; $i++) { $link = $r['link_before'] . str_replace('%', $i, $r['pagelink']) . $r['link_after']; if ($i != $page || !$more && 1 == $page) { $link = _wp_link_page($i) . $link . '</a>'; } /** * Filters the HTML output of individual page number links. * * @since 3.6.0 * * @param string $link The page number HTML output. * @param int $i Page number for paginated posts' page links. */ $link = apply_filters('wp_link_pages_link', $link, $i); // Use the custom links separator beginning with the second link. $output .= 1 === $i ? ' ' : $r['separator']; $output .= $link; } $output .= $r['after']; } elseif ($more) { $output .= $r['before']; $prev = $page - 1; if ($prev > 0) { $link = _wp_link_page($prev) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>'; /** This filter is documented in wp-includes/post-template.php */ $output .= apply_filters('wp_link_pages_link', $link, $prev); } $next = $page + 1; if ($next <= $numpages) { if ($prev) { $output .= $r['separator']; } $link = _wp_link_page($next) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>'; /** This filter is documented in wp-includes/post-template.php */ $output .= apply_filters('wp_link_pages_link', $link, $next); } $output .= $r['after']; } } /** * Filters the HTML output of page links for paginated posts. * * @since 3.6.0 * * @param string $output HTML output of paginated posts' page links. * @param array $args An array of arguments. */ $html = apply_filters('wp_link_pages', $output, $args); if ($r['echo']) { echo $html; } return $html; }
/** * Built-in pagination for galleries * * @since 1.6.5.1 */ function file_gallery_do_pagination($total = 0, $page = 0) { if (0 < $total && 0 < $page) { remove_query_arg('page'); $options = get_option('file_gallery'); $out = array('<span class="current">' . $page . '</span>'); if (!isset($options['pagination_count']) || empty($options['pagination_count']) || 0 >= $options['pagination_count']) { $limit = 9; } else { $limit = $options['pagination_count']; } $c = 0; $l = $limit; $end = false; $start = false; $current = $page; $sides = ($limit - 1) / 2; $sl = ceil($sides); $sr = floor($sides); // skip to first page link if ($limit - $sl < $current) { $start = true; } // skip to last page link if ($total - $sr > $current) { $end = true; } // left side if (1 < $current) { $current--; while (0 < $current && 0 < $sl) { array_unshift($out, str_replace('<a ', '<a class="page"', _wp_link_page($current)) . $current . '</a>'); $current--; $sl--; $limit--; } $c = $current; } $current = $page + 1; $sr += $sl; // right side while ($current <= $total && 0 < $sr) { array_push($out, str_replace('<a ', '<a class="page"', _wp_link_page($current)) . $current . '</a>'); $current++; $sr--; $limit--; } // leftovers while (1 < $limit && 0 < $c) { array_unshift($out, str_replace('<a ', '<a class="page"', _wp_link_page($c)) . $c . '</a>'); $c--; $limit--; } if ($start) { array_unshift($out, str_replace('<a ', '<a title="' . __('Skip to first page', 'file-gallery') . '" class="page"', _wp_link_page(1)) . '«</a>'); } if ($end) { array_push($out, str_replace('<a ', '<a title="' . __('Skip to last page', 'file-gallery') . '" class="page"', _wp_link_page($total)) . '»</a>'); } if ('rtl' == get_bloginfo('text_direction')) { $out = array_reverse($out); } return '<div class="wp-pagenavi">' . "\n" . implode("\n", $out) . "\n</div>"; } return ''; }