| 250 | 250 | if ( isset($rewrite_vars[$_qv]) ) |
| 251 | 251 | $redirect['query'] = remove_query_arg($_qv, $redirect['query']); |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | } |
| 257 | 257 | } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var( 'category_name' ) ) { |
| 258 | 258 | $category = get_category_by_path( $cat ); |
| 259 | 259 | $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids')); |
| 260 | 260 | if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) ) |
| 261 | 261 | $redirect_url = get_permalink($wp_query->get_queried_object_id()); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | // Post Paging |
| 269 | 275 | $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); |
| 270 | 276 | } |
| 271 | 277 | |
| 272 | 278 | // paging and feeds |
| 273 | 279 | if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) { |
| 274 | 280 | 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'] ) ) { |
| 275 | 281 | // Strip off paging and feed |
| 276 | 282 | $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging |
| 277 | 283 | $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings |
| 278 | 284 | $redirect['path'] = preg_replace("#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing comment paging |
| 279 | 285 | } |
| 280 | 286 | |
| 281 | 287 | $addl_path = ''; |
| 282 | 288 | if ( is_feed() && in_array( get_query_var('feed'), $wp_rewrite->feeds ) ) { |
| 283 | 289 | $addl_path = !empty( $addl_path ) ? trailingslashit($addl_path) : ''; |