Make WordPress Core

Ticket #19241: 19241.check-category_name.diff

File 19241.check-category_name.diff, 1.1 KB (added by duck_, 13 years ago)
  • wp-includes/canonical.php

     
    191191                                }
    192192
    193193                        }
    194                 } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {
    195                         $category = get_category_by_path(get_query_var('category_name'));
     194                } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false && $cat = get_query_var( 'category_name' ) ) {
     195                        $category = get_category_by_path( $cat );
    196196                        $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));
    197197                        if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) )
    198198                                $redirect_url = get_permalink($wp_query->get_queried_object_id());
     
    494494        }
    495495}
    496496
    497 add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
    498  No newline at end of file
     497add_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );