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:
parent
9ca5fd7287
commit
ae65f5197c
|
@ -1633,7 +1633,8 @@ function paginate_links( $args = '' ) {
|
||||||
'end_size' => 1,
|
'end_size' => 1,
|
||||||
'mid_size' => 2,
|
'mid_size' => 2,
|
||||||
'type' => 'plain',
|
'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 );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
|
@ -1657,6 +1658,7 @@ function paginate_links( $args = '' ) {
|
||||||
$link = str_replace('%#%', $current - 1, $link);
|
$link = str_replace('%#%', $current - 1, $link);
|
||||||
if ( $add_args )
|
if ( $add_args )
|
||||||
$link = add_query_arg( $add_args, $link );
|
$link = add_query_arg( $add_args, $link );
|
||||||
|
$link .= $add_fragment;
|
||||||
$page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>";
|
$page_links[] = "<a class='prev page-numbers' href='" . clean_url($link) . "'>$prev_text</a>";
|
||||||
endif;
|
endif;
|
||||||
for ( $n = 1; $n <= $total; $n++ ) :
|
for ( $n = 1; $n <= $total; $n++ ) :
|
||||||
|
@ -1669,6 +1671,7 @@ function paginate_links( $args = '' ) {
|
||||||
$link = str_replace('%#%', $n, $link);
|
$link = str_replace('%#%', $n, $link);
|
||||||
if ( $add_args )
|
if ( $add_args )
|
||||||
$link = add_query_arg( $add_args, $link );
|
$link = add_query_arg( $add_args, $link );
|
||||||
|
$link .= $add_fragment;
|
||||||
$page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n</a>";
|
$page_links[] = "<a class='page-numbers' href='" . clean_url($link) . "'>$n</a>";
|
||||||
$dots = true;
|
$dots = true;
|
||||||
elseif ( $dots && !$show_all ) :
|
elseif ( $dots && !$show_all ) :
|
||||||
|
@ -1682,6 +1685,7 @@ function paginate_links( $args = '' ) {
|
||||||
$link = str_replace('%#%', $current + 1, $link);
|
$link = str_replace('%#%', $current + 1, $link);
|
||||||
if ( $add_args )
|
if ( $add_args )
|
||||||
$link = add_query_arg( $add_args, $link );
|
$link = add_query_arg( $add_args, $link );
|
||||||
|
$link .= $add_fragment;
|
||||||
$page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>";
|
$page_links[] = "<a class='next page-numbers' href='" . clean_url($link) . "'>$next_text</a>";
|
||||||
endif;
|
endif;
|
||||||
switch ( $type ) :
|
switch ( $type ) :
|
||||||
|
|
|
@ -815,6 +815,8 @@ function get_comments_pagenum_link($pagenum = 1) {
|
||||||
$result = $base . $request;
|
$result = $base . $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$result .= '#comments';
|
||||||
|
|
||||||
$result = apply_filters('get_comments_pagenum_link', $result);
|
$result = apply_filters('get_comments_pagenum_link', $result);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -828,9 +830,6 @@ function next_comments_link($label='', $max_page = 0) {
|
||||||
|
|
||||||
$page = get_query_var('cpage');
|
$page = get_query_var('cpage');
|
||||||
|
|
||||||
if ( !$page )
|
|
||||||
$page = 1;
|
|
||||||
|
|
||||||
if ( !$page )
|
if ( !$page )
|
||||||
$page = 1;
|
$page = 1;
|
||||||
|
|
||||||
|
@ -858,6 +857,9 @@ function previous_comments_link($label='') {
|
||||||
|
|
||||||
$page = get_query_var('cpage');
|
$page = get_query_var('cpage');
|
||||||
|
|
||||||
|
if ( !$page )
|
||||||
|
$page = 1;
|
||||||
|
|
||||||
if ( $page <= 1 )
|
if ( $page <= 1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -871,6 +873,42 @@ function previous_comments_link($label='') {
|
||||||
echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
|
echo "\" $attr>". preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$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() {
|
function get_shortcut_link() {
|
||||||
$link = "javascript:
|
$link = "javascript:
|
||||||
var d=document,
|
var d=document,
|
||||||
|
|
Loading…
Reference in New Issue