Changeset 15705 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 10/04/2010 10:37:25 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r15690 r15705 271 271 272 272 $defaults = array( 'hierarchical' => false, 273 'hierarchical_url' => false, 273 274 'update_count_callback' => '', 274 275 'rewrite' => true, … … 296 297 'with_front' => true, 297 298 )); 298 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term="); 299 if ( $args['hierarchical'] && $args['hierarchical_url'] ) 300 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '.*?/?([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term="); 301 else 302 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term="); 299 303 $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']); 300 304 } … … 2611 2615 2612 2616 $slug = $term->slug; 2617 $t = get_taxonomy($taxonomy); 2613 2618 2614 2619 if ( empty($termlink) ) { 2615 $t = get_taxonomy($taxonomy);2616 2620 if ( $t->query_var ) 2617 2621 $termlink = "?$t->query_var=$slug"; … … 2620 2624 $termlink = home_url($termlink); 2621 2625 } else { 2622 $termlink = str_replace("%$taxonomy%", $slug, $termlink); 2626 if ( $t->hierarchical_url ) { 2627 $hierarchical_slugs = array(); 2628 $ancestors = get_ancestors($term->term_id, $taxonomy); 2629 foreach ( (array)$ancestors as $ancestor ) { 2630 $ancestor_term = get_term($ancestor, $taxonomy); 2631 $hierarchical_slugs[] = $ancestor_term->slug; 2632 } 2633 $hierarchical_slugs = array_reverse($hierarchical_slugs); 2634 $hierarchical_slugs[] = $slug; 2635 $termlink = str_replace("%$taxonomy%", implode('/', $hierarchical_slugs), $termlink); 2636 } else { 2637 $termlink = str_replace("%$taxonomy%", $slug, $termlink); 2638 } 2623 2639 $termlink = home_url( user_trailingslashit($termlink, 'category') ); 2624 2640 }
Note: See TracChangeset
for help on using the changeset viewer.