Make WordPress Core

Ticket #10219: 10219-2.diff

File 10219-2.diff, 5.7 KB (added by dancameron, 9 years ago)

Minor mods of previous patch, along with additional support of twenty-twelve and twenty-eleven.

  • src/wp-content/themes/twentyeleven/functions.php

     
    504504function twentyeleven_content_nav( $html_id ) {
    505505        global $wp_query;
    506506
    507         if ( $wp_query->max_num_pages > 1 ) : ?>
    508                 <nav id="<?php echo esc_attr( $html_id ); ?>">
    509                         <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
    510                         <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' ) ); ?></div>
    511                         <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' ) ); ?></div>
    512                 </nav><!-- #nav-above -->
    513         <?php endif;
     507        // Don't print empty markup if there's only one page.
     508        if ( $wp_query->max_num_pages < 2 ) {
     509                return;
     510        }
     511
     512        $desc_order = 'DESC' === get_query_var( 'order' );
     513        $next_label = __( '<span class="meta-nav">&larr;</span> Older posts', 'twentyeleven' );
     514        $prev_label = __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentyeleven' );
     515
     516        ?>
     517        <nav id="<?php echo esc_attr( $html_id ); ?>">
     518                <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
     519                <div class="nav-<?php echo $desc_order ? 'previous' : 'next'; ?>"><?php next_posts_link( $desc_order ? $next_label : $prev_label ); ?></div>
     520                <div class="nav-<?php echo $desc_order ? 'next' : 'previous'; ?>"><?php previous_posts_link( $desc_order ? $prev_label : $next_label ); ?></div>
     521        </nav><!-- #nav-above -->
     522        <?php
    514523}
    515524endif; // twentyeleven_content_nav
    516525
  • src/wp-content/themes/twentythirteen/functions.php

     
    259259        global $wp_query;
    260260
    261261        // Don't print empty markup if there's only one page.
    262         if ( $wp_query->max_num_pages < 2 )
     262        if ( $wp_query->max_num_pages < 2 ) {
    263263                return;
     264        }
     265
     266        $desc_order = 'DESC' === get_query_var( 'order' );
     267        $next_label = __( '<span class="meta-nav">&larr;</span> Older posts', 'twentythirteen' );
     268        $prev_label = __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentythirteen' );
     269
    264270        ?>
    265271        <nav class="navigation paging-navigation" role="navigation">
    266272                <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'twentythirteen' ); ?></h1>
    267273                <div class="nav-links">
    268274
    269275                        <?php if ( get_next_posts_link() ) : ?>
    270                         <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentythirteen' ) ); ?></div>
     276                                <div class="nav-<?php echo $desc_order ? 'previous' : 'next'; ?>"><?php next_posts_link( $desc_order ? $next_label : $prev_label ); ?></div>
    271277                        <?php endif; ?>
    272278
    273279                        <?php if ( get_previous_posts_link() ) : ?>
    274                         <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentythirteen' ) ); ?></div>
     280                                <div class="nav-<?php echo $desc_order ? 'next' : 'previous'; ?>"><?php previous_posts_link( $desc_order ? $prev_label : $next_label ); ?></div>
    275281                        <?php endif; ?>
    276282
    277283                </div><!-- .nav-links -->
  • src/wp-content/themes/twentytwelve/functions.php

     
    278278function twentytwelve_content_nav( $html_id ) {
    279279        global $wp_query;
    280280
    281         if ( $wp_query->max_num_pages > 1 ) : ?>
    282                 <nav id="<?php echo esc_attr( $html_id ); ?>" class="navigation" role="navigation">
    283                         <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
    284                         <div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'twentytwelve' ) ); ?></div>
    285                         <div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?></div>
    286                 </nav><!-- .navigation -->
    287         <?php endif;
     281        // Don't print empty markup if there's only one page.
     282        if ( $wp_query->max_num_pages < 2 ) {
     283                return;
     284        }
     285
     286        $desc_order = 'DESC' === get_query_var( 'order' );
     287        $next_label = __( '<span class="meta-nav">&larr;</span> Older posts', 'twentytwelve' );
     288        $prev_label = __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'twentytwelve' );
     289
     290        ?>
     291        <nav id="<?php echo esc_attr( $html_id ); ?>" class="navigation" role="navigation">
     292                <h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
     293                <div class="nav-<?php echo $desc_order ? 'previous' : 'next'; ?>"><?php next_posts_link( $desc_order ? $next_label : $prev_label ); ?></div>
     294                <div class="nav-<?php echo $desc_order ? 'next' : 'previous'; ?>"><?php previous_posts_link( $desc_order ? $prev_label : $next_label ); ?></div>
     295        </nav><!-- .navigation -->
     296        <?php
    288297}
    289298endif;
    290299
  • src/wp-includes/link-template.php

     
    24282428
    24292429        // Don't print empty markup if there's only one page.
    24302430        if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
     2431                $desc = 'DESC' === get_query_var( 'order' );
    24312432                $args = wp_parse_args( $args, array(
    2432                         'prev_text'          => __( 'Older posts' ),
    2433                         'next_text'          => __( 'Newer posts' ),
     2433                        'prev_text'          => $desc ? __( 'Older posts' ) : __( 'Newer posts' ),
     2434                        'next_text'          => $desc ? __( 'Newer posts' ) : __( 'Older posts' ),
    24342435                        'screen_reader_text' => __( 'Posts navigation' ),
    24352436                ) );
    24362437