From a27f712fbb236c887b3a016d7abfc90c73796426 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Tue, 18 Mar 2014 23:30:55 +0000 Subject: [PATCH] Introduce `before_page_number` and `after_page_number` arguments for `paginate_links()`. Fixes #24709. Props grahamarmfield. git-svn-id: https://develop.svn.wordpress.org/trunk@27600 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index 5c4bc7503d..1dae0cc336 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -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[] = "" . number_format_i18n($n) . ""; + $page_links[] = "" . $before_page_number . number_format_i18n( $n ) . $after_page_number . ""; $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[] = "" . number_format_i18n($n) . ""; + $page_links[] = "" . $before_page_number . number_format_i18n( $n ) . $after_page_number . ""; $dots = true; elseif ( $dots && !$show_all ) : $page_links[] = '' . __( '…' ) . '';