Ticket #21266: 21271.diff
File 21271.diff, 6.6 KB (added by , 12 years ago) |
---|
-
wp-includes/post-template.php
607 607 * is not linked. 608 608 * 609 609 * @since 1.2.0 610 * @access private611 610 * 612 611 * @param string|array $args Optional. Overwrite the defaults. 613 612 * @return string Formatted output in HTML. 614 613 */ 615 function wp_link_pages( $args = '') {614 function wp_link_pages( $args = '' ) { 616 615 $defaults = array( 617 616 'before' => '<p>' . __('Pages:'), 'after' => '</p>', 618 617 'link_before' => '', 'link_after' => '', … … 676 675 * @return string Link. 677 676 */ 678 677 function _wp_link_page( $i ) { 679 global $post, $wp_rewrite; 680 681 if ( 1 == $i ) { 682 $url = get_permalink(); 683 } else { 684 if ( '' == get_option('permalink_structure') || in_array($post->post_status, array('draft', 'pending')) ) 685 $url = add_query_arg( 'page', $i, get_permalink() ); 686 elseif ( 'page' == get_option('show_on_front') && get_option('page_on_front') == $post->ID ) 687 $url = trailingslashit(get_permalink()) . user_trailingslashit("$wp_rewrite->pagination_base/" . $i, 'single_paged'); 688 else 689 $url = trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged'); 690 } 691 678 $url = get_post_page_link( $i ); 692 679 return '<a href="' . esc_url( $url ) . '">'; 693 680 } 694 681 -
wp-includes/link-template.php
1375 1375 * 1376 1376 * @param int $pagenum Optional. Page ID. 1377 1377 * @param bool $escape Optional. Whether to escape the URL for display, with esc_url(). Defaults to true. 1378 * Otherwise, prepares the URL with esc_url_raw(). 1378 * Otherwise, prepares the URL with esc_url_raw(). 1379 * @param string $url Optional. URL to modify. Defaults to null - in this case function will use $_SERVER['REQUEST_URI'] 1379 1380 * @return string 1380 1381 */ 1381 function get_pagenum_link( $pagenum = 1, $escape = true) {1382 function get_pagenum_link( $pagenum = 1, $escape = true, $url = null ) { 1382 1383 global $wp_rewrite; 1383 1384 1384 1385 $pagenum = (int) $pagenum; 1385 1386 1386 $request = remove_query_arg( 'paged' ); 1387 if ( !empty( $url ) ) 1388 $request = remove_query_arg( 'paged', $url ); 1389 else 1390 $request = remove_query_arg( 'paged' ); 1387 1391 1388 $home_root = parse_url(home_url()); 1389 $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : ''; 1392 if ( !empty( $url ) ) 1393 $home_root = home_url(); 1394 else { 1395 $home_root = parse_url( home_url() ); 1396 $home_root = ( isset( $home_root['path'] ) ) ? $home_root['path'] : ''; 1397 } 1390 1398 $home_root = preg_quote( $home_root, '|' ); 1391 1399 1392 $request = preg_replace( '|^'. $home_root . '|', '', $request);1393 $request = preg_replace( '|^/+|', '', $request);1400 $request = preg_replace( '|^'. $home_root . '|', '', $request ); 1401 $request = preg_replace( '|^/+|', '', $request ); 1394 1402 1395 1403 if ( !$wp_rewrite->using_permalinks() || is_admin() ) { 1396 1404 $base = trailingslashit( get_bloginfo( 'url' ) ); … … 1411 1419 $query_string = ''; 1412 1420 } 1413 1421 1414 $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request );1415 $request = preg_replace( '|^index\.php|', '', $request );1416 $request = ltrim( $request, '/');1422 $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request ); 1423 $request = preg_replace( '|^index\.php|', '', $request ); 1424 $request = ltrim( $request, '/' ); 1417 1425 1418 1426 $base = trailingslashit( get_bloginfo( 'url' ) ); 1419 1427 … … 1427 1435 $result = $base . $request . $query_string; 1428 1436 } 1429 1437 1430 $result = apply_filters( 'get_pagenum_link', $result);1438 $result = apply_filters( 'get_pagenum_link', $result, $url ); 1431 1439 1432 1440 if ( $escape ) 1433 1441 return esc_url( $result ); … … 1640 1648 } 1641 1649 1642 1650 /** 1651 * Retrieve page link for paginated post (i.e. includes the <!--nextpage--> 1652 * Quicktag one or more times). 1653 * 1654 * @since 3.5.0 1655 * 1656 * @param int $pagenum Optional. Page number. Default is 1. 1657 * @param int|object $post Optional. Post ID or post object. Default is null 1658 * @return string 1659 */ 1660 function get_post_page_link( $pagenum = 1, $post = null ) { 1661 global $wp_rewrite; 1662 1663 $post = get_post( $post ); 1664 $pagenum = (int) $pagenum; 1665 1666 $result = get_permalink( $post->ID ); 1667 1668 if ( 1 != $pagenum ) { 1669 if ( ( '' == get_option( 'permalink_structure' ) ) || in_array( $post->post_status, array( 'draft', 'pending' ) ) ) 1670 $result = add_query_arg( 'page', $pagenum, $result ); 1671 elseif ( ( 'page' == get_option('show_on_front') ) && ( get_option('page_on_front') == $post->ID ) ) 1672 $result = trailingslashit( $result ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $pagenum, 'single_paged' ); 1673 else 1674 $result = trailingslashit( $result ) . user_trailingslashit( $pagenum, 'single_paged' ); 1675 } 1676 1677 $result = apply_filters( 'get_post_page_link', $result, $post, $pagenum ); 1678 1679 return $result; 1680 } 1681 1682 /** 1643 1683 * Retrieve comments page number link. 1644 1684 * 1645 1685 * @since 2.7.0 1646 1686 * 1647 * @param int $pagenum Optional. Page number. 1687 * @param int $pagenum Optional. Page number. Default is 1. 1688 * @param int $max_page Optional. Maximum page number. Default is 0. 1689 * @param int|object $post Optional. Post ID or post object. Default is null 1690 * @param boolean $add_anchor Optional. Add anchor part to link or not. Default is true. 1648 1691 * @return string 1649 1692 */ 1650 function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {1651 global $ post, $wp_rewrite;1693 function get_comments_pagenum_link( $pagenum = 1, $max_page = 0, $post = null, $add_anchor = true ) { 1694 global $wp_rewrite; 1652 1695 1696 $post = get_post( $post ); 1653 1697 $pagenum = (int) $pagenum; 1654 1698 1655 1699 $result = get_permalink( $post->ID ); … … 1657 1701 if ( 'newest' == get_option('default_comments_page') ) { 1658 1702 if ( $pagenum != $max_page ) { 1659 1703 if ( $wp_rewrite->using_permalinks() ) 1660 $result = user_trailingslashit( trailingslashit( $result) . 'comment-page-' . $pagenum, 'commentpaged');1704 $result = user_trailingslashit( trailingslashit( $result ) . 'comment-page-' . $pagenum, 'commentpaged' ); 1661 1705 else 1662 1706 $result = add_query_arg( 'cpage', $pagenum, $result ); 1663 1707 } 1664 1708 } elseif ( $pagenum > 1 ) { 1665 1709 if ( $wp_rewrite->using_permalinks() ) 1666 $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged' );1710 $result = user_trailingslashit( trailingslashit($result) . 'comment-page-' . $pagenum, 'commentpaged' ); 1667 1711 else 1668 1712 $result = add_query_arg( 'cpage', $pagenum, $result ); 1669 1713 } 1670 1714 1671 $result .= '#comments'; 1715 if ( $add_anchor ) { 1716 $result .= '#comments'; 1717 } 1672 1718 1673 $result = apply_filters( 'get_comments_pagenum_link', $result);1719 $result = apply_filters( 'get_comments_pagenum_link', $result, $post, $pagenum, $max_page, $add_anchor ); 1674 1720 1675 1721 return $result; 1676 1722 }