Make WordPress Core

Ticket #29808: 29808.8.diff

File 29808.8.diff, 5.1 KB (added by obenland, 10 years ago)

post navigation improvements

  • 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`.
    21992197 * }
    22002198 * @return string Markup for post links.
    22012199 */
    22022200function get_the_post_navigation( $args = array() ) {
    22032201        $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' ),
     2202                'prev_text' => '%title',
     2203                'next_text' => '%title',
    22062204        ) );
    22072205
    22082206        $navigation = '';
     
    22102208        $next       = get_next_post_link( '<div class="nav-next">%link</div>', $args['next_text'] );
    22112209
    22122210        // Only add markup if there's somewhere to navigate to.
    2213         if ( $next || $previous ) {
    2214                 $navigation = _navigation_markup( $next . $previous, 'post-navigation', __( 'Post navigation' ) );
     2211        if ( $previous || $next ) {
     2212                $navigation = _navigation_markup( $previous . $next, 'post-navigation', __( 'Post navigation' ) );
    22152213        }
    22162214
    22172215        return $navigation;
     
    22382236 * @param array $args {
    22392237 *     Optional. Default paging navigation arguments.
    22402238 *
    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>`.
     2239 *     @type string $prev_text Anchor text to display in the previous posts link. Default: `Older posts`.
     2240 *     @type string $next_text Anchor text to display in the next posts link. Default: `Newer posts`.
    22452241 * }
    22462242 * @return string Markup for paging links.
    22472243 */
     
    22512247        // Don't print empty markup if there's only one page.
    22522248        if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    22532249                $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>' ),
     2250                        'prev_text' => __( 'Older posts' ),
     2251                        'next_text' => __( 'Newer posts' ),
    22562252                ) );
    22572253
    2258                 $next_link = get_next_posts_link( $args['prev_text'] );
    2259                 $prev_link = get_previous_posts_link( $args['next_text'] );
     2254                $next_link = get_previous_posts_link( $args['next_text'] );
     2255                $prev_link = get_next_posts_link( $args['prev_text'] );
    22602256
    2261                 if ( $next_link ) {
    2262                         $navigation .= '<div class="nav-previous">' . $next_link . '</div>';
     2257                if ( $prev_link ) {
     2258                        $navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
    22632259                }
    22642260
    2265                 if ( $prev_link ) {
    2266                         $navigation .= '<div class="nav-next">' . $prev_link . '</div>';
     2261                if ( $next_link ) {
     2262                        $navigation .= '<div class="nav-next">' . $next_link . '</div>';
    22672263                }
    22682264
    22692265                $navigation = _navigation_markup( $navigation );
     
    23032299 *     @type int    $total              The total amount of pages. Default: Value of 'max_num_pages' of current query.
    23042300 *     @type int    $current            The current page number. Default: Value of 'paged' query var.
    23052301 *     @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;`.
     2302 *     @type string $prev_text          Anchor text to display in the previous posts link. Default: `Previous`.
     2303 *     @type string $next_text          Anchor text to display in the next posts link. Default: `Next`.
    23082304 *     @type bool   $show_all           Whether to show all pages.
    23092305 *                                      Default: false, shows short list of the pages near the current page.
    23102306 *     @type int    $end_size           Amount of numbers on either the start and the end list edges. Default: 1.
     
    23242320        if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    23252321                $args = wp_parse_args( $args, array(
    23262322                        'mid_size'  => 1,
    2327                         'prev_text' => __( '&larr; Previous' ),
    2328                         'next_text' => __( 'Next &rarr;' ),
     2323                        'prev_text' => __( 'Previous' ),
     2324                        'next_text' => __( 'Next' ),
    23292325                ) );
    23302326                // Make sure we get plain links, so we can work with it.
    23312327                $args['type'] = 'plain';
     
    23732369
    23742370        $template = '
    23752371        <nav class="navigation %1$s" role="navigation">
    2376                 <h1 class="screen-reader-text">%2$s</h1>
     2372                <h2 class="screen-reader-text">%2$s</h2>
    23772373                <div class="nav-links">%3$s</div>
    23782374        </nav>';
    23792375