Make WordPress Core

Changeset 15936


Ignore:
Timestamp:
10/23/2010 06:29:22 PM (16 years ago)
Author:
nacin
Message:

Move the CPT archive flag outside of the rewrite argument, into its own has_archive. has_archive controls more than just URL rewriting, it also handles whether ?post_type= is treated as a CPT archive. feeds remain in rewrite as ?feed= would work regardless. see #13818.

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r15934 r15936  
    860860 *     types and page labels for hierarchical ones. You can see accepted values in {@link get_post_type_labels()}.
    861861 * - permalink_epmask - The default rewrite endpoint bitmasks.
     862 * - has_archive - Whether to have a post type archive. Will generate the proper rewrite rules if rewrite is enabled.
    862863 * - rewrite - false to prevent rewrite. Defaults to true. Use array('slug'=>$slug) to customize permastruct;
    863864 *     default will use $post_type as slug. Other options include 'with_front' and 'feeds'.
    … …  
    886887                'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => false,
    887888                '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false,
    888                 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null,
     889                'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true,
     890                'supports' => array(), 'register_meta_box_cb' => null,
    889891                'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null,
    890892                'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 'show_in_nav_menus' => null, 'show_in_menu' => null,
    … …  
    941943
    942944        if ( false !== $args->rewrite && '' != get_option('permalink_structure') ) {
    943                 if ( !is_array($args->rewrite) )
     945                if ( ! is_array( $args->rewrite ) )
    944946                        $args->rewrite = array();
    945                 if ( !isset($args->rewrite['slug']) )
     947                if ( ! isset( $args->rewrite['slug'] ) )
    946948                        $args->rewrite['slug'] = $post_type;
    947                 if ( !isset($args->rewrite['with_front']) )
     949                if ( ! isset( $args->rewrite['with_front'] ) )
    948950                        $args->rewrite['with_front'] = true;
    949                 if ( !isset($args->rewrite['archive']) )
    950                         $args->rewrite['archive'] = false;
    951                 if ( !isset($args->rewrite['feeds']) || !$args->rewrite['archive'] )
    952                         $args->rewrite['feeds'] = (bool) $args->rewrite['archive'];
     951                if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive )
     952                        $args->rewrite['feeds'] = (bool) $args->has_archive;
    953953
    954954                if ( $args->hierarchical )
    … …  
    957957                        $wp_rewrite->add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
    958958
    959                 if ( $args->rewrite['archive'] ) {
    960                         $archive_slug = $args->rewrite['archive'] === true ? $args->rewrite['slug'] : $args->rewrite['archive'];
     959                if ( $args->has_archive ) {
     960                        $archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive;
    961961                        $wp_rewrite->add_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' );
    962962                        if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {
  • trunk/wp-includes/query.php

    r15935 r15936  
    13351335                        if ( !empty( $qv['post_type'] ) && ! is_array( $qv['post_type'] ) ) {
    13361336                                $post_type_obj = get_post_type_object( $qv['post_type'] );
    1337                                 if ( is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['archive'] )
     1337                                if ( $post_type_obj->has_archive )
    13381338                                        $this->is_post_type_archive = true;
    13391339                        }
Note: See TracChangeset for help on using the changeset viewer.