diff --git a/wp-includes/post.php b/wp-includes/post.php
index 5eae599..17b5fa5 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -908,7 +908,7 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' )
  * @return object|WP_Error the registered post type object, or an error object
  */
 function register_post_type($post_type, $args = array()) {
-	global $wp_post_types, $wp_rewrite, $wp;
+	global $wp_post_types, $wp;
 
 	if ( !is_array($wp_post_types) )
 		$wp_post_types = array();
@@ -985,7 +985,30 @@ function register_post_type($post_type, $args = array()) {
 		$wp->add_query_var($args->query_var);
 	}
 
-	if ( false !== $args->rewrite && ( is_admin() || '' != get_option('permalink_structure') ) ) {
+	if ( $args->register_meta_box_cb )
+		add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
+
+	$args->labels = get_post_type_labels( $args );
+	$args->label = $args->labels->name;
+
+	$wp_post_types[$post_type] = $args;
+
+	add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 );
+
+	foreach ( $args->taxonomies as $taxonomy ) {
+		register_taxonomy_for_object_type( $taxonomy, $post_type );
+	}
+
+	return $args;
+}
+
+function _post_type_rewrite_rules() {
+	global $wp_rewrite;
+
+	if ( '' == get_option('permalink_structure') )
+		return;
+
+	foreach ( get_post_types( array( 'rewrite' => false ), 'objects', 'not' ) as $post_type => $args ) {
 		if ( ! is_array( $args->rewrite ) )
 			$args->rewrite = array();
 		if ( empty( $args->rewrite['slug'] ) )
@@ -1021,23 +1044,8 @@ function register_post_type($post_type, $args = array()) {
 
 		$wp_rewrite->add_permastruct($post_type, "{$args->rewrite['slug']}/%$post_type%", $args->rewrite['with_front'], $args->permalink_epmask);
 	}
-
-	if ( $args->register_meta_box_cb )
-		add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
-
-	$args->labels = get_post_type_labels( $args );
-	$args->label = $args->labels->name;
-
-	$wp_post_types[$post_type] = $args;
-
-	add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 );
-
-	foreach ( $args->taxonomies as $taxonomy ) {
-		register_taxonomy_for_object_type( $taxonomy, $post_type );
-	}
-
-	return $args;
 }
+add_action( 'pre_flush_rewrite_rules', '_post_type_rewrite_rules', 9 );
 
 /**
  * Builds an object with all post type capabilities out of a post type object
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index 4502db1..355c0ad 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -1857,6 +1857,7 @@ class WP_Rewrite {
 	 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
 	 */
 	function flush_rules($hard = true) {
+		do_action( 'pre_flush_rewrite_rules', $hard );
 		delete_option('rewrite_rules');
 		$this->wp_rewrite_rules();
 		if ( $hard && function_exists('save_mod_rewrite_rules') )
diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
index dee7af8..97e08ed 100644
--- a/wp-includes/taxonomy.php
+++ b/wp-includes/taxonomy.php
@@ -292,7 +292,7 @@ function is_taxonomy_hierarchical($taxonomy) {
  * @param array|string $args See above description for the two keys values.
  */
 function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
-	global $wp_taxonomies, $wp_rewrite, $wp;
+	global $wp_taxonomies, $wp;
 
 	if ( ! is_array($wp_taxonomies) )
 		$wp_taxonomies = array();
@@ -318,22 +318,6 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
 		$wp->add_query_var($args['query_var']);
 	}
 
-	if ( false !== $args['rewrite'] && '' != get_option('permalink_structure') ) {
-		$args['rewrite'] = wp_parse_args($args['rewrite'], array(
-			'slug' => sanitize_title_with_dashes($taxonomy),
-			'with_front' => true,
-			'hierarchical' => false
-		));
-
-		if ( $args['hierarchical'] && $args['rewrite']['hierarchical'] )
-			$tag = '(.+?)';
-		else
-			$tag = '([^/]+)';
-
-		$wp_rewrite->add_rewrite_tag("%$taxonomy%", $tag, $args['query_var'] ? "{$args['query_var']}=" : "taxonomy=$taxonomy&term=");
-		$wp_rewrite->add_permastruct($taxonomy, "{$args['rewrite']['slug']}/%$taxonomy%", $args['rewrite']['with_front']);
-	}
-
 	if ( is_null($args['show_ui']) )
 		$args['show_ui'] = $args['public'];
 
@@ -365,6 +349,30 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
  	add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');
 }
 
+function _taxonomy_rewrite_rules() {
+	global $wp_rewrite;
+
+	if ( '' == get_option('permalink_structure') )
+		return;
+
+	foreach ( get_taxonomies( array( 'rewrite' => false ), 'objects', 'not' ) as $taxonomy => $args ) {
+		$args->rewrite = wp_parse_args( $args->rewrite, array(
+			'slug' => sanitize_title_with_dashes( $taxonomy ),
+			'with_front' => true,
+			'hierarchical' => false
+		) );
+
+		if ( $args->hierarchical && $args->rewrite['hierarchical'] )
+			$tag = '(.+?)';
+		else
+			$tag = '([^/]+)';
+
+		$wp_rewrite->add_rewrite_tag( "%$taxonomy%", $tag, $args->query_var ? "{$args->query_var}=" : "taxonomy=$taxonomy&term=" );
+		$wp_rewrite->add_permastruct( $taxonomy, $args->rewrite['slug'] . "/%$taxonomy%", $args->rewrite['with_front'] );
+	}
+}
+add_action( 'pre_flush_rewrite_rules', '_taxonomy_rewrite_rules', 9 );
+
 /**
  * Builds an object with all taxonomy labels out of a taxonomy object
  *
