Introduce `before_page_number` and `after_page_number` arguments for `paginate_links()`. Fixes #24709. Props grahamarmfield.

Built from https://develop.svn.wordpress.org/trunk@27600


git-svn-id: http://core.svn.wordpress.org/trunk@27443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2014-03-18 23:31:14 +00:00
parent bba0e99688
commit 8f5e5941bb
1 changed files with 11 additions and 3 deletions

View File

@ -1983,6 +1983,12 @@ function language_attributes($doctype = 'html') {
* It is possible to add query vars to the link by using the 'add_args' argument
* and see {@link add_query_arg()} for more information.
*
* The 'before_page_number' and 'after_page_number' arguments allow users to
* augment the links themselves. Typically this might be to add context to the
* numbered links so that screen reader users understand what the links are for.
* The text strings are added before and after the page number - within the
* anchor tag.
*
* @since 2.1.0
*
* @param string|array $args Optional. Override defaults.
@ -2002,7 +2008,9 @@ function paginate_links( $args = '' ) {
'mid_size' => 2,
'type' => 'plain',
'add_args' => false, // array of query args to add
'add_fragment' => ''
'add_fragment' => '',
'before_page_number' => '',
'after_page_number' => ''
);
$args = wp_parse_args( $args, $defaults );
@ -2031,7 +2039,7 @@ function paginate_links( $args = '' ) {
endif;
for ( $n = 1; $n <= $total; $n++ ) :
if ( $n == $current ) :
$page_links[] = "<span class='page-numbers current'>" . number_format_i18n($n) . "</span>";
$page_links[] = "<span class='page-numbers current'>" . $before_page_number . number_format_i18n( $n ) . $after_page_number . "</span>";
$dots = true;
else :
if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
@ -2040,7 +2048,7 @@ function paginate_links( $args = '' ) {
if ( $add_args )
$link = add_query_arg( $add_args, $link );
$link .= $add_fragment;
$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . number_format_i18n($n) . "</a>";
$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $before_page_number . number_format_i18n( $n ) . $after_page_number . "</a>";
$dots = true;
elseif ( $dots && !$show_all ) :
$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';