Changeset 38216
- Timestamp:
- 08/08/2016 06:48:53 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/canonical.php
r38107 r38216 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 $post_terms = get_the_terms( $wp_query->get_queried_object_id(), 'category' ); 260 if ( ( ! $category || is_wp_error( $category ) ) || ( ! is_wp_error( $post_terms ) && ! empty( $post_terms ) && ! in_array( $category, $post_terms ) ) ) { 259 if ( ( ! $category || is_wp_error( $category ) ) || ! has_term( $category->term_id, 'category', $wp_query->get_queried_object_id() ) ) { 261 260 $redirect_url = get_permalink($wp_query->get_queried_object_id()); 262 261 } -
trunk/tests/phpunit/tests/canonical/category.php
r37261 r38216 63 63 // Nonexistent category will redirect to correct one. 64 64 array( '/foo/post0/', array( 'url' => '/cat0/post0/', 'qv' => array( 'category_name' => 'cat0', 'name' => 'post0', 'page' => '' ) ) ), 65 66 // Embed URLs should not redirect to post permalinks. 67 array( '/cat0/post0/embed/', array( 'url' => '/cat0/post0/embed/', 'qv' => array( 'category_name' => 'cat0', 'name' => 'post0', 'embed' => 'true' ) ) ), 65 68 ); 66 69 }
Note: See TracChangeset
for help on using the changeset viewer.