| 59 | | return $wp_rewrite->add_permastruct( $name, $struct, $with_front, $ep_mask ); |
| | 60 | |
| | 61 | // backwards compatibility for the old parameters: $with_front and $ep_mask |
| | 62 | if ( ! is_array( $args ) ) |
| | 63 | $args = array( 'with_front' => $args ); |
| | 64 | if ( func_num_args() == 4 ) |
| | 65 | $args['ep_mask'] = func_get_arg( 3 ); |
| | 66 | |
| | 67 | return $wp_rewrite->add_permastruct( $name, $struct, $args ); |
| 1521 | | foreach ( $this->extra_permastructs as $permastructname => $permastruct ) { |
| 1522 | | if ( is_array($permastruct) ) |
| 1523 | | $rules = $this->generate_rewrite_rules($permastruct[0], $permastruct[1]); |
| 1524 | | else |
| 1525 | | $rules = $this->generate_rewrite_rules($permastruct, EP_NONE); |
| | 1529 | foreach ( $this->extra_permastructs as $permastructname => $struct ) { |
| | 1530 | if ( is_array( $struct ) ) { |
| | 1531 | if ( count( $struct ) == 2 ) |
| | 1532 | $rules = $this->generate_rewrite_rules( $struct[0], $struct[1] ); |
| | 1533 | else |
| | 1534 | $rules = $this->generate_rewrite_rules( $struct['struct'], $struct['ep_mask'], $struct['paged'], $struct['feed'], $struct['forcomments'], $struct['walk_dirs'], $struct['endpoints'] ); |
| | 1535 | } else { |
| | 1536 | $rules = $this->generate_rewrite_rules( $struct ); |
| | 1537 | } |
| 1829 | | * @param string $struct Permalink structure. |
| 1830 | | * @param bool $with_front Prepend front base to permalink structure. |
| | 1848 | * @param string $struct Permalink structure (e.g. category/%category%) |
| | 1849 | * @param array $args Optional configuration for building the rules from the permalink structure: |
| | 1850 | * - with_front (bool) - Should the structure be prepended with WP_Rewrite::$front? Default is true. |
| | 1851 | * - ep_mask (int) - Endpoint mask defining what endpoints are added to the structure. Default is EP_NONE. |
| | 1852 | * - paged (bool) - Should archive pagination rules be added for the structure? Default is true. |
| | 1853 | * - feed (bool) - Should feed rewrite rules be added for the structure? Default is true. |
| | 1854 | * - forcomments (bool) - Should the feed rules be a query for a comments feed? Default is false. |
| | 1855 | * - walk_dirs (bool) - Should the 'directories' making up the structure be walked over and rewrite |
| | 1856 | * rules built for each in turn? Default is true. |
| | 1857 | * - endpoints (bool) - Should endpoints be applied to the generated rewrite rules? Default is true. |
| 1832 | | function add_permastruct($name, $struct, $with_front = true, $ep_mask = EP_NONE) { |
| 1833 | | if ( $with_front ) |
| | 1859 | function add_permastruct( $name, $struct, $args = array() ) { |
| | 1860 | // backwards compatibility for the old parameters: $with_front and $ep_mask |
| | 1861 | if ( ! is_array( $args ) ) |
| | 1862 | $args = array( 'with_front' => $args ); |
| | 1863 | if ( func_num_args() == 4 ) |
| | 1864 | $args['ep_mask'] = func_get_arg( 3 ); |
| | 1865 | |
| | 1866 | $defaults = array( |
| | 1867 | 'with_front' => true, |
| | 1868 | 'ep_mask' => EP_NONE, |
| | 1869 | 'paged' => true, |
| | 1870 | 'feed' => true, |
| | 1871 | 'forcomments' => false, |
| | 1872 | 'walk_dirs' => true, |
| | 1873 | 'endpoints' => true, // really necessary? |
| | 1874 | ); |
| | 1875 | $args = wp_parse_args( $args, $defaults ); |
| | 1876 | $args['struct'] = $struct; |
| | 1877 | |
| | 1878 | if ( $args['with_front'] ) |