Make WordPress Core

Ticket #35344: 35344.2.diff

File 35344.2.diff, 2.8 KB (added by dd32, 9 years ago)
  • src/wp-includes/canonical.php

    function redirect_canonical( $requested_ 
    250250                                                        if ( isset($rewrite_vars[$_qv]) )
    251251                                                                $redirect['query'] = remove_query_arg($_qv, $redirect['query']);
    252252                                                }
    253253                                        }
    254254                                }
    255255
    256256                        }
    257257                } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var( 'category_name' ) ) {
    258258                        $category = get_category_by_path( $cat );
    259259                        $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));
    260260                        if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) )
    261261                                $redirect_url = get_permalink($wp_query->get_queried_object_id());
    262262                }
    263263
    264264                // Post Paging
    265                 if ( is_singular() && ! is_front_page() && get_query_var('page') ) {
     265                if ( is_singular() && get_query_var('page') && ( !is_front_page() || ( isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') ) ) ) {
    266266                        if ( !$redirect_url )
    267267                                $redirect_url = get_permalink( get_queried_object_id() );
    268                         $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
     268
     269                        $page = get_query_var( 'page' );
     270                        if ( is_front_page() ) {
     271                                $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );
     272                        } else {
     273                                $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' );
     274                        }
    269275                        $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
    270276                }
    271277
    272278                // paging and feeds
    273279                if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
    274280                        while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
    275281                                // Strip off paging and feed
    276282                                $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
    277283                                $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
    278284                                $redirect['path'] = preg_replace("#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing comment paging
    279285                        }
    280286
    281287                        $addl_path = '';
    282288                        if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) {
    283289                                $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : '';