WordPress.org

Make WordPress Core

Ticket #29808: 29808.10.diff

File 29808.10.diff, 7.5 KB (added by obenland, 5 years ago)
  • src/wp-includes/link-template.php

     
    21922192 * @param array $args {
    21932193 *     Optional. Default post navigation arguments.
    21942194 *
    2195  *     @type string $prev_text Anchor text to display in the previous post link.
    2196  *                             Default: `<span class="meta-nav">&larr;</span> %title`.
    2197  *     @type string $next_text Anchor text to display in the next post link.
    2198  *                             Default: `%title <span class="meta-nav">&rarr;</span>`.
     2195 *     @type string $prev_text          Anchor text to display in the previous post link. Default: `%title`.
     2196 *     @type string $next_text          Anchor text to display in the next post link. Default: `%title`.
     2197 *     @type string $screen_reader_text Screen reader text for nav element. Default: 'Post navigation'.
    21992198 * }
    22002199 * @return string Markup for post links.
    22012200 */
    22022201function get_the_post_navigation( $args = array() ) {
    22032202        $args = wp_parse_args( $args, array(
    2204                 'prev_text' => _x( '<span class="meta-nav">&larr;</span> %title', 'Previous post link' ),
    2205                 'next_text' => _x( '%title <span class="meta-nav">&rarr;</span>', 'Next post link' ),
     2203                'prev_text'          => '%title',
     2204                'next_text'          => '%title',
     2205                'screen_reader_text' => __( 'Post navigation' ),
    22062206        ) );
    22072207
    22082208        $navigation = '';
     
    22102210        $next       = get_next_post_link( '<div class="nav-next">%link</div>', $args['next_text'] );
    22112211
    22122212        // Only add markup if there's somewhere to navigate to.
    2213         if ( $next || $previous ) {
    2214                 $navigation = _navigation_markup( $next . $previous, 'post-navigation', __( 'Post navigation' ) );
     2213        if ( $previous || $next ) {
     2214                $navigation = _navigation_markup( $previous . $next, 'post-navigation', $args['screen_reader_text'] );
    22152215        }
    22162216
    22172217        return $navigation;
     
    22382238 * @param array $args {
    22392239 *     Optional. Default paging navigation arguments.
    22402240 *
    2241  *     @type string $prev_text Anchor text to display in the previous posts link.
    2242  *                             Default: `<span class="meta-nav">&larr;</span> Older posts`.
    2243  *     @type string $next_text Anchor text to display in the next posts link.
    2244  *                             Default: `Newer posts <span class="meta-nav">&rarr;</span>`.
     2241 *     @type string $prev_text          Anchor text to display in the previous posts link. Default: `Older posts`.
     2242 *     @type string $next_text          Anchor text to display in the next posts link. Default: `Newer posts`.
     2243 *     @type string $screen_reader_text Screen reader text for nav element. Default: 'Posts navigation'.
    22452244 * }
    22462245 * @return string Markup for paging links.
    22472246 */
     
    22512250        // Don't print empty markup if there's only one page.
    22522251        if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    22532252                $args = wp_parse_args( $args, array(
    2254                         'prev_text' => __( '<span class="meta-nav">&larr;</span> Older posts' ),
    2255                         'next_text' => __( 'Newer posts <span class="meta-nav">&rarr;</span>' ),
     2253                        'prev_text'          => __( 'Older posts' ),
     2254                        'next_text'          => __( 'Newer posts' ),
     2255                        'screen_reader_text' => __( 'Posts navigation' ),
    22562256                ) );
    22572257
    2258                 $next_link = get_next_posts_link( $args['prev_text'] );
    2259                 $prev_link = get_previous_posts_link( $args['next_text'] );
     2258                $next_link = get_previous_posts_link( $args['next_text'] );
     2259                $prev_link = get_next_posts_link( $args['prev_text'] );
    22602260
    2261                 if ( $next_link ) {
    2262                         $navigation .= '<div class="nav-previous">' . $next_link . '</div>';
     2261                if ( $prev_link ) {
     2262                        $navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
    22632263                }
    22642264
    2265                 if ( $prev_link ) {
    2266                         $navigation .= '<div class="nav-next">' . $prev_link . '</div>';
     2265                if ( $next_link ) {
     2266                        $navigation .= '<div class="nav-next">' . $next_link . '</div>';
    22672267                }
    22682268
    2269                 $navigation = _navigation_markup( $navigation );
     2269                $navigation = _navigation_markup( $navigation, 'paging-navigation', $args['screen_reader_text'] );
    22702270        }
    22712271
    22722272        return $navigation;
     
    22902290 * @since 4.1.0
    22912291 *
    22922292 * @param array $args {
    2293  *     Optional. Default pagination arguments.
     2293 *     Optional. Default pagination arguments. {@see paginate_links()}
    22942294 *
    2295  *     @type string $base               URL to be used to create the paginated links.
    2296  *                                      Example: `http://example.com/all_posts.php%_%`
    2297  *                                      The `%_%` is required and will be replaced by the contents of the
    2298  *                                      'format' argument.
    2299  *                                      Default: Current page number link with appended `%_%`.
    2300  *     @type string $format             Used to replace the page number. Example: `?page=%#%`
    2301  *                                      The `%#%` is required and will be replaced with the page number.
    2302  *                                      Default: Current permalink format with appended `%#%`.
    2303  *     @type int    $total              The total amount of pages. Default: Value of 'max_num_pages' of current query.
    2304  *     @type int    $current            The current page number. Default: Value of 'paged' query var.
    2305  *     @type bool   $prev_next          Whether to include previous and next links. Default: true.
    2306  *     @type string $prev_text          Anchor text to display in the previous posts link. Default: `&larr; Previous`.
    2307  *     @type string $next_text          Anchor text to display in the next posts link. Default: `Next &rarr;`.
    2308  *     @type bool   $show_all           Whether to show all pages.
    2309  *                                      Default: false, shows short list of the pages near the current page.
    2310  *     @type int    $end_size           Amount of numbers on either the start and the end list edges. Default: 1.
    2311  *     @type int    $mid_size           Amount of numbers to either side of current page but not including current page.
    2312  *                                      Default: 1.
    2313  *     @type array  $add_args           Query vars to be added to the links. Accepts an associative array of arguments.
    2314  *                                      Default: Empty array.
    2315  *     @type string $before_page_number Text to prepend to the anchor text. Default: Empty string.
    2316  *     @type string $after_page_number  Text to append to the anchor text. Default: Empty string.
     2295 *     @type string $screen_reader_text Screen reader text for nav element. Default: 'Posts navigation'.
    23172296 * }
    23182297 * @return string Markup for pagination links.
    23192298 */
     
    23232302        // Don't print empty markup if there's only one page.
    23242303        if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    23252304                $args = wp_parse_args( $args, array(
    2326                         'mid_size'  => 1,
    2327                         'prev_text' => __( '&larr; Previous' ),
    2328                         'next_text' => __( 'Next &rarr;' ),
     2305                        'mid_size'           => 1,
     2306                        'prev_text'          => __( 'Previous' ),
     2307                        'next_text'          => __( 'Next' ),
     2308                        'screen_reader_text' => __( 'Posts navigation' ),
    23292309                ) );
    23302310                // Make sure we get plain links, so we can work with it.
    23312311                $args['type'] = 'plain';
     
    23352315
    23362316                // `navigation_markup()` expects a string, `paginate_links()` can return an array.
    23372317                if ( $links && ! is_array( $links ) ) {
    2338                         $navigation = _navigation_markup( $links, 'pagination' );
     2318                        $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] );
    23392319                }
    23402320        }
    23412321
     
    23722352
    23732353        $template = '
    23742354        <nav class="navigation %1$s" role="navigation">
    2375                 <h1 class="screen-reader-text">%2$s</h1>
     2355                <h2 class="screen-reader-text">%2$s</h2>
    23762356                <div class="nav-links">%3$s</div>
    23772357        </nav>';
    23782358