Changeset 9097

Show
Ignore:
Timestamp:
10/07/08 22:41:51 (2 months ago)
Author:
ryan
Message:

paginate_comments_links(). see #7769

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/general-template.php

    r9025 r9097  
    16341634        'mid_size' => 2, 
    16351635        'type' => 'plain', 
    1636         'add_args' => false // array of query args to add 
     1636        'add_args' => false, // array of query args to add 
     1637        'add_fragment' => '' 
    16371638    ); 
    16381639 
     
    16581659        if ( $add_args ) 
    16591660            $link = add_query_arg( $add_args, $link ); 
     1661        $link .= $add_fragment; 
    16601662        $page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>"; 
    16611663    endif; 
     
    16701672                if ( $add_args ) 
    16711673                    $link = add_query_arg( $add_args, $link ); 
     1674                $link .= $add_fragment; 
    16721675                $page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n</a>"; 
    16731676                $dots = true; 
     
    16831686        if ( $add_args ) 
    16841687            $link = add_query_arg( $add_args, $link ); 
     1688        $link .= $add_fragment; 
    16851689        $page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>"; 
    16861690    endif; 
  • 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