WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/20/2010 02:05:32 AM (10 years ago)
Author:
dd32
Message:

Allow for a custom Endpoint Mask to be passed to add_endpoint(). Allows for endpoints to be targeted to specific rewrite rules. Allow custom post_types to specify their Endpoint mask. Allows for post_type's rewrite rules to inherit Post endpoints, or alternatively, allows for add_endpoint() to target specific post_types. Fixes #12605

File:
1 edited

Legend:

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

    r13769 r13773  
    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
     
    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;
     
    13601360                    $ep_mask_specific = EP_DAY;
    13611361                    break;
     1362                default:
     1363                    $ep_mask_specific = EP_NONE;
    13621364            }
    13631365
     
    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.
     
    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
Note: See TracChangeset for help on using the changeset viewer.