Ticket #16973: 16973.2.diff
File 16973.2.diff, 4.4 KB (added by , 14 years ago) |
---|
-
wp-includes/post-template.php
618 618 * @return string Formatted output in HTML. 619 619 */ 620 620 function wp_link_pages($args = '') { 621 global $page, $numpages, $multipage, $more, $pagenow; 622 623 if ( !$multipage ) 624 return false; 625 621 626 $defaults = array( 622 627 'before' => '<p>' . __('Pages:'), 'after' => '</p>', 623 628 'link_before' => '', 'link_after' => '', … … 630 635 $r = apply_filters( 'wp_link_pages_args', $r ); 631 636 extract( $r, EXTR_SKIP ); 632 637 633 global $page, $numpages, $multipage, $more, $pagenow;634 635 638 $output = ''; 636 if ( $multipage ) { 637 if ( 'number' == $next_or_number ) { 638 $output .= $before; 639 for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) { 640 $j = str_replace('%',$i,$pagelink); 641 $output .= ' '; 642 if ( ($i != $page) || ((!$more) && ($page==1)) ) { 643 $output .= _wp_link_page($i); 644 } 645 $output .= $link_before . $j . $link_after; 646 if ( ($i != $page) || ((!$more) && ($page==1)) ) 647 $output .= '</a>'; 639 640 if ( 'number' == $next_or_number ) { 641 $output .= $before; 642 for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) { 643 $j = str_replace('%',$i,$pagelink); 644 $output .= ' '; 645 if ( ($i != $page) || ((!$more) && ($page==1)) ) { 646 $output .= '<a href="' . esc_url( get_multipage_link( $i ) ) . '">'; 648 647 } 649 $output .= $after; 650 } else { 651 if ( $more ) { 652 $output .= $before; 653 $i = $page - 1; 654 if ( $i && $more ) { 655 $output .= _wp_link_page($i); 656 $output .= $link_before. $previouspagelink . $link_after . '</a>'; 657 } 658 $i = $page + 1; 659 if ( $i <= $numpages && $more ) { 660 $output .= _wp_link_page($i); 661 $output .= $link_before. $nextpagelink . $link_after . '</a>'; 662 } 663 $output .= $after; 664 } 648 $output .= $link_before . $j . $link_after; 649 if ( ($i != $page) || ((!$more) && ($page==1)) ) 650 $output .= '</a>'; 665 651 } 652 $output .= $after; 653 } elseif ( $more ) { 654 $output .= $before; 655 $i = $page - 1; 656 if ( $i && $more ) { 657 $output .= '<a href="' . esc_url( get_multipage_link( $i ) ) . '">'; 658 $output .= $link_before. $previouspagelink . $link_after . '</a>'; 659 } 660 $i = $page + 1; 661 if ( $i <= $numpages && $more ) { 662 $output .= '<a href="' . esc_url( get_multipage_link( $i ) ) . '">'; 663 $output .= $link_before. $nextpagelink . $link_after . '</a>'; 664 } 665 $output .= $after; 666 666 } 667 667 668 668 if ( $echo ) … … 671 671 return $output; 672 672 } 673 673 674 /**675 * Helper function for wp_link_pages().676 *677 * @since 3.1.0678 * @access private679 *680 * @param int $i Page number.681 * @return string Link.682 */683 function _wp_link_page( $i ) {684 global $post, $wp_rewrite;685 686 if ( 1 == $i ) {687 $url = get_permalink();688 } else {689 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) )690 $url = add_query_arg( 'page', $i, get_permalink() );691 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID )692 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged');693 else694 $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged');695 }696 697 return '<a href="' . esc_url( $url ) . '">';698 }699 700 674 // 701 675 // Post-meta: Custom per-post fields. 702 676 // -
wp-includes/link-template.php
1532 1532 } 1533 1533 1534 1534 /** 1535 * Retrieve link to a multipage part. 1536 * 1537 * @since 3.2.0 1538 * 1539 * @param int $page Optional. 1540 * @return string 1541 */ 1542 function get_multipage_link( $page = 1 ) { 1543 global $post, $wp_rewrite; 1544 1545 if ( 1 == $page ) { 1546 $url = get_permalink(); 1547 } else { 1548 if ( '' == get_option('permalink_structure') || in_array( $post->post_status, array( 'draft', 'pending') ) ) 1549 $url = add_query_arg( 'page', $page, get_permalink() ); 1550 elseif ( 'page' == get_option( 'show_on_front' ) && get_option('page_on_front') == $post->ID ) 1551 $url = trailingslashit( get_permalink() ) . user_trailingslashit( $wp_rewrite->pagination_base . "/$page", 'single_paged' ); 1552 else 1553 $url = trailingslashit( get_permalink() ) . user_trailingslashit( $page, 'single_paged' ); 1554 } 1555 1556 return $url; 1557 } 1558 1559 /** 1535 1560 * Retrieve next posts pages link. 1536 1561 * 1537 1562 * Backported from 2.1.3 to 2.0.10.