paginate_comments_links(). see #7769

git-svn-id: http://svn.automattic.com/wordpress/trunk@9097 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-07 22:41:51 +00:00
parent 9ca5fd7287
commit ae65f5197c
2 changed files with 46 additions and 4 deletions

View File

@ -1633,7 +1633,8 @@ function paginate_links( $args = '' ) {
'end_size' => 1,
'mid_size' => 2,
'type' => 'plain',
'add_args' => false // array of query args to add
'add_args' => false, // array of query args to add
'add_fragment' => ''
);
$args = wp_parse_args( $args, $defaults );
@ -1657,6 +1658,7 @@ function paginate_links( $args = '' ) {
$link = str_replace('%#%', $current - 1, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $add_fragment;
$page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>";
endif;
for ( $n = 1; $n <= $total; $n++ ) :
@ -1669,6 +1671,7 @@ function paginate_links( $args = '' ) {
$link = str_replace('%#%', $n, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $add_fragment;
$page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n</a>";
$dots = true;
elseif ( $dots && !$show_all ) :
@ -1682,6 +1685,7 @@ function paginate_links( $args = '' ) {
$link = str_replace('%#%', $current + 1, $link);
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $add_fragment;
$page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>";
endif;
switch ( $type ) :

View File

@ -815,6 +815,8 @@ function get_comments_pagenum_link($pagenum = 1) {
$result = $base . $request;
}
$result .= '#comments';
$result = apply_filters('get_comments_pagenum_link', $result);
return $result;
@ -828,9 +830,6 @@ function next_comments_link($label='', $max_page = 0) {
$page = get_query_var('cpage');
if ( !$page )
$page = 1;
if ( !$page )
$page = 1;
@ -858,6 +857,9 @@ function previous_comments_link($label='') {
$page = get_query_var('cpage');
if ( !$page )
$page = 1;
if ( $page <= 1 )
return;
@ -871,6 +873,42 @@ function previous_comments_link($label='') {
echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label) .'</a>';
}
/** Create pagination links for the comments on the current post
*
* @package WordPress
* @see paginate_links
* @since 2.7
*
* @param string|array $args Optional args. See paginate_links.
* @return string Markup for pagination links
*/
function paginate_comments_links($args = array()) {
global $wp_query;
if ( !is_singular() )
return;
$page = get_query_var('cpage');
if ( !$page )
$page = 1;
$max_page = $wp_query->max_num_comment_pages;
$defaults = array(
'base' => add_query_arg( 'cpage', '%#%' ),
'format' => '',
'total' => $max_page,
'current' => $page,
'echo' => true,
'add_fragment' => '#comments'
);
$args = wp_parse_args( $args, $defaults );
$page_links = paginate_links( $args );
if ( $args['echo'] )
echo $page_links;
else
return $page_links;
}
function get_shortcut_link() {
$link = "javascript:
var d=document,