WordPress.org

Make WordPress Core

Changeset 28645


Ignore:
Timestamp:
05/31/2014 06:50:16 PM (7 years ago)
Author:
lancewillett
Message:

Twenty Fourteen: change hardcoded pagination base to use the WordPress Rewrite object's pagination_base value instead. Document global variable usage properly.

Props SergeyBiryukov, fixes #28405.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfourteen/inc/template-tags.php

    r27595 r28645  
    1313 *
    1414 * @since Twenty Fourteen 1.0
     15 *
     16 * @global WP_Query   $wp_query   WordPress Query object.
     17 * @global WP_Rewrite $wp_rewrite WordPress Rewrite object.
    1518 */
    1619function twentyfourteen_paging_nav() {
     20    global $wp_query, $wp_rewrite;
     21
    1722    // Don't print empty markup if there's only one page.
    18     if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
     23    if ( $wp_query->max_num_pages < 2 ) {
    1924        return;
    2025    }
     
    3237    $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
    3338
    34     $format  = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
    35     $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
     39    $format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
     40    $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
    3641
    3742    // Set up paginated links.
     
    3944        'base'     => $pagenum_link,
    4045        'format'   => $format,
    41         'total'    => $GLOBALS['wp_query']->max_num_pages,
     46        'total'    => $wp_query->max_num_pages,
    4247        'current'  => $paged,
    4348        'mid_size' => 1,
Note: See TracChangeset for help on using the changeset viewer.