WordPress.org

Make WordPress Core

Ticket #12605: 12605.diff

File 12605.diff, 4.0 KB (added by dd32, 8 years ago)
  • wp-includes/post.php

     
    790790                $wp_post_types = array();
    791791
    792792        // Args prefixed with an underscore are reserved for internal use.
    793         $defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null );
     793        $defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'permalink_epmask' => EP_NONE );
    794794        $args = wp_parse_args($args, $defaults);
    795795        $args = (object) $args;
    796796
     
    852852                if ( !isset($args->rewrite['with_front']) )
    853853                        $args->rewrite['with_front'] = true;
    854854                $wp_rewrite->add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name=");
    855                 $wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front']);
     855                $wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask);
    856856        }
    857857
    858858        if ( $args->register_meta_box_cb )
  • wp-includes/rewrite.php

     
    5454 * @param string $struct Permalink structure.
    5555 * @param bool $with_front Prepend front base to permalink structure.
    5656 */
    57 function add_permastruct( $name, $struct, $with_front = true ) {
     57function add_permastruct( $name, $struct, $with_front = true, $ep_mask = EP_NONE ) {
    5858        global $wp_rewrite;
    59         return $wp_rewrite->add_permastruct( $name, $struct, $with_front );
     59        return $wp_rewrite->add_permastruct( $name, $struct, $with_front, $ep_mask );
    6060}
    6161
    6262/**
     
    10831083                        return false;
    10841084
    10851085                if ( isset($this->extra_permastructs[$name]) )
    1086                         return $this->extra_permastructs[$name];
     1086                        return $this->extra_permastructs[$name][0];
    10871087
    10881088                return false;
    10891089        }
     
    13591359                                case '%day%':
    13601360                                        $ep_mask_specific = EP_DAY;
    13611361                                        break;
     1362                                default:
     1363                                        $ep_mask_specific = EP_NONE;
    13621364                        }
    13631365
    13641366                        //create query for /page/xx
     
    16111613                $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
    16121614
    16131615                // Extra permastructs
    1614                 foreach ( $this->extra_permastructs as $permastruct )
    1615                         $this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct, EP_NONE));
     1616                foreach ( $this->extra_permastructs as $permastruct ) {
     1617                        if ( is_array($permastruct) )
     1618                                $this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct[0], $permastruct[1]));
     1619                        else
     1620                                $this->extra_rules_top = array_merge($this->extra_rules_top, $this->generate_rewrite_rules($permastruct, EP_NONE));
     1621                }
    16161622
    16171623                // Put them together.
    16181624                if ( $this->use_verbose_page_rules )
     
    19061912         * @param string $struct Permalink structure.
    19071913         * @param bool $with_front Prepend front base to permalink structure.
    19081914         */
    1909         function add_permastruct($name, $struct, $with_front = true) {
     1915        function add_permastruct($name, $struct, $with_front = true, $ep_mask = EP_NONE) {
    19101916                if ( $with_front )
    19111917                        $struct = $this->front . $struct;
    1912                 $this->extra_permastructs[$name] = $struct;
     1918                $this->extra_permastructs[$name] = array($struct, $ep_mask);
    19131919        }
    19141920
    19151921        /**