Make WordPress Core

Ticket #29808: 29808-pagination.diff

File 29808-pagination.diff, 2.4 KB (added by GaryJ, 10 years ago)

Add Twenty Fourteen code to get_the_pagination()

  • src/wp-includes/link-template.php

    diff --git src/wp-includes/link-template.php src/wp-includes/link-template.php
    index 3de61f4..4807acb 100644
    function the_posts_navigation( $args = array() ) { 
    23042304 * @return string Markup for pagination links.
    23052305 */
    23062306function get_the_pagination( $args = array() ) {
    2307         $navigation = '';
     2307        global $wp_query, $wp_rewrite;
    23082308
    23092309        // Don't print empty markup if there's only one page.
    2310         if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
    2311                 $args = wp_parse_args( $args, array(
    2312                         'mid_size'           => 1,
    2313                         'prev_text'          => __( 'Previous' ),
    2314                         'next_text'          => __( 'Next' ),
    2315                         'screen_reader_text' => __( 'Posts navigation' ),
    2316                 ) );
    2317                 // Make sure we get plain links, so we can work with it.
    2318                 $args['type'] = 'plain';
     2310        if ( $wp_query->max_num_pages < 2 ) {
     2311                return;
     2312        }
    23192313
    2320                 // Set up paginated links.
    2321                 $links = paginate_links( $args );
     2314        $paged        = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
     2315        $pagenum_link = html_entity_decode( get_pagenum_link() );
     2316        $query_args   = array();
     2317        $url_parts    = explode( '?', $pagenum_link );
    23222318
    2323                 if ( $links ) {
    2324                         $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] );
    2325                 }
     2319        if ( isset( $url_parts[1] ) ) {
     2320                wp_parse_str( $url_parts[1], $query_args );
     2321        }
     2322
     2323        $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
     2324        $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
     2325
     2326        $format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
     2327        $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
     2328
     2329        $args = wp_parse_args( $args, array(
     2330                'base'               => $pagenum_link,
     2331                'format'             => $format,
     2332                'add_args'           => array_map( 'urlencode', $query_args ),
     2333                'total'              => $wp_query->max_num_pages,
     2334                'current'            => $paged,
     2335                'mid_size'           => 1,
     2336                'prev_text'          => __( 'Previous' ),
     2337                'next_text'          => __( 'Next' ),
     2338                'screen_reader_text' => __( 'Posts navigation' ),
     2339        ) );
     2340
     2341        $navigation = '';
     2342
     2343        // Set up paginated links.
     2344        $links = paginate_links( $args );
     2345
     2346        if ( $links ) {
     2347                $navigation = _navigation_markup( $links, 'pagination', $args['screen_reader_text'] );
    23262348        }
    23272349
    23282350        return $navigation;