From 49672ae6088a7616639d63f64132a502511dcce2 Mon Sep 17 00:00:00 2001 From: nacin Date: Tue, 26 Oct 2010 07:12:06 +0000 Subject: [PATCH] Allow page rewrites to be disabled. see #13818. git-svn-id: http://svn.automattic.com/wordpress/trunk@15970 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 0569ad7a7..244579d26 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -861,7 +861,7 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' ) * - permalink_epmask - The default rewrite endpoint bitmasks. * - has_archive - True to enable post type archives. Will generate the proper rewrite rules if rewrite is enabled. * - rewrite - false to prevent rewrite. Defaults to true. Use array('slug'=>$slug) to customize permastruct; - * default will use $post_type as slug. Other options include 'with_front' and 'feeds'. + * default will use $post_type as slug. Other options include 'with_front', 'feeds', and 'pages'. * - query_var - false to prevent queries, or string to value of the query var to use for this post type * - can_export - true allows this post type to be exported. * - show_in_nav_menus - true makes this post type available for selection in navigation menus. @@ -948,6 +948,8 @@ function register_post_type($post_type, $args = array()) { $args->rewrite['slug'] = $post_type; if ( ! isset( $args->rewrite['with_front'] ) ) $args->rewrite['with_front'] = true; + if ( ! isset( $args->rewrite['pages'] ) ) + $args->rewrite['pages'] = true; if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive ) $args->rewrite['feeds'] = (bool) $args->has_archive; @@ -964,7 +966,8 @@ function register_post_type($post_type, $args = array()) { $wp_rewrite->add_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); $wp_rewrite->add_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); } - $wp_rewrite->add_rule( "{$archive_slug}/page/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' ); + if ( $args->rewrite['pages'] ) + $wp_rewrite->add_rule( "{$archive_slug}/page/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' ); } $wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask);