WordPress.org

Make WordPress Core

Ticket #19275: 19275.diff

File 19275.diff, 4.7 KB (added by nacin, 7 years ago)
  • wp-includes/taxonomy.php

     
    2323                'rewrite' => did_action( 'init' ) ? array(
    2424                                        'hierarchical' => true,
    2525                                        'slug' => get_option('category_base') ? get_option('category_base') : 'category',
    26                                         'with_front' => ( get_option('category_base') && ! $wp_rewrite->using_index_permalinks() ) ? false : true ) : false,
     26                                        'with_front' => ( get_option('category_base') && ! $wp_rewrite->using_index_permalinks() ) ? false : true,
     27                                        'ep_mask' => EP_CATEGORIES,
     28                                ) : false,
    2729                'public' => true,
    2830                'show_ui' => true,
    2931                '_builtin' => true,
     
    3436                'query_var' => 'tag',
    3537                'rewrite' => did_action( 'init' ) ? array(
    3638                                        'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag',
    37                                         'with_front' => ( get_option('tag_base') && ! $wp_rewrite->using_index_permalinks() ) ? false : true ) : false,
     39                                        'with_front' => ( get_option('tag_base') && ! $wp_rewrite->using_index_permalinks() ) ? false : true,
     40                                        'ep_mask' => EP_TAGS,
     41                                ) : false,
    3842                'public' => true,
    3943                'show_ui' => true,
    4044                '_builtin' => true,
     
    322326                $args['rewrite'] = wp_parse_args($args['rewrite'], array(
    323327                        'slug' => sanitize_title_with_dashes($taxonomy),
    324328                        'with_front' => true,
    325                         'hierarchical' => false
     329                        'hierarchical' => false,
     330                        'ep_mask' => EP_NONE,
    326331                ));
    327332
    328333                if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )
     
    331336                        $tag = '([^/]+)';
    332337
    333338                $wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");
    334                 $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
     339                $wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front'], $args['rewrite']['ep_mask'] );
    335340        }
    336341
    337342        if ( is_null($args['show_ui']) )
  • wp-includes/post.php

     
    893893 *     register_taxonomy_for_object_type().
    894894 * - labels - An array of labels for this post type. By default post labels are used for non-hierarchical
    895895 *     types and page labels for hierarchical ones. You can see accepted values in {@link get_post_type_labels()}.
    896  * - permalink_epmask - The default rewrite endpoint bitmasks.
    897896 * - has_archive - True to enable post type archives. Will generate the proper rewrite rules if rewrite is enabled.
    898897 * - rewrite - false to prevent rewrite. Defaults to true. Use array('slug'=>$slug) to customize permastruct;
    899  *     default will use $post_type as slug. Other options include 'with_front', 'feeds', and 'pages'.
     898 *     default will use $post_type as slug. Other options include 'with_front', 'feeds', 'pages', and 'ep_mask'.
    900899 * - query_var - false to prevent queries, or string to value of the query var to use for this post type
    901900 * - can_export - true allows this post type to be exported.
    902901 * - show_in_nav_menus - true makes this post type available for selection in navigation menus.
     
    924923                'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true,
    925924                'supports' => array(), 'register_meta_box_cb' => null,
    926925                'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null,
    927                 'permalink_epmask' => EP_PERMALINK, 'can_export' => true,
     926                'can_export' => true,
    928927                'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null,
    929928        );
    930929        $args = wp_parse_args($args, $defaults);
     
    999998                        $args->rewrite['pages'] = true;
    1000999                if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )
    10011000                        $args->rewrite['feeds'] = (bool) $args->has_archive;
     1001                if ( ! isset( $args->rewrite['ep_mask'] ) ) {
     1002                        if ( isset( $args['permalink_epmask'] ) )
     1003                                $args->rewrite['ep_mask'] = $args['permalink_epmask'];
     1004                        else
     1005                                $args->rewrite['ep_mask'] = EP_PERMALINK;
     1006                }
    10021007
    10031008                if ( $args->hierarchical )
    10041009                        $wp_rewrite->add_rewrite_tag("%$post_type%", '(.+?)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
     
    10221027                                $wp_rewrite->add_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' );
    10231028                }
    10241029
    1025                 $wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask);
     1030                $wp_rewrite->add_permastruct( $post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->rewrite['ep_mask'] );
    10261031        }
    10271032
    10281033        if ( $args->register_meta_box_cb )