WordPress.org

Make WordPress Core

Ticket #12508: 12508.2.diff

File 12508.2.diff, 1.2 KB (added by scribu, 8 years ago)

also fix #10445

  • wp-includes/taxonomy.php

     
    233261        }
    234262
    235263        if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) {
    236                 if ( !is_array($args['rewrite']) )
    237                         $args['rewrite'] = array();
    238                 if ( !isset($args['rewrite']['slug']) )
    239                         $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy);
    240                 if ( !isset($args['rewrite']['with_front']) )
    241                         $args['rewrite']['with_front'] = true;
    242                 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=$term");
    243                 $wp_rewrite->add_permastruct($taxonomy, "/{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
     264                $args['rewrite'] = wp_parse_args($args['rewrite'], array(
     265                        'slug' => sanitize_title_with_dashes($taxonomy),
     266                        'with_front' => true,
     267                ));
     268                $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");
     269                $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
    244270        }
    245271
    246272        if ( is_null($args['show_ui']) )