Make WordPress Core


Ignore:
Timestamp:
10/07/2008 10:41:51 PM (16 years ago)
Author:
ryan
Message:

paginate_comments_links(). see #7769

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r8961 r9097  
    816816    }
    817817
     818    $result .= '#comments';
     819
    818820    $result = apply_filters('get_comments_pagenum_link', $result);
    819821
     
    832834        $page = 1;
    833835
    834     if ( !$page )
    835         $page = 1;
    836 
    837836    $nextpage = intval($page) + 1;
    838837
     
    859858    $page = get_query_var('cpage');
    860859
     860    if ( !$page )
     861        $page = 1;
     862
    861863    if ( $page <= 1 )
    862864        return;
     
    870872    $attr = apply_filters( 'previous_comments_link_attributes', '' );
    871873    echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
     874}
     875
     876/** Create pagination links for the comments on the current post
     877 *
     878 * @package WordPress
     879 * @see paginate_links
     880 * @since 2.7
     881 *
     882 * @param string|array $args Optional args. See paginate_links.
     883 * @return string Markup for pagination links
     884*/
     885function paginate_comments_links($args = array()) {
     886    global $wp_query;
     887
     888    if ( !is_singular() )
     889        return;
     890
     891    $page = get_query_var('cpage');
     892    if ( !$page )
     893        $page = 1;
     894    $max_page = $wp_query->max_num_comment_pages;
     895    $defaults = array(
     896        'base' => add_query_arg( 'cpage', '%#%' ),
     897        'format' => '',
     898        'total' => $max_page,
     899        'current' => $page,
     900        'echo' => true,
     901        'add_fragment' => '#comments'
     902    );
     903    $args = wp_parse_args( $args, $defaults );
     904    $page_links = paginate_links( $args );
     905
     906    if ( $args['echo'] )
     907        echo $page_links;
     908    else
     909        return $page_links;
    872910}
    873911
Note: See TracChangeset for help on using the changeset viewer.